コード例 #1
0
ファイル: AnalyticsController.cs プロジェクト: epeshk/uLearn
        public ActionResult UserUnitStatistics(string courseId, Guid unitId, string userId)
        {
            var course = courseManager.GetCourse(courseId);
            var user   = usersRepo.FindUserById(userId);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var unit                = course.GetUnitById(unitId);
            var slides              = unit.Slides;
            var exercises           = slides.OfType <ExerciseSlide>();
            var acceptedSubmissions = userSolutionsRepo
                                      .GetAllAcceptedSubmissionsByUser(courseId, exercises.Select(s => s.Id), userId)
                                      .OrderByDescending(s => s.Timestamp)
                                      .DistinctBy(u => u.SlideId);
            var userScores = visitsRepo.GetScoresForSlides(courseId, userId, slides.Select(s => s.Id));

            var model = new UserUnitStatisticsPageModel
            {
                Course      = course,
                Unit        = unit,
                User        = user,
                Slides      = slides.ToDictionary(s => s.Id),
                Submissions = acceptedSubmissions.ToList(),
                Scores      = userScores,
            };

            return(View(model));
        }
コード例 #2
0
        public ActionResult UserUnitStatistics(string courseId, Guid unitId, string userId)
        {
            var course = courseManager.GetCourse(courseId);
            var user   = usersRepo.FindUserById(userId);

            if (user == null)
            {
                return(HttpNotFound());
            }

            var unit = course.FindUnitById(unitId);

            if (unit == null)
            {
                return(HttpNotFound());
            }

            var slides              = unit.Slides;
            var exercises           = slides.OfType <ExerciseSlide>().ToList();
            var acceptedSubmissions = userSolutionsRepo
                                      .GetAllAcceptedSubmissionsByUser(courseId, exercises.Select(s => s.Id), userId)
                                      .OrderByDescending(s => s.Timestamp)
                                      .DistinctBy(u => u.SlideId)
                                      .ToList();
            var reviewedSubmissions = userSolutionsRepo
                                      .GetAllAcceptedSubmissionsByUser(courseId, exercises.Select(s => s.Id), userId)
                                      .Where(s => s.ManualCheckings.Any(c => c.IsChecked))
                                      .OrderByDescending(s => s.Timestamp)
                                      .DistinctBy(u => u.SlideId)
                                      .ToList();
            var userScores = visitsRepo.GetScoresForSlides(courseId, userId, slides.Select(s => s.Id));

            var unitIndex    = course.Units.FindIndex(u => u.Id == unitId);
            var previousUnit = unitIndex == 0 ? null : course.Units[unitIndex - 1];
            var nextUnit     = unitIndex == course.Units.Count - 1 ? null : course.Units[unitIndex + 1];

            var model = new UserUnitStatisticsPageModel
            {
                Course              = course,
                Unit                = unit,
                User                = user,
                Slides              = slides.ToDictionary(s => s.Id),
                Submissions         = acceptedSubmissions,
                ReviewedSubmissions = reviewedSubmissions,
                Scores              = userScores,
                PreviousUnit        = previousUnit,
                NextUnit            = nextUnit,
            };

            return(View(model));
        }