Esempio n. 1
0
        private async Task <CoursePageModel> CreateCoursePageModel(
            Course course, Slide slide,
            AbstractManualSlideChecking manualChecking, int?exerciseSubmissionId = null,
            List <string> groupsIds       = null,
            bool autoplay                 = false,
            bool isManualCheckingReadonly = false)
        {
            var userId = User.Identity.GetUserId();

            if (manualChecking != null)
            {
                userId = manualChecking.UserId;
            }

            var visiter = await VisitSlide(course.Id, slide.Id, userId).ConfigureAwait(false);

            var maxSlideScore = GetMaxSlideScoreForUser(course, slide, userId);
            var defaultProhibitFurtherReview = groupsRepo.GetDefaultProhibitFutherReviewForUser(course.Id, userId, User);
            var manualCheckingsLeft          = manualChecking != null?ControllerUtils.GetManualCheckingsCountInQueue(slideCheckingsRepo, groupsRepo, User, course.Id, slide, groupsIds) : 0;

            var score = Tuple.Create(visiter.Score, maxSlideScore);
            var model = new CoursePageModel
            {
                UserId             = userId,
                CourseId           = course.Id,
                CourseTitle        = course.Title,
                Slide              = slide,
                Score              = score,
                BlockRenderContext = CreateRenderContext(
                    course, slide, manualChecking, exerciseSubmissionId, groupsIds,
                    autoplay: autoplay,
                    isManualCheckingReadonly: isManualCheckingReadonly,
                    defaultProhibitFurtherReview: defaultProhibitFurtherReview, manualCheckingsLeft: manualCheckingsLeft),
                ManualChecking = manualChecking,
                ContextManualCheckingUserGroups = manualChecking != null?groupsRepo.GetUserGroupsNamesAsString(course.Id, manualChecking.UserId, User) : "",
                                                      ContextManualCheckingUserArchivedGroups = manualChecking != null?groupsRepo.GetUserGroupsNamesAsString(course.Id, manualChecking.UserId, User, onlyArchived : true) : "",
                                                                                                    IsGuest      = false,
                                                                                                    SlideEditUrl = GetGitEditLink(course, slide.Info.SlideFile)
            };

            return(model);
        }
Esempio n. 2
0
        private async Task <CoursePageModel> CreateCoursePageModel(
            Course course, Slide slide,
            AbstractManualSlideChecking manualChecking, int?exerciseSubmissionId = null,
            List <string> groupsIds       = null,
            bool autoplay                 = false,
            bool isManualCheckingReadonly = false)
        {
            var userId = User.Identity.GetUserId();

            if (manualChecking != null)
            {
                userId = manualChecking.UserId;
            }

            var defaultProhibitFurtherReview = groupsRepo.GetDefaultProhibitFutherReviewForUser(course.Id, userId, User);
            var manualCheckingsLeftInQueue   = manualChecking != null?ControllerUtils.GetManualCheckingsCountInQueue(slideCheckingsRepo, groupsRepo, User, course.Id, slide, groupsIds) : 0;

            var(notArchivedGroupNames, archivedGroupNames) = GetGroupNames(course, manualChecking);

            var model = new CoursePageModel
            {
                UserId             = userId,
                CourseId           = course.Id,
                CourseTitle        = course.Title,
                Slide              = slide,
                BlockRenderContext = CreateRenderContext(
                    course, slide, manualChecking, exerciseSubmissionId, groupsIds,
                    autoplay: autoplay,
                    isManualCheckingReadonly: isManualCheckingReadonly,
                    defaultProhibitFurtherReview: defaultProhibitFurtherReview, manualCheckingsLeftInQueue: manualCheckingsLeftInQueue),
                ManualChecking = manualChecking,
                ContextManualCheckingUserGroups         = notArchivedGroupNames,
                ContextManualCheckingUserArchivedGroups = archivedGroupNames,
                IsGuest = false,
            };

            return(model);
        }
Esempio n. 3
0
        private int GetManualCheckingsCountInQueue(ICourse course, QuizSlide slide)
        {
            var groupsIds = Request.GetMultipleValuesFromQueryString("group");

            return(ControllerUtils.GetManualCheckingsCountInQueue(slideCheckingsRepo, groupsRepo, User, course.Id, slide, groupsIds));
        }