示例#1
0
        private void BeginProcessingSubmission(
            Submission submission,
            SubmissionForProcessing submissionForProcessing,
            IOjsData data,
            ISubmissionsForProcessingDataService submissionsForProccessingData,
            IParticipantScoresDataService participantScoresData)
        {
            submission.ProcessingComment = null;
            try
            {
                data.TestRuns.DeleteBySubmissionId(submission.Id);
                this.ProcessSubmission(submission);
                data.SaveChanges();
            }
            catch (Exception exception)
            {
                this.logger.ErrorFormat("ProcessSubmission on submission №{0} has thrown an exception: {1}", submission.Id, exception);
                submission.ProcessingComment = $"Exception in ProcessSubmission: {exception.Message}";
            }

            try
            {
                this.CalculatePointsForSubmission(submission);
            }
            catch (Exception exception)
            {
                this.logger.ErrorFormat("CalculatePointsForSubmission on submission №{0} has thrown an exception: {1}", submission.Id, exception);
                submission.ProcessingComment = $"Exception in CalculatePointsForSubmission: {exception.Message}";
            }

            submission.Processed = true;
            submissionsForProccessingData.SetToProcessed(submissionForProcessing.Id);

            try
            {
                participantScoresData.SaveBySubmission(submission);
            }
            catch (Exception exception)
            {
                this.logger.ErrorFormat("SaveParticipantScore on submission №{0} has thrown an exception: {1}", submission.Id, exception);
                submission.ProcessingComment = $"Exception in SaveParticipantScore: {exception.Message}";
            }

            try
            {
                submission.CacheTestRuns();
            }
            catch (Exception exception)
            {
                this.logger.ErrorFormat("CacheTestRuns on submission №{0} has thrown an exception: {1}", submission.Id, exception);
                submission.ProcessingComment = $"Exception in CacheTestRuns: {exception.Message}";
            }

            try
            {
                data.SaveChanges();
            }
            catch (Exception exception)
            {
                this.logger.ErrorFormat("Unable to save changes to the submission №{0}! Exception: {1}", submission.Id, exception);
            }

            this.logger.InfoFormat("Submission №{0} successfully processed", submission.Id);
        }
示例#2
0
        public void CacheTestRunsShouldSetValidResult()
        {
            var submission = new Submission
            {
                TestRuns = new List <TestRun>
                {
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = true
                        }, Id = 1, ResultType = TestRunResultType.CorrectAnswer
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = false
                        }, Id = 2, ResultType = TestRunResultType.WrongAnswer
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = false
                        }, Id = 3, ResultType = TestRunResultType.CorrectAnswer
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = true
                        }, Id = 4, ResultType = TestRunResultType.TimeLimit
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = false
                        }, Id = 5, ResultType = TestRunResultType.CorrectAnswer
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = false
                        }, Id = 6, ResultType = TestRunResultType.MemoryLimit
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = false
                        }, Id = 7, ResultType = TestRunResultType.CorrectAnswer
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = true
                        }, Id = 8, ResultType = TestRunResultType.RunTimeError
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = false
                        }, Id = 9, ResultType = TestRunResultType.CorrectAnswer
                    },
                    new TestRun {
                        Test = new Test {
                            IsTrialTest = false
                        }, Id = 10, ResultType = TestRunResultType.WrongAnswer
                    },
                }
            };

            submission.CacheTestRuns();

            Assert.AreEqual("30241003001", submission.TestRunsCache);
        }