Exemplo n.º 1
0
        public void SubmitQuestionReportAndUpdateProgress(TestTemplateInfo templateInfo, QuestionModel question)
        {
            string correctAnswer;

            if (this.TestType == AppConstants.TEST_TYPE_TYPE_ALONG)
            {
                correctAnswer = question.Question;
            }
            else
            {
                correctAnswer = TestQuestionBank.Where(x => x.Key == question.Question).FirstOrDefault().Value;
            }

            if (this.TestType == AppConstants.TEST_TYPE_MULTIPLE_CHOICE)
            {
                question.UserEnteredAnswer = question.SelectedAnswerIndex != -1?question.AnswerChooserList.ElementAt(question.SelectedAnswerIndex):string.Empty;
            }

            if (question.UserEnteredAnswer == null)
            {
                question.UserEnteredAnswer = string.Empty;
            }
            //to avoid case sensitivity
            bool IsValidAnswer = correctAnswer.ToLower() == question.UserEnteredAnswer.ToLower() ? true : false;

            TestProgress.Add(templateInfo.TestQuestionId, IsValidAnswer);
        }
Exemplo n.º 2
0
        List <TestTemplateInfo> GetTestTemplateDetails()
        {
            List <TestTemplateInfo> templateDetails = new List <TestTemplateInfo>();

            for (int item = 0; item < TestQuestionBank.Count; item++)
            {
                var           detail = TestQuestionBank.ElementAt(item);
                QuestionModel question;
                if (TestType == AppConstants.TEST_TYPE_TYPE_ALONG)
                {
                    question = new QuestionModel()
                    {
                        Question = detail.Value
                    };
                }
                else if (TestType == AppConstants.TEST_TYPE_MULTIPLE_CHOICE)
                {
                    question = new QuestionModel()
                    {
                        Question = detail.Key, AnswerChooserList = GetAnswerChooserList(detail)
                    };
                }
                else
                {
                    question = new QuestionModel()
                    {
                        Question = detail.Key
                    };
                }


                Random           rnd = new Random();
                TestTemplateInfo templateInformation = new TestTemplateInfo()
                {
                    TestQuestionId   = item,
                    TestQuestion     = question,
                    QuestionTemplate = GetTemplateFromTestType(this.TestType)
                                       //For shuffle
                                       //R   QuestionTemplate = AvailableTemplates.ElementAt(rnd.Next(0, AvailableTemplates.Count))
                };

                templateDetails.Add(templateInformation);
            }


            return(templateDetails);
        }