public ActionResult PrevNextButtons(string courseId, Guid slideId, bool onSolutionsSlide) { var course = courseManager.GetCourse(courseId); var slide = course.FindSlideById(slideId); if (slide == null) { return(Content("")); } var userId = User.Identity.GetUserId(); var nextIsAcceptedSolutions = !onSolutionsSlide && slide is ExerciseSlide && visitsRepo.IsSkippedOrPassed(courseId, 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, (slide as ExerciseSlide)?.Exercise.HideShowSolutionsButton ?? false, 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)); }