コード例 #1
0
        public async Task <ManualExerciseChecking> AddManualExerciseChecking(string courseId, Guid slideId, string userId, UserExerciseSubmission submission)
        {
            var manualChecking = new ManualExerciseChecking
            {
                CourseId  = courseId,
                SlideId   = slideId,
                UserId    = userId,
                Timestamp = DateTime.Now,

                SubmissionId = submission.Id,
            };

            db.ManualExerciseCheckings.Add(manualChecking);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbEntityValidationException e)
            {
                throw new Exception(
                          string.Join("\r\n", e.EntityValidationErrors.Select(v => v.Entry.Entity.ToString())) +
                          string.Join("\r\n",
                                      e.EntityValidationErrors.SelectMany(v => v.ValidationErrors).Select(err => err.PropertyName + " " + err.ErrorMessage)));
            }

            return(manualChecking);
        }
コード例 #2
0
        public async Task <ExerciseCodeReview> AddExerciseCodeReview(ManualExerciseChecking checking, string userId, int startLine, int startPosition, int finishLine, int finishPosition, string comment)
        {
            var review = db.ExerciseCodeReviews.Add(new ExerciseCodeReview
            {
                AuthorId           = userId,
                Comment            = comment,
                ExerciseCheckingId = checking.Id,
                StartLine          = startLine,
                StartPosition      = startPosition,
                FinishLine         = finishLine,
                FinishPosition     = finishPosition,
            });

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbEntityValidationException e)
            {
                throw new Exception(
                          string.Join("\r\n",
                                      e.EntityValidationErrors.SelectMany(v => v.ValidationErrors).Select(err => err.PropertyName + " " + err.ErrorMessage)));
            }

            /* Extract review from database to fill review.Author by EF's DynamicProxy */
            return(db.ExerciseCodeReviews.AsNoTracking().FirstOrDefault(r => r.Id == review.Id));
        }
コード例 #3
0
 public ExerciseScoreFormModel(string courseId, ExerciseSlide slide, ManualExerciseChecking checking, List <string> groupsIds = null, bool isCurrentSubmissionChecking = false)
 {
     CourseId  = courseId;
     Slide     = slide;
     Checking  = checking;
     GroupsIds = groupsIds;
     IsCurrentSubmissionChecking = isCurrentSubmissionChecking;
 }
コード例 #4
0
 private async Task NotifyAboutManualExerciseChecking(ManualExerciseChecking checking)
 {
     var isRecheck    = notificationsRepo.FindNotifications <PassedManualExerciseCheckingNotification>(n => n.CheckingId == checking.Id).Any();
     var notification = new PassedManualExerciseCheckingNotification
     {
         Checking  = checking,
         IsRecheck = isRecheck,
     };
     await notificationsRepo.AddNotification(checking.CourseId, notification, User.Identity.GetUserId());
 }
コード例 #5
0
 public ExerciseScoreFormModel(string courseId, ExerciseSlide slide, ManualExerciseChecking checking, int manualCheckingsLeft, List <string> groupsIds = null,
                               bool isCurrentSubmissionChecking = false, bool defaultProhibitFutherReview = true)
 {
     CourseId                    = courseId;
     Slide                       = slide;
     Checking                    = checking;
     ManualCheckingsLeft         = manualCheckingsLeft;
     GroupsIds                   = groupsIds;
     IsCurrentSubmissionChecking = isCurrentSubmissionChecking;
     DefaultProhibitFutherReview = defaultProhibitFutherReview;
 }
コード例 #6
0
        public async Task <ManualExerciseChecking> AddManualExerciseChecking(string courseId, Guid slideId, string userId, UserExerciseSubmission submission)
        {
            var manualChecking = new ManualExerciseChecking
            {
                CourseId     = courseId,
                SlideId      = slideId,
                UserId       = userId,
                Timestamp    = DateTime.Now,
                SubmissionId = submission.Id,
            };

            db.ManualExerciseCheckings.Add(manualChecking);

            await db.SaveChangesAsync().ConfigureAwait(false);

            return(manualChecking);
        }
コード例 #7
0
 public Task <ExerciseCodeReview> AddExerciseCodeReview(ManualExerciseChecking checking, string userId, int startLine, int startPosition, int finishLine, int finishPosition, string comment, bool setAddingTime = true)
 {
     return(AddExerciseCodeReview(null, checking, userId, startLine, startPosition, finishLine, finishPosition, comment, setAddingTime));
 }
コード例 #8
0
        private async Task <ExerciseCodeReview> AddExerciseCodeReview([CanBeNull] UserExerciseSubmission submission, [CanBeNull] ManualExerciseChecking checking, string userId, int startLine, int startPosition, int finishLine, int finishPosition, string comment, bool setAddingTime)
        {
            var review = db.ExerciseCodeReviews.Add(new ExerciseCodeReview
            {
                AuthorId           = userId,
                Comment            = comment,
                ExerciseCheckingId = checking?.Id,
                SubmissionId       = submission?.Id,
                StartLine          = startLine,
                StartPosition      = startPosition,
                FinishLine         = finishLine,
                FinishPosition     = finishPosition,
                AddingTime         = setAddingTime ? DateTime.Now : ExerciseCodeReview.NullAddingTime,
            });

            await db.SaveChangesAsync().ConfigureAwait(false);

            /* Extract review from database to fill review.Author by EF's DynamicProxy */
            return(db.ExerciseCodeReviews.AsNoTracking().FirstOrDefault(r => r.Id == review.Id));
        }
コード例 #9
0
 public async Task ProhibitFurtherExerciseManualChecking(ManualExerciseChecking checking)
 {
     checking.ProhibitFurtherManualCheckings = true;
     await db.SaveChangesAsync().ConfigureAwait(false);
 }
コード例 #10
0
 public Task ProhibitFurtherExerciseManualChecking(ManualExerciseChecking checking)
 {
     checking.ProhibitFurtherManualCheckings = true;
     return(db.SaveChangesAsync());
 }
コード例 #11
0
        public ActionResult Submission(string courseId, Guid slideId, string userId = null, int?submissionId = null, int?manualCheckingId = null, bool isLti = false, bool showOutput = false, bool instructorView = false, bool onlyAccepted = true)
        {
            if (!User.HasAccessFor(courseId, CourseRole.Instructor))
            {
                instructorView = false;
            }

            var currentUserId = userId ?? (User.Identity.IsAuthenticated ? User.Identity.GetUserId() : "");
            UserExerciseSubmission submission = null;

            if (submissionId.HasValue && submissionId.Value > 0)
            {
                submission = userSolutionsRepo.FindSubmissionById(submissionId.Value);
                if (submission == null)
                {
                    return(HttpNotFound());
                }
                if (!string.Equals(courseId, submission.CourseId, StringComparison.OrdinalIgnoreCase))
                {
                    return(HttpNotFound());
                }
                if (slideId != submission.SlideId)
                {
                    return(HttpNotFound());
                }
                if (!User.HasAccessFor(courseId, CourseRole.Instructor) && submission.UserId != currentUserId)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
                }
            }
            else if (!submissionId.HasValue && !manualCheckingId.HasValue)
            {
                submission = GetExerciseSubmissionShownByDefault(courseId, slideId, currentUserId, instructorView);
            }

            var course = courseManager.GetCourse(courseId);
            var slide  = course.FindSlideById(slideId);

            if (slide == null)
            {
                return(HttpNotFound());
            }

            ManualExerciseChecking manualChecking = null;

            if (User.HasAccessFor(courseId, CourseRole.Instructor) && manualCheckingId.HasValue)
            {
                manualChecking = slideCheckingsRepo.FindManualCheckingById <ManualExerciseChecking>(manualCheckingId.Value);
            }
            if (manualChecking != null && !submissionId.HasValue)
            {
                submission = manualChecking.Submission;
            }

            var model = CreateExerciseBlockData(course, slide, submission, onlyAccepted, currentUserId);

            model.IsLti = isLti;
            model.ShowOutputImmediately = showOutput;
            model.InstructorView        = instructorView;
            model.ShowOnlyAccepted      = onlyAccepted;
            if (manualChecking != null)
            {
                if (manualChecking.CourseId.EqualsIgnoreCase(courseId))
                {
                    model.ManualChecking = manualChecking;
                    model.Reviews        = submission?.GetAllReviews() ?? new List <ExerciseCodeReview>();
                }
            }

            return(PartialView(model));
        }