|
9 | 9 | from http.server import HTTPServer |
10 | 10 | from itertools import chain |
11 | 11 |
|
12 | | -from dmoj import graders, packet |
| 12 | +from dmoj import packet |
13 | 13 | from dmoj.control import JudgeControlRequestHandler |
14 | 14 | from dmoj.error import CompileError |
15 | 15 | from dmoj.judgeenv import clear_problem_dirs_cache, env, get_supported_problems, startup_warnings |
@@ -82,17 +82,8 @@ def update_problems(self): |
82 | 82 | self.updater_signal.set() |
83 | 83 |
|
84 | 84 | def _block_and_grade(self, problem, language, source, short_circuit, report=print): |
85 | | - if 'signature_grader' in problem.config: |
86 | | - grader_class = graders.SignatureGrader |
87 | | - elif 'interactive' in problem.config: |
88 | | - grader_class = graders.BridgedInteractiveGrader |
89 | | - elif 'custom_judge' in problem.config: |
90 | | - grader_class = graders.CustomGrader |
91 | | - else: |
92 | | - grader_class = graders.StandardGrader |
93 | | - |
94 | 85 | try: |
95 | | - self.current_grader = grader_class(self, problem, language, utf8bytes(source)) |
| 86 | + self.current_grader = problem.grader_class(self, problem, language, utf8bytes(source)) |
96 | 87 | except CompileError as compilation_error: |
97 | 88 | error = compilation_error.args[0] or b'compiler exited abnormally' |
98 | 89 |
|
@@ -187,25 +178,23 @@ def grade_cases(self, grader, cases, short_circuit=False, is_short_circuiting=Fa |
187 | 178 | if isinstance(case, BatchedTestCase): |
188 | 179 | yield BatchBegin() |
189 | 180 |
|
190 | | - for batched_case in self.grade_cases(grader, case.batched_cases, |
191 | | - short_circuit=case.config['short_circuit'], |
192 | | - is_short_circuiting=is_short_circuiting): |
| 181 | + for batched_result in self.grade_cases(grader, case.batched_cases, |
| 182 | + short_circuit=case.config['short_circuit'], |
| 183 | + is_short_circuiting=is_short_circuiting): |
193 | 184 | # A batched case just failed. |
194 | 185 | # There are two cases where this means that we should completely short-circuit: |
195 | 186 | # 1. If the batch was worth 0 points, to emulate the property of 0-point cases. |
196 | 187 | # 2. If the short_circuit flag is true, see <https://github.com/DMOJ/judge/issues/341>. |
197 | | - if (batched_case.result_flag & Result.WA) and \ |
| 188 | + if (batched_result.result_flag & Result.WA) and \ |
198 | 189 | (short_circuit or case.kind in (TestCase.KIND_SAMPLE, TestCase.KIND_PRETEST)): |
199 | 190 | is_short_circuiting = True |
200 | | - yield batched_case |
| 191 | + yield batched_result |
201 | 192 | yield BatchEnd() |
202 | 193 | continue |
203 | 194 |
|
204 | 195 | # Stop grading if we're short circuiting |
205 | 196 | if is_short_circuiting: |
206 | | - result = Result(case) |
207 | | - result.result_flag = Result.SC |
208 | | - yield result |
| 197 | + yield Result(case, Result.SC) |
209 | 198 | continue |
210 | 199 |
|
211 | 200 | result = grader.grade(case) |
|
0 commit comments