public async Task <ActionResult> DropQuiz(string courseId, Guid slideId, bool isLti) { var slide = courseManager.GetCourse(courseId).GetSlideById(slideId); if (slide is QuizSlide) { var userId = User.Identity.GetUserId(); var userQuizDrops = userQuizzesRepo.GetQuizDropStates(courseId, userId, slideId).Count(b => b); var maxTriesCount = GetMaxTriesCount(courseId, slide as QuizSlide); var isQuizScoredMaximum = userQuizzesRepo.IsQuizScoredMaximum(courseId, userId, slideId); if (userQuizDrops + 1 < maxTriesCount && !isQuizScoredMaximum) { await userQuizzesRepo.DropQuizAsync(courseId, userId, slideId); await visitsRepo.UpdateScoreForVisit(courseId, slideId, userId); if (isLti) { LtiUtils.SubmitScore(courseId, slide, userId); } } else if ((userQuizDrops + 1 >= maxTriesCount || isQuizScoredMaximum) && !(slide as QuizSlide).ManualChecking) { /* Allow user to drop quiz after all tries are exceeded, but don't update score */ await userQuizzesRepo.DropQuizAsync(courseId, userId, slideId); } } var model = new { courseId, slideId = slide.Id, isLti }; if (isLti) { return(RedirectToAction("LtiSlide", "Course", model)); } return(RedirectToAction("SlideById", "Course", model)); }