Пример #1
0
        private async Task <List <ExerciseCodeReview> > CreateStyleErrorsReviewsForSubmission(int?submissionId, List <SolutionStyleError> styleErrors, string exerciseMetricId)
        {
            var ulearnBotUserId = await usersRepo.GetUlearnBotUserId();

            var result = new List <ExerciseCodeReview>();

            foreach (var error in styleErrors)
            {
                if (!await styleErrorsRepo.IsStyleErrorEnabled(error.ErrorType))
                {
                    continue;
                }

                var review = await slideCheckingsRepo.AddExerciseCodeReview(
                    submissionId,
                    ulearnBotUserId,
                    error.Span.StartLinePosition.Line,
                    error.Span.StartLinePosition.Character,
                    error.Span.EndLinePosition.Line,
                    error.Span.EndLinePosition.Character,
                    error.Message
                    );

                result.Add(review);

                var errorName = Enum.GetName(typeof(StyleErrorType), error.ErrorType);
                metricSender.SendCount("exercise.style_error");
                metricSender.SendCount($"exercise.style_error.{errorName}");
                metricSender.SendCount($"exercise.{exerciseMetricId}.style_error");
                metricSender.SendCount($"exercise.{exerciseMetricId}.style_error.{errorName}");
            }
            return(result);
        }
Пример #2
0
        public async Task <List <ExerciseCodeReview> > CreateStyleErrorsReviewsForSubmission(int?submissionId, List <StyleError> styleErrors, string exerciseMetricId)
        {
            if (ulearnBotUserId == null)
            {
                ulearnBotUserId = await usersRepo.GetUlearnBotUserId();
            }

            metricSender.SendCount($"exercise.{exerciseMetricId}.StyleViolation");

            var result = new List <ExerciseCodeReview>();

            foreach (var error in styleErrors)
            {
                var review = await slideCheckingsRepo.AddExerciseCodeReview(
                    submissionId,
                    ulearnBotUserId,
                    error.Span.StartLinePosition.Line,
                    error.Span.StartLinePosition.Character,
                    error.Span.EndLinePosition.Line,
                    error.Span.EndLinePosition.Character,
                    error.Message
                    );

                result.Add(review);

                var errorName = error.ErrorType;
                metricSender.SendCount("exercise.style_error");
                metricSender.SendCount($"exercise.style_error.{errorName}");
                metricSender.SendCount($"exercise.{exerciseMetricId}.style_error");
                metricSender.SendCount($"exercise.{exerciseMetricId}.style_error.{errorName}");
            }
            return(result);
        }
Пример #3
0
        public async Task ProcessResult(UserExerciseSubmission submission, RunningResults result)
        {
            if (result.StyleErrors == null || result.StyleErrors.Count == 0)
            {
                return;
            }

            if (result.Verdict != Verdict.Ok)
            {
                return;
            }

            var checking = submission.AutomaticChecking;

            if (!checking.IsRightAnswer)
            {
                return;
            }

            var exerciseSlide = (await courseManager.FindCourseAsync(submission.CourseId))
                                ?.FindSlideById(submission.SlideId, true) as ExerciseSlide;

            if (exerciseSlide == null)
            {
                return;
            }

            if (ulearnBotUserId == null)
            {
                ulearnBotUserId = await usersRepo.GetUlearnBotUserId();
            }

            var exerciseMetricId = ExerciseController.GetExerciseMetricId(submission.CourseId, exerciseSlide);

            metricSender.SendCount($"exercise.{exerciseMetricId}.StyleViolation");

            foreach (var error in result.StyleErrors)
            {
                await slideCheckingsRepo.AddExerciseCodeReview(
                    submission.Id,
                    ulearnBotUserId,
                    error.Span.StartLinePosition.Line,
                    error.Span.StartLinePosition.Character,
                    error.Span.EndLinePosition.Line,
                    error.Span.EndLinePosition.Character,
                    error.Message
                    );

                var errorName = error.ErrorType;
                metricSender.SendCount("exercise.style_error");
                metricSender.SendCount($"exercise.style_error.{errorName}");
                metricSender.SendCount($"exercise.{exerciseMetricId}.style_error");
                metricSender.SendCount($"exercise.{exerciseMetricId}.style_error.{errorName}");
            }
        }