Пример #1
0
 public void GradeSubmission(string problemName, string userName)
 {
     if (!problemModel.Contains(problemName))
     {
         throw new JudgeProblemNotFoundExpcetion(problemName);
     }
     if (!userModel.Contains(userName))
     {
         throw new JudgeUserNotFoundException(userName);
     }
     Totaltestcases = TestcasesGraded = 0;
     Totaltestcases = problemModel[problemName].Testcases.Count;
     problemName    = problemModel[problemName].ProblemName;
     userName       = userModel[userName].UserName; //exactly name
     if (IsGrading)
     {
         throw new JudgeIsGradingException();
     }
     new Thread(new ThreadStart(() =>
     {
         IsGrading         = true;
         double totalScore = GradeOneSubmission(problemName, userName, out JudgeUpdateScoreType status);
         if (IsGrading)
         {
             OnUpdateScore?.Invoke(this, new JudgeUpdateScoreSubmissionEvent()
             {
                 Points      = totalScore,
                 ProblemName = problemName,
                 UserName    = userName,
                 Status      = status
             });
         }
         IsGrading = false;
         OnGradeStatusChanged?.Invoke(this, new JudgeGradingEvent()
         {
             Event = JudgeGradingEventType.Complete
         });
     })).Start();
 }