public NextQuestionResult GetNextQuestion(int testId, int userId, int nextQuestionNumber) { GheckForTestUnlockedForUser(testId, userId); List <AnswerOnTestQuestion> testAnswers = GetAnswersForTest(testId, userId); Dictionary <int, PassedQuestionResult> questionsStatuses = GetQuestionStatuses(testAnswers); Tuple <Question, int> nextQuestion = GetQuestion(testAnswers, nextQuestionNumber, userId); var result = new NextQuestionResult { Question = nextQuestion.Item1 == null ? null : nextQuestion.Item1, Number = nextQuestion.Item1 == null ? 0 : nextQuestion.Item2, QuestionsStatuses = questionsStatuses }; if (nextQuestion.Item1 == null) { result.Mark = nextQuestion.Item2; } if (nextQuestion.Item1 != null) { result.Seconds = GetRemainingTime(testId, nextQuestion.Item1.Id, userId); } var test = GetTest(testId); result.SetTimeForAllTest = test.SetTimeForAllTest; result.ForSelfStudy = test.ForSelfStudy; return(result); }
public NextQuestionResult GetNextQuestion(int testId, int userId, int nextQuestionNumber) { GheckForTestUnlockedForUser(testId, userId); var testAnswers = GetAnswersForTest(testId, userId); var questionsStatuses = GetQuestionStatuses(testAnswers); var nextQuestion = GetQuestion(testAnswers, nextQuestionNumber, userId); var result = new NextQuestionResult { Question = nextQuestion.Item1, Number = nextQuestion.Item1 == null ? 0 : nextQuestion.Item2, QuestionsStatuses = questionsStatuses }; if (nextQuestion.Item1 == null) { result.Mark = nextQuestion.Item2; result.Percent = nextQuestion.Item3; } if (nextQuestion.Item1 != null) { result.Seconds = GetRemainingTime(testId, nextQuestion.Item1.Id, userId); } var test = GetTest(testId); result.SetTimeForAllTest = test.SetTimeForAllTest; result.ForSelfStudy = test.ForSelfStudy; return(result); }
public PartialViewResult GetNextQuestion(int testId, int questionNumber) { if (questionNumber == 1 && TestsManagementService.GetTest(testId, true).Questions.Count == 0) { ViewBag.Message = "Тест не содержит ни одного вопроса"; return(PartialView("Error")); } NextQuestionResult nextQuestion = TestPassingService.GetNextQuestion(testId, CurrentUserId, questionNumber); if (nextQuestion.Question == null) { ViewBag.Mark = nextQuestion.Mark; return(PartialView("EndTest", nextQuestion.QuestionsStatuses)); } return(PartialView("GetNextQuestion", nextQuestion)); }