Beispiel #1
0
        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();
                if (userQuizzesRepo.GetQuizDropStates(courseId, userId, slideId).Count(b => b) < GetMaxDropCount(slide as QuizSlide) &&
                    !userQuizzesRepo.IsQuizScoredMaximum(courseId, userId, slideId))
                {
                    await userQuizzesRepo.DropQuiz(userId, slideId);

                    await slideCheckingsRepo.RemoveAttempts(courseId, slideId, userId);

                    await visitsRepo.UpdateScoreForVisit(courseId, slideId, userId);

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

            if (isLti)
            {
                return(RedirectToAction("LtiSlide", "Course", model));
            }
            return(RedirectToAction("SlideById", "Course", model));
        }
Beispiel #2
0
        public async Task <ActionResult> ForgetAll(string courseId, Guid slideId)
        {
            var slide  = courseManager.GetCourse(courseId).GetSlideById(slideId);
            var userId = User.Identity.GetUserId();

            db.SolutionLikes.RemoveRange(db.SolutionLikes.Where(q => q.UserId == userId && q.Submission.SlideId == slideId));

            db.UserExerciseSubmissions.RemoveSlideAction(courseId, slideId, userId);
            db.UserQuizSubmissions.RemoveSlideAction(courseId, slideId, userId);
            db.Visits.RemoveSlideAction(courseId, slideId, userId);
            await slideCheckingsRepo.RemoveAttempts(courseId, slideId, userId, false);

            db.UserQuestions.RemoveSlideAction(courseId, slideId, userId);
            db.SlideRates.RemoveSlideAction(courseId, slideId, userId);
            db.Hints.RemoveSlideAction(courseId, slideId, userId);
            await db.SaveChangesAsync();

            return(RedirectToAction("SlideById", new { courseId, slideId = slide.Id }));
        }