private TocModel CreateToc(Slide slide) { var builder = new TocModelBuilder(GetSlideUrl, s => 0, course, slide.Index) { IsInstructor = true, GetUnitInstructionNotesUrl = unitName => GetInstructorNotesFilename(unitName), GetUnitStatisticsUrl = unitName => "404.html" }; return(builder.CreateTocModel()); }
private TocModel CreateToc(Slide slide) { var builder = new TocModelBuilder(GetSlideUrl, s => 0, s => s.MaxScore, (u, g) => 0, course, slide.Id) { IsInstructor = true, GetUnitInstructionNotesUrl = GetInstructorNotesFilename, GetUnitStatisticsUrl = unit => "404.html", IsSlideHidden = s => false }; return(builder.CreateTocModel()); }
private TocModel CreateTocModel(Course course, Guid?currentSlideId, string userId) { var visibleUnits = unitsRepo.GetVisibleUnits(course, User); var visited = visitsRepo.GetIdOfVisitedSlides(course.Id, userId); var scoresForSlides = visitsRepo.GetScoresForSlides(course.Id, userId); var solvedSlidesIds = ControllerUtils.GetSolvedSlides(solutionsRepo, userQuizzesRepo, course, userId); var slidesWithUsersManualChecking = visitsRepo.GetSlidesWithUsersManualChecking(course.Id, userId).ToImmutableHashSet(); var enabledManualCheckingForUser = groupsRepo.IsManualCheckingEnabledForUser(course, userId); Func <Slide, int> getSlideMaxScoreFunc = s => ControllerUtils.GetMaxScoreForUsersSlide(s, solvedSlidesIds.Contains(s.Id), slidesWithUsersManualChecking.Contains(s.Id), enabledManualCheckingForUser); var userGroupsIds = groupsRepo.GetUserGroupsIds(course.Id, userId); var enabledScoringGroupsIds = groupsRepo.GetEnabledAdditionalScoringGroups(course.Id) .Where(e => userGroupsIds.Contains(e.GroupId)) .Select(e => e.ScoringGroupId) .ToList(); var additionalScores = additionalScoresRepo.GetAdditionalScoresForUser(course.Id, userId); var builder = new TocModelBuilder( s => Url.RouteUrl("Course.SlideById", new { courseId = course.Id, slideId = s.Url }), s => scoresForSlides.ContainsKey(s.Id) ? scoresForSlides[s.Id] : 0, getSlideMaxScoreFunc, (u, g) => additionalScores.GetOrDefault(Tuple.Create(u.Id, g.Id), 0), course, currentSlideId) { GetUnitInstructionNotesUrl = unit => Url.Action("InstructorNote", "Course", new { courseId = course.Id, unitId = unit.Id }), GetUnitStatisticsUrl = unit => Url.Action("UnitStatistics", "Analytics", new { courseId = course.Id, unitId = unit.Id }), IsInstructor = User.HasAccessFor(course.Id, CourseRole.Instructor), IsSolved = s => solvedSlidesIds.Contains(s.Id), IsVisited = s => visited.Contains(s.Id), IsUnitVisible = visibleUnits.Contains, IsSlideHidden = s => s is QuizSlide && ((QuizSlide)s).ManualChecking && !enabledManualCheckingForUser && !solvedSlidesIds.Contains(s.Id), EnabledScoringGroupsIds = enabledScoringGroupsIds, }; var userGroups = groupsRepo.GetUserGroups(course.Id, User.Identity.GetUserId()); var tocGroupsForStatistics = userGroups.Select(g => new TocGroupForStatistics { GroupName = g.Name, StatisticsUrl = Url.Action("CourseStatistics", "Analytics", new { courseId = course.Id, group = g.Id }) }); var toc = builder.CreateTocModel(tocGroupsForStatistics.ToList()); toc.NextUnitTime = unitsRepo.GetNextUnitPublishTime(course.Id); return(toc); }
private TocModel CreateGuestTocModel(Course course, int slideIndex) { var visibleUnits = unitsRepo.GetVisibleUnits(course.Id, User); var builder = new TocModelBuilder( s => Url.Action("Slide", "Course", new { courseId = course.Id, slideIndex = s.Index }), s => 0, course, slideIndex); builder.IsInstructor = false; builder.IsVisited = s => false; builder.IsUnitVisible = visibleUnits.Contains; var toc = builder.CreateTocModel(); toc.NextUnitTime = unitsRepo.GetNextUnitPublishTime(course.Id); return(toc); }
private TocModel CreateGuestTocModel(Course course, Guid?currentSlideId) { var visibleUnits = unitsRepo.GetVisibleUnits(course, User); var builder = new TocModelBuilder( s => Url.RouteUrl("Course.SlideById", new { courseId = course.Id, slideId = s.Url }), s => 0, s => 0, (u, g) => 0, course, currentSlideId) { IsInstructor = false, IsVisited = s => false, IsUnitVisible = visibleUnits.Contains, IsSlideHidden = s => s is QuizSlide && ((QuizSlide)s).ManualChecking }; var toc = builder.CreateTocModel(); toc.NextUnitTime = unitsRepo.GetNextUnitPublishTime(course.Id); return(toc); }
private TocModel CreateTocModel(Course course, int slideIndex, string userId) { var visibleUnits = unitsRepo.GetVisibleUnits(course.Id, User); var solved = GetSolvedSlides(course, userId); var visited = visitsRepo.GetIdOfVisitedSlides(course.Id, userId); var scoresForSlides = visitsRepo.GetScoresForSlides(course.Id, userId); var builder = new TocModelBuilder( s => Url.Action("Slide", "Course", new { courseId = course.Id, slideIndex = s.Index }), s => scoresForSlides.ContainsKey(s.Id) ? scoresForSlides[s.Id] : 0, course, slideIndex); builder.GetUnitInstructionNotesUrl = unitName => Url.Action("InstructorNote", "Course", new { courseId = course.Id, unitName }); builder.GetUnitStatisticsUrl = unitName => Url.Action("UnitStatistics", "Analytics", new { courseId = course.Id, unitName }); builder.IsInstructor = User.HasAccessFor(course.Id, CourseRole.Instructor); builder.IsSolved = s => solved.Contains(s.Id); builder.IsVisited = s => visited.Contains(s.Id); builder.IsUnitVisible = visibleUnits.Contains; var toc = builder.CreateTocModel(); toc.NextUnitTime = unitsRepo.GetNextUnitPublishTime(course.Id); return(toc); }