Exemplo n.º 1
0
        private string ReplaceQuizzesBuiltinParameters(string content, Certificate certificate, Course course)
        {
            var passedQuizzesCount        = userQuizzesRepo.GetIdOfQuizPassedSlides(course.Id, certificate.UserId).Count;
            var scoredMaximumQuizzesCount = userQuizzesRepo.GetIdOfQuizSlidesScoredMaximum(course.Id, certificate.UserId).Count;

            content = SubstituteOneParameter(content, "quizzes.passed", passedQuizzesCount.ToString());
            content = SubstituteOneParameter(content, "quizzes.passed_maxscore", scoredMaximumQuizzesCount.ToString());
            return(content);
        }
Exemplo n.º 2
0
        private async Task AddManualCheckingsForOldSolutions(string courseId, string userId)
        {
            log.Info($"Создаю ручные проверки для всех решения пользователя {userId} в курсе {courseId}");

            var course = courseManager.GetCourse(courseId);

            /* For exercises */
            var acceptedSubmissionsBySlide = userSolutionsRepo.GetAllAcceptedSubmissionsByUser(courseId, userId)
                                             .GroupBy(s => s.SlideId)
                                             .ToDictionary(g => g.Key, g => g.ToList());

            foreach (var acceptedSubmissionsForSlide in acceptedSubmissionsBySlide.Values)
            {
                /* If exists at least one manual checking for at least one submissions on slide, then ignore this slide */
                if (!acceptedSubmissionsForSlide.Any(s => s.ManualCheckings.Any()))
                {
                    /* Otherwise found the latest accepted submission */
                    var lastSubmission = acceptedSubmissionsForSlide.OrderByDescending(s => s.Timestamp).First();

                    var slideId = lastSubmission.SlideId;
                    var slide   = course.FindSlideById(slideId) as ExerciseSlide;
                    if (slide == null || !slide.Exercise.RequireReview)
                    {
                        continue;
                    }

                    log.Info($"Создаю ручную проверку для решения {lastSubmission.Id}, слайд {slideId}");
                    await slideCheckingsRepo.AddManualExerciseChecking(courseId, slideId, userId, lastSubmission);

                    await visitsRepo.MarkVisitsAsWithManualChecking(slideId, userId);
                }
            }

            /* For quizzes */
            var passedQuizzesIds = userQuizzesRepo.GetIdOfQuizPassedSlides(courseId, userId);

            foreach (var quizSlideId in passedQuizzesIds)
            {
                var slide = course.FindSlideById(quizSlideId) as QuizSlide;
                if (slide == null || !slide.ManualChecking)
                {
                    continue;
                }
                if (!userQuizzesRepo.IsWaitingForManualCheck(courseId, quizSlideId, userId))
                {
                    log.Info($"Создаю ручную проверку для теста {slide.Id}");
                    await slideCheckingsRepo.AddQuizAttemptForManualChecking(courseId, quizSlideId, userId);

                    await visitsRepo.MarkVisitsAsWithManualChecking(quizSlideId, userId);
                }
            }
        }