Пример #1
0
 private void AddQuestionToList(TestQuestion question)
 {
     if (Questions.Count < PageCount)
     {
         Questions.Add(question);
     }
 }
Пример #2
0
        /// <summary>
        /// Generates question with answers
        /// </summary>
        /// <returns>TestQuestion</returns>
        public static TestQuestion CreateQuestion(string questionText, int idQuestion, params TestAnswer[] answers)
        {
            TestQuestion question = new TestQuestion();

            question.QuestionText = questionText;
            question.QuestionId   = idQuestion;

            question.Answers.AddRange(answers);

            return(question);
        }
Пример #3
0
        /// <summary>
        /// Function to get given uncorrect answer's id
        /// </summary>
        /// <param name="pageIndex">current page index</param>
        /// <param name="question">current question</param>
        /// <returns>Uncorrect answer id, if it was found</returns>
        private int?wrongAnswerId(int pageIndex, TestQuestion question)
        {
            int?wrongAnswerId = null;

            // if all questions have been answered
            if (GivenAnswers != null && GivenAnswers.Count == PageCount)
            {
                var givenAnswerId = GivenAnswers[pageIndex - 1];

                var answ      = question.Answers;
                var correctId = answ.Where(a => a.IsCorrectAnswer);

                if (givenAnswerId != correctId.First().Id)
                {
                    wrongAnswerId = givenAnswerId;
                }
            }

            return(wrongAnswerId);
        }
Пример #4
0
        public override void GetItems(int pageSize, int pageIndex)
        {
            CurrentQuestion = new TestQuestion();
            Items           = new AdvancedObservableCollection <TestAnswer>();


            switch (pageIndex)
            {
            case 1:
            {
                var correctAnswers =
                    QuestionsGenerator.GenerateFirstQuestion(null);
                var answerId = wrongAnswerId(PageIndex, correctAnswers);

                CurrentQuestion = QuestionsGenerator.GenerateFirstQuestion(answerId);

                break;
            }

            case 2:
            {
                var correctAnswers =
                    QuestionsGenerator.GenerateSecondQuestion(null);
                var answerId = wrongAnswerId(PageIndex, correctAnswers);

                CurrentQuestion = QuestionsGenerator.GenerateSecondQuestion(answerId);

                break;
            }

            case 3:
            {
                var correctAnswers =
                    QuestionsGenerator.GenerateThirdQuestion(null);
                var answerId = wrongAnswerId(PageIndex, correctAnswers);

                CurrentQuestion = QuestionsGenerator.GenerateThirdQuestion(answerId);
                break;
            }

            case 4:
            {
                var correctAnswers =
                    QuestionsGenerator.GenerateFourthQuestion(null);
                var answerId = wrongAnswerId(PageIndex, correctAnswers);

                CurrentQuestion = QuestionsGenerator.GenerateFourthQuestion(answerId);
                break;
            }

            case 5:
            {
                var correctAnswers =
                    QuestionsGenerator.GenerateFifthQuestion(null);
                var answerId = wrongAnswerId(PageIndex, correctAnswers);


                CurrentQuestion = QuestionsGenerator.GenerateFifthQuestion(answerId);
                break;
            }

            case 6:
            {
                var correctAnswers =
                    QuestionsGenerator.GenerateSixthQuestion(null);
                var answerId = wrongAnswerId(PageIndex, correctAnswers);


                CurrentQuestion = QuestionsGenerator.GenerateSixthQuestion(answerId);
                break;
            }
            }

            Items.AddRange(CurrentQuestion.Answers);
            AddQuestionToList(CurrentQuestion);
        }