Example #1
0
        private int GetManualCheckingsCountInQueue(string courseId, Slide slide, List <string> groupsIds)
        {
            var filterOptions = GetManualCheckingFilterOptionsByGroup(courseId, groupsIds);

            if (filterOptions.UserIds == null)
            {
                groupsIds = new List <string> {
                    "all"
                }
            }
            ;
            filterOptions.SlidesIds = new List <Guid> {
                slide.Id
            };

            if (slide is ExerciseSlide)
            {
                return(slideCheckingsRepo.GetManualCheckingQueue <ManualExerciseChecking>(filterOptions).Count());
            }
            if (slide is QuizSlide)
            {
                return(slideCheckingsRepo.GetManualCheckingQueue <ManualQuizChecking>(filterOptions).Count());
            }

            throw new ArgumentException("Slide should be quiz or exercise", nameof(slide));
        }
Example #2
0
        public ActionResult Analytics(string courseId, Guid slideId, DateTime periodStart)
        {
            var course    = courseManager.GetCourse(courseId);
            var unit      = course.FindUnitBySlideId(slideId);
            var quizSlide = (QuizSlide)course.GetSlideById(slideId);

            var quizVersions = quizzesRepo.GetQuizVersions(courseId, quizSlide.Id).ToList();
            var dict         = new SortedDictionary <string, List <QuizAnswerInfo> >();
            var passes       = db.UserQuizzes
                               .Where(q => quizSlide.Id == q.SlideId && !q.isDropped && periodStart <= q.Timestamp)
                               .GroupBy(q => q.UserId)
                               .Join(db.Users, g => g.Key, user => user.Id, (g, user) => new { UserId = user.Id, user.UserName, UserQuizzes = g.ToList(), QuizVersion = g.FirstOrDefault().QuizVersion })
                               .ToList();

            foreach (var pass in passes)
            {
                var slide = quizSlide;
                if (pass.QuizVersion != null)
                {
                    slide = new QuizSlide(quizSlide.Info, pass.QuizVersion.GetRestoredQuiz(course, unit));
                }
                dict[pass.UserName] = GetUserQuizAnswers(slide, pass.UserQuizzes).ToList();
            }

            var userIds           = passes.Select(p => p.UserId).Distinct().ToList();
            var userNameById      = passes.ToDictionary(p => p.UserId, p => p.UserName);
            var groups            = groupsRepo.GetUsersGroupsNamesAsStrings(courseId, userIds, User).ToDictionary(kv => userNameById[kv.Key], kv => kv.Value);
            var rightAnswersCount = dict.Values
                                    .SelectMany(list => list
                                                .Where(info => info.Score == info.MaxScore))
                                    .GroupBy(arg => arg.Id)
                                    .ToDictionary(grouping => grouping.Key, grouping => grouping.Count());

            var usersByQuizVersion       = passes.GroupBy(p => p.QuizVersion?.Id).ToDictionary(g => g.Key, g => g.Select(u => u.UserName).ToList());
            var usersWaitsForManualCheck = slideCheckingsRepo.GetManualCheckingQueue <ManualQuizChecking>(
                new ManualCheckingQueueFilterOptions {
                CourseId = courseId, SlidesIds = new List <Guid> {
                    quizSlide.Id
                }
            }
                ).ToList().Select(i => i.User.UserName).ToImmutableHashSet();

            return(PartialView(new QuizAnalyticsModel
            {
                Course = course,
                Unit = course.FindUnitBySlideId(quizSlide.Id),
                SlideId = quizSlide.Id,

                UserAnswers = dict,
                QuizVersions = quizVersions,
                UsersByQuizVersion = usersByQuizVersion,
                RightAnswersCount = rightAnswersCount,
                GroupByUser = groups,
                UsersWaitsForManualCheck = usersWaitsForManualCheck,
            }));
        }
Example #3
0
        public static int GetManualCheckingsCountInQueue(SlideCheckingsRepo slideCheckingsRepo, GroupsRepo groupsRepo, IPrincipal user,
                                                         string courseId, Slide slide, List <string> groupsIds)
        {
            var filterOptions = GetFilterOptionsByGroup <ManualCheckingQueueFilterOptions>(groupsRepo, user, courseId, groupsIds);

            filterOptions.SlidesIds = new List <Guid> {
                slide.Id
            };

            if (slide is ExerciseSlide)
            {
                return(slideCheckingsRepo.GetManualCheckingQueue <ManualExerciseChecking>(filterOptions).Count());
            }
            if (slide is QuizSlide)
            {
                return(slideCheckingsRepo.GetManualCheckingQueue <ManualQuizChecking>(filterOptions).Count());
            }

            throw new ArgumentException("Slide should be quiz or exercise", nameof(slide));
        }
Example #4
0
        private int GetManualCheckingCount(string courseId, string userId, Guid slideId, UserQuizSubmission beforeSubmissions = null)
        {
            var queue = slideCheckingsRepo.GetManualCheckingQueue <ManualQuizChecking>(new ManualCheckingQueueFilterOptions
            {
                CourseId  = courseId,
                SlidesIds = new[] { slideId },
                UserIds   = new List <string> {
                    userId
                },
                OnlyChecked = null,                 // For calculating not checked submissions as well as checked ones
            }).ToList();

            if (beforeSubmissions != null)
            {
                queue = queue.Where(s => s.Timestamp < beforeSubmissions.Timestamp).ToList();
            }

            return(queue.Count());
        }