Skip to content

Commit

Permalink
Merge pull request #99 from tossy310/domjudge-reactive-submit
Browse files Browse the repository at this point in the history
Support packing DOMjudge reactive judge
  • Loading branch information
not522 authored Sep 8, 2024
2 parents c6882ad + 45a2b7b commit 1194c9d
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions rime/plugins/judge_system/domjudge.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,24 +297,44 @@ def Pack(self, ui, testset):
ui.errors.Exception(testset)
yield False

if len(testset.judges) > 1:
has_reactive = False
has_custom_judge = False

if testset.reactives:
if len(testset.reactives) != 1:
ui.errors.Error(
testset,
'Multiple reactive runners is not supported in DOMJudge.')
yield False
if not isinstance(testset.reactives[0].variant,
DOMJudgeReactiveRunner):
ui.errors.Error(
testset, 'Only domjudge_reactive_runner is supported.')
yield False
has_reactive = True
elif len(testset.judges) > 1:
ui.errors.Error(
testset, 'Multiple varidators is not supported in DOMJudge.')
yield False
elif (len(testset.judges) == 1 and
not isinstance(testset.judges[0], basic_codes.InternalDiffCode
)):
judge = testset.judges[0]

# TODO(tossy310): support DOMJudgeReactiveRunner
if not isinstance(judge.variant, DOMJudgeJudgeRunner):
if not isinstance(testset.judges[0].variant, DOMJudgeJudgeRunner):
ui.errors.Error(
testset,
'Only domjudge_judge_runner is supported.')
yield False
has_custom_judge = True

if has_reactive or has_custom_judge:
if has_reactive:
judge = testset.reactives[0]
elif has_custom_judge:
judge = testset.judges[0]

validator_dir = os.path.join(
pack_files_dir, 'output_validators',
testset.problem.name + '_' +
os.path.splitext(judge.src_name)[0])
files.MakeDir(validator_dir)
ui.console.PrintAction(
Expand All @@ -334,7 +354,10 @@ def Pack(self, ui, testset):
# TODO: add more data to problem.yaml?
yaml_file = os.path.join(pack_files_dir, 'problem.yaml')
with open(yaml_file, 'w') as f:
f.write('validation: custom\n')
if has_custom_judge:
f.write('validation: custom\n')
elif has_reactive:
f.write('validation: custom interactive\n')

if (testset.problem.domjudge_config_defined and
testset.problem.domjudge_problem_file):
Expand Down

0 comments on commit 1194c9d

Please sign in to comment.