Example #1
0
        public void OnGet(int id)
        {
            var content = sessionHelper.GetContent();
            var quiz    = content.Item1;
            var answers = content.Item2;

            QuestionViewModel = new QuestionViewModel
            {
                Question = quiz.Questions.Where(q => q.Id == id).FirstOrDefault(),
                Answer   = answers.ContainsKey(id) ?
                           answers[id] : string.Empty,
                Number = id,
                Total  = quiz.Questions.Count()
            };
            ViewData["Title"] = $"Question {QuestionViewModel.Number} of {QuestionViewModel.Total}";
        }
Example #2
0
        public void OnGet()
        {
            var content = sessionHelper.GetContent();

            FinishViewModel = new FinishViewModel
            {
                Quiz    = content.Item1,
                Answers = content.Item2
            };
            FinishViewModel.CorrectAnswers = FinishViewModel.Quiz.Questions.ToList().Count(q =>
                                                                                           q.CorrectAnswer.Equals(FinishViewModel.Answers[q.QuestionId - 1]));
            ViewData["Title"] = "End of Quiz";
        }