public async Task <IActionResult> SolveQuiz(Guid quizId) { SampleQuiz sample = await _context.GetSampleQuiz(quizId); SolvingQuiz quiz = SolvingQuiz.CreateFromSample(sample); await _context.AddQuizesToUser(quiz, sample, _userManager.GetUserId(User)); return(RedirectToAction("SolveQuestions", new { quizId = quiz.Id, sampleId = sample.Id })); }
public async Task <IActionResult> SolveQuestions(Guid quizId, Guid sampleId) { SolvingQuiz quiz = await _context.GetSolvingQuiz(quizId); SampleQuiz sample = await _context.GetSampleQuiz(sampleId); SolvedQuestion solvedQuestion = quiz.Questions.First(); SolvingQuestionModel question = new SolvingQuestionModel(sample.Questions.Find(s => s.QuestionText.Equals(solvedQuestion.QuestionText)), solvedQuestion); return(View(question)); }
public async Task <IActionResult> SolveQuestions(SolvingQuestionModel model) { if (ModelState.IsValid) { SolvingQuiz quiz = await _context.GetSolvingQuiz(model.SolvingQuizId); SampleQuiz sample = await _context.GetSampleQuiz(model.SampleQuizId); _context.StoreUserAnswer(model.UserAnswer, quiz.Questions.ElementAt(model.QuestionNumber - 1)); await _context.CalculateStats(quiz); if (model.QuestionNumber == quiz.NumberOfQuestions) { return(RedirectToAction("Profile")); } model.nextQuestion(sample.Questions, quiz.Questions.ElementAt(model.QuestionNumber)); } return(View(model)); }
public async Task <IActionResult> SolvedQuizDetails(Guid quizId) { SolvingQuiz quiz = await _context.GetSolvingQuiz(quizId); return(View(quiz)); }