Ejemplo n.º 1
0
        private ExerciseBlockData CreateAcceptedAlertModel(ExerciseSlide slide, Course course)
        {
            var userId            = User.Identity.GetUserId();
            var isSkippedOrPassed = visitsRepo.IsSkippedOrPassed(course.Id, slide.Id, userId);
            /* TODO: It's not necessary to create ExerciseBlockData here */
            var model = new ExerciseBlockData(course.Id, slide, isSkippedOrPassed)
            {
                CourseId = course.Id,
                IsGuest  = !User.Identity.IsAuthenticated,
                Url      = Url,
            };

            return(model);
        }
Ejemplo n.º 2
0
        public ViewResult AcceptedAlert(string courseId, int slideIndex = 0)
        {
            var userId            = User.Identity.GetUserId();
            var course            = courseManager.GetCourse(courseId);
            var slide             = (ExerciseSlide)course.Slides[slideIndex];
            var isSkippedOrPassed = visitsRepo.IsSkippedOrPassed(slide.Id, userId);
            var model             = new ExerciseBlockData
            {
                IsSkippedOrPassed   = isSkippedOrPassed,
                AcceptedSolutionUrl = Url.Action("AcceptedSolutions", "Course", new { courseId, slideIndex, isLti = true }),
                CourseId            = courseId,
                SlideIndex          = slideIndex
            };

            return(View(model));
        }
        public ActionResult PrevNextButtons(string courseId, Guid slideId, bool onSolutionsSlide)
        {
            var course = courseManager.GetCourse(courseId);
            var slide  = course.GetSlideById(slideId);
            var userId = User.Identity.GetUserId();
            var nextIsAcceptedSolutions = !onSolutionsSlide && slide is ExerciseSlide && visitsRepo.IsSkippedOrPassed(slide.Id, userId) && !((ExerciseSlide)slide).Exercise.HideShowSolutionsButton;
            var visibleUnits            = unitsRepo.GetVisibleUnits(course, User);
            var nextSlide = course.Slides.FirstOrDefault(s => s.Index > slide.Index && visibleUnits.Contains(s.Info.Unit));
            var prevSlide = course.Slides.LastOrDefault(s => s.Index < slide.Index && visibleUnits.Contains(s.Info.Unit));

            var model = new PrevNextButtonsModel(
                course,
                slide.Id,
                nextIsAcceptedSolutions,
                nextSlide,
                prevSlide,
                !User.Identity.IsAuthenticated);

            if (onSolutionsSlide)
            {
                model.SetPrevSlide(slide);
            }
            return(PartialView(model));
        }
        public ActionResult PrevNextButtons(string courseId, int slideIndex, bool onSolutionsSlide)
        {
            var course = courseManager.GetCourse(courseId);
            var slide  = course.Slides[slideIndex];
            var userId = User.Identity.GetUserId();
            var nextIsAcceptedSolutions = !onSolutionsSlide && slide is ExerciseSlide && visitsRepo.IsSkippedOrPassed(slide.Id, userId);
            var visibleUnits            = unitsRepo.GetVisibleUnits(courseId, User);
            var nextSlide = course.Slides.FirstOrDefault(s => s.Index > slideIndex && visibleUnits.Contains(s.Info.UnitName));
            var prevSlide = course.Slides.LastOrDefault(s => s.Index < slideIndex && visibleUnits.Contains(s.Info.UnitName));

            var model = new PrevNextButtonsModel(
                course,
                slideIndex,
                nextIsAcceptedSolutions,
                nextSlide == null ? -1 : nextSlide.Index,
                prevSlide == null ? -1 : prevSlide.Index,
                !User.Identity.IsAuthenticated);

            if (onSolutionsSlide)
            {
                model.PrevSlideIndex = model.SlideIndex;
            }
            return(PartialView(model));
        }