예제 #1
0
        private QuizState GetQuizState(string courseId, string userId, Guid slideId, int userScore, int maxScore, UserQuizSubmission submission = null)
        {
            log.Info($"Ищу статус прохождения теста {courseId}:{slideId} для пользователя {userId}");

            var lastSubmission = userQuizzesRepo.FindLastUserSubmission(courseId, slideId, userId);

            var manualChecking = submission?.ManualChecking ?? lastSubmission?.ManualChecking;

            if (manualChecking != null)
            {
                /* For manually checked quizzes attempts are counting by manual checkings, not by user quiz submissions
                 * (because user can resend quiz before instructor checked and score it) */
                var manualCheckingCount = GetManualCheckingCount(courseId, userId, slideId, submission);

                log.Info($"Статус прохождения теста {courseId}:{slideId} для пользователя {userId}: есть ручная проверка №{manualChecking.Id}, проверяется ли сейчас: {manualChecking.IsLocked}");
                if (manualChecking.IsChecked)
                {
                    return(new QuizState(QuizStatus.ReadyToSend, manualCheckingCount, userScore, maxScore));
                }
                return(new QuizState(manualChecking.IsLocked ? QuizStatus.IsCheckingByInstructor : QuizStatus.WaitsForManualChecking, manualCheckingCount, userScore, maxScore));
            }

            var usedAttemptsCount = userQuizzesRepo.GetUsedAttemptsCount(courseId, userId, slideId);

            return(new QuizState(QuizStatus.ReadyToSend, usedAttemptsCount, userScore, maxScore));
        }