Example #1
0
		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();
		}
Example #2
0
		private TocModel CreateToc(Slide slide)
		{
			var builder = new TocModelBuilder(GetSlideUrl, s => 0, s => s.MaxScore, course, slide.Id)
			{
				IsInstructor = true,
				GetUnitInstructionNotesUrl = unitName => GetInstructorNotesFilename(unitName),
				GetUnitStatisticsUrl = unitName => "404.html",
				IsSlideHidden = s => false
			};
			return builder.CreateTocModel();
		}
		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.Id, User);
			var builder = new TocModelBuilder(
				s => Url.RouteUrl("Course.SlideById", new { courseId = course.Id, slideId = s.Url }),
				s => 0,
				s => 0,
				course,
				currentSlideId);
			builder.IsInstructor = false;
			builder.IsVisited = s => false;
			builder.IsUnitVisible = visibleUnits.Contains;
			builder.IsSlideHidden = s => s is QuizSlide && ((QuizSlide)s).Quiz.ManualCheck;
			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;
		}
		private TocModel CreateTocModel(Course course, Guid? currentSlideId, string userId)
		{
			var visibleUnits = unitsRepo.GetVisibleUnits(course.Id, User);
			var solvedSlidesIds = GetSolvedSlides(course, userId);
			var visited = visitsRepo.GetIdOfVisitedSlides(course.Id, userId);
			var scoresForSlides = visitsRepo.GetScoresForSlides(course.Id, userId);
			var slidesWithUsersManualChecking = visitsRepo.GetSlidesWithUsersManualChecking(course.Id, userId).ToImmutableHashSet();
			var enabledManualCheckingForUser = groupsRepo.IsManualCheckingEnabledForUser(course, 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,
				s => GetMaxScoreForUsersSlide(s, solvedSlidesIds.Contains(s.Id), slidesWithUsersManualChecking.Contains(s.Id), enabledManualCheckingForUser),
				course,
				currentSlideId)
			{
				GetUnitInstructionNotesUrl = unitName => Url.Action("InstructorNote", "Course", new { courseId = course.Id, unitName }),
				GetUnitStatisticsUrl = unitName => Url.Action("UnitStatistics", "Analytics", new { courseId = course.Id, unitName }),
				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).Quiz.ManualCheck &&
									!enabledManualCheckingForUser && !solvedSlidesIds.Contains(s.Id)
			};

			var toc = builder.CreateTocModel();
			toc.NextUnitTime = unitsRepo.GetNextUnitPublishTime(course.Id);
			return toc;
		}
Example #7
0
		private TocModel CreateToc(Course course, Slide slide)
		{
			var builder = new TocModelBuilder(GetSlideUrl, s => 0, course, slide.Index) { IsInstructor = true, GetUnitInstructionNotesUrl = x => x + ".html", GetUnitStatisticsUrl = x => "404.html" };
			return builder.CreateTocModel();
		}
Example #8
0
		private TocModel CreateToc(Course course, Slide slide)
		{
			var builder = new TocModelBuilder(s => GetSlideUrl(s), s => 0, course, slide.Index);
			return builder.CreateTocModel();
		}