示例#1
0
        internal static void AssertEqual(AnswerOptionDTO answerOption, SampleExam.Features.Question.Edit.AnswerData answer)
        {
            if (answer.Id.HasValue)
            {
                Assert.True(answer.Id == answerOption.Id);
            }

            Assert.True(answer.IsRight == answerOption.IsRight && answer.Text == answerOption.Text);
        }
示例#2
0
        public int GetResultFromTest(int idTest, List <QuestionDTO> testQuestionsFromUser, string nameUser)
        {
            var testParent = GetTest(idTest);

            int countAllAnswerOption = 0;

            foreach (var item in testParent)
            {
                foreach (var itemAnswer in item.AnswerOptionsDTO)
                {
                    countAllAnswerOption++;
                }
            }


            int countAnswers = 0;

            foreach (var itemQuestion in testParent)
            {
                QuestionDTO userAnswers = testQuestionsFromUser.FirstOrDefault(x => x.ID == itemQuestion.ID);
                foreach (var itemAnswerOptions in itemQuestion.AnswerOptionsDTO)
                {
                    AnswerOptionDTO userAnswer = userAnswers.AnswerOptionsDTO.FirstOrDefault(x => x.ID == itemAnswerOptions.ID);

                    if (itemAnswerOptions.isTrueAnswer == userAnswer.isTrueAnswer)
                    {
                        countAnswers++;
                    }
                    else
                    {
                        countAnswers--;
                    }
                }
            }

            int mark      = Convert.ToInt32(countAnswers / countAllAnswerOption * 100);
            int idteacher = testParent.ElementAt(0).TestDTO.TeacherID;

            (wrapper as WrapperTeacher).AddResultFromPassedTest(idteacher, nameUser, mark);
            return(mark);
        }
 public void DeleteAnswerOption(AnswerOptionDTO answer)
 {
     wrapper.Delete(mapper.Map <AnswerOptionDTO, AnswerOption>(answer));
 }
 public void AddAnswerOption(AnswerOptionDTO answer)
 {
     wrapper.AddItem(mapper.Map <AnswerOptionDTO, AnswerOption>(answer));
 }