コード例 #1
0
        private async Task CreateStyleErrorsReviewsForSubmission(UserExerciseSubmission submission, IEnumerable <SolutionStyleError> styleErrors, string exerciseMetricId)
        {
            var ulearnBotUserId = usersRepo.GetUlearnBotUserId();

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

                await slideCheckingsRepo.AddExerciseCodeReview(
                    submission,
                    ulearnBotUserId,
                    error.Span.StartLinePosition.Line,
                    error.Span.StartLinePosition.Character,
                    error.Span.EndLinePosition.Line,
                    error.Span.EndLinePosition.Character,
                    error.Message
                    );

                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}");
            }
        }
コード例 #2
0
        public async Task <ActionResult> AddExerciseCodeReview(string courseId, int checkingId, [FromBody] ReviewInfo reviewInfo)
        {
            var checking = slideCheckingsRepo.FindManualCheckingById <ManualExerciseChecking>(checkingId);

            if (!string.Equals(checking.CourseId, courseId, StringComparison.OrdinalIgnoreCase))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
            }

            /* Make start position less than finish position */
            if (reviewInfo.StartLine > reviewInfo.FinishLine || (reviewInfo.StartLine == reviewInfo.FinishLine && reviewInfo.StartPosition > reviewInfo.FinishPosition))
            {
                var tmp = reviewInfo.StartLine;
                reviewInfo.StartLine  = reviewInfo.FinishLine;
                reviewInfo.FinishLine = tmp;

                tmp = reviewInfo.StartPosition;
                reviewInfo.StartPosition  = reviewInfo.FinishPosition;
                reviewInfo.FinishPosition = tmp;
            }

            var review = await slideCheckingsRepo.AddExerciseCodeReview(checking, User.Identity.GetUserId(), reviewInfo.StartLine, reviewInfo.StartPosition, reviewInfo.FinishLine, reviewInfo.FinishPosition, reviewInfo.Comment);

            return(PartialView("_ExerciseReview", new ExerciseCodeReviewModel
            {
                Review = review,
                ManualChecking = checking,
            }));
        }