Ejemplo n.º 1
0
        public async Task <ActionResult> DropQuiz(string courseId, string slideId, bool isLti)
        {
            var slide = courseManager.GetCourse(courseId).GetSlideById(slideId);

            if (slide is QuizSlide)
            {
                var userId = User.Identity.GetUserId();
                if (userQuizzesRepo.GetQuizDropStates(courseId, userId, slideId).Count(b => b) < GetMaxDropCount(slide as QuizSlide) &&
                    !userQuizzesRepo.GetQuizBlocksTruth(courseId, userId, slideId).All(b => b.Value))
                {
                    await userQuizzesRepo.DropQuiz(userId, slideId);

                    await visitsRepo.DropAttempt(slideId, userId);

                    if (isLti)
                    {
                        LtiUtils.SubmitScore(slide, userId);
                    }
                }
            }
            var model = new { courseId, slideIndex = slide.Index, isLti };

            if (isLti)
            {
                return(RedirectToAction("LtiSlide", "Course", model));
            }
            return(RedirectToAction("Slide", "Course", model));
        }