Exemplo n.º 1
0
        public static ExerciseAutomaticCheckingResponse Build([NotNull] AutomaticExerciseChecking checking,
                                                              [CanBeNull] List <ReviewInfo> botReviews, bool showCheckerLogs)
        {
            var result = new ExerciseAutomaticCheckingResponse
            {
                ProcessStatus = AutomaticExerciseCheckingProcessStatus.ServerError,
                Result        = AutomaticExerciseCheckingResult.NotChecked
            };

            result.ProcessStatus = GetProcessStatus(checking);
            result.Output        = checking.Output?.Text;
            result.CheckerLogs   = showCheckerLogs ? checking.DebugLogs?.Text : null;
            if (result.ProcessStatus != AutomaticExerciseCheckingProcessStatus.Done)
            {
                if (result.Output == null)
                {
                    if (result.ProcessStatus == AutomaticExerciseCheckingProcessStatus.WaitingTimeLimitExceeded)
                    {
                        result.Output ??= "К сожалению, мы не смогли проверить ваше решение. Попробуйте отправить его снова";
                    }
                    else if (result.ProcessStatus == AutomaticExerciseCheckingProcessStatus.Running)
                    {
                        result.Output ??= "Ваше решение уже проверяется";
                    }
                    else if (result.ProcessStatus == AutomaticExerciseCheckingProcessStatus.Waiting)
                    {
                        result.Output ??= "Решение ждет своей очереди на проверку, мы будем пытаться проверить его еще 10 минут";
                    }
                }
                return(result);
            }
            if (checking.IsCompilationError)
            {
                result.Result = AutomaticExerciseCheckingResult.CompilationError;
                result.Output = checking.CompilationError?.Text;
                return(result);
            }
            result.Result = checking.IsRightAnswer ? AutomaticExerciseCheckingResult.RightAnswer : AutomaticExerciseCheckingResult.WrongAnswer;
            if (checking.IsRightAnswer)
            {
                result.Reviews = botReviews;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static SubmissionInfo Build(UserExerciseSubmission submission,
                                           [CanBeNull] Dictionary <int, IEnumerable <ExerciseCodeReviewComment> > reviewId2Comments, bool showCheckerLogs)
        {
            var botReviews = submission.NotDeletedReviews
                             .Select(r => ToReviewInfo(r, true, reviewId2Comments))
                             .ToList();
            var manualCheckingReviews = submission.ManualCheckings
                                        .SelectMany(c => c.NotDeletedReviews)
                                        .Select(r => ToReviewInfo(r, false, reviewId2Comments))
                                        .ToList();
            var automaticChecking = submission.AutomaticChecking == null
                                ? null : ExerciseAutomaticCheckingResponse.Build(submission.AutomaticChecking, botReviews, showCheckerLogs);

            return(new SubmissionInfo
            {
                Id = submission.Id,
                Code = submission.SolutionCode.Text,
                Language = submission.Language,
                Timestamp = submission.Timestamp,
                AutomaticChecking = automaticChecking,
                ManualCheckingPassed = submission.ManualCheckings.Any(mc => mc.IsChecked),
                ManualCheckingReviews = manualCheckingReviews.Where(r => r.Author != null).ToList()
            });
        }