Skip to content

Commit 754779b

Browse files
committed
Create verdict groups that selectively can be used
Instead of manually adding various verdicts to the list in different places. This is not completely equivalent to before, but the changes should be fine. The original behaviour of calling `getVerdicts` without arguments is unchanged and `getVerdicts(mergeExternal: true)` maps to `getVerdicts(['final', 'external'])`.
1 parent 34b1849 commit 754779b

9 files changed

+38
-31
lines changed

etc/verdicts.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@
44
// CCS specification (and a few more common ones) at:
55
// https://ccs-specs.icpc.io/2021-11/ccs_system_requirements#judge-responses
66
return [
7-
'compiler-error' => 'CE',
8-
'memory-limit' => 'MLE',
9-
'output-limit' => 'OLE',
10-
'run-error' => 'RTE',
11-
'timelimit' => 'TLE',
12-
'wrong-answer' => 'WA',
13-
'no-output' => 'NO',
14-
'correct' => 'AC',
7+
'final' => [
8+
'compiler-error' => 'CE',
9+
'memory-limit' => 'MLE',
10+
'output-limit' => 'OLE',
11+
'run-error' => 'RTE',
12+
'timelimit' => 'TLE',
13+
'wrong-answer' => 'WA',
14+
'no-output' => 'NO',
15+
'correct' => 'AC',
16+
],
17+
'error' => [
18+
'aborted' => 'JE',
19+
'import-error' => 'IE',
20+
],
21+
'in_progress' => [
22+
'judging' => 'JU',
23+
'pending' => 'JU',
24+
'queued' => 'JU',
25+
],
26+
// The 'external' group is defined in configuration.
1527
];

webapp/src/Controller/API/JudgementController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ public function __construct(
4444
) {
4545
parent::__construct($entityManager, $DOMJudgeService, $config, $eventLogService);
4646

47-
$verdicts = $this->dj->getVerdicts();
48-
$verdicts['aborted'] = 'JE'; /* happens for aborted judgings */
49-
$this->verdicts = $verdicts;
47+
$this->verdicts = $this->dj->getVerdicts(['final', 'error']);
5048
}
5149

5250
/**

webapp/src/Controller/API/JudgementTypeController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function singleAction(Request $request, string $id): JudgementType
8585
*/
8686
protected function getJudgementTypes(?array $filteredOn = null): array
8787
{
88-
$verdicts = $this->dj->getVerdicts(mergeExternal: true);
88+
$verdicts = $this->dj->getVerdicts(['final', 'external']);
8989

9090
$result = [];
9191
foreach ($verdicts as $name => $label) {

webapp/src/Controller/Jury/RejudgingController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,8 @@ public function viewAction(
241241
}
242242
$todo = $this->rejudgingService->calculateTodo($rejudging)['todo'];
243243

244-
$verdicts = $this->dj->getVerdicts();
244+
$verdicts = $this->dj->getVerdicts(['final', 'error']);
245245
$verdicts[''] = 'JE'; /* happens for aborted judgings */
246-
$verdicts['aborted'] = 'JE'; /* happens for aborted judgings */
247246

248247
$used = [];
249248
$verdictTable = [];

webapp/src/Controller/Jury/ShadowDifferencesController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ public function indexAction(
8383
$this->requestStack->getSession()->save();
8484

8585
$contest = $this->dj->getCurrentContest();
86-
$verdicts = array_merge(['judging' => 'JU'], $this->dj->getVerdicts(mergeExternal: true));
87-
88-
$verdicts['import-error'] = 'IE';
86+
$verdicts = $this->dj->getVerdicts(['final', 'error', 'external', 'in_progress']);
8987

9088
$used = [];
9189
$verdictTable = [];

webapp/src/Controller/Jury/SubmissionController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ public function indexAction(
138138
// Load preselected filters
139139
$filters = $this->dj->jsonDecode((string)$this->dj->getCookie('domjudge_submissionsfilter') ?: '[]');
140140

141-
$results = array_keys($this->dj->getVerdicts());
142-
$results[] = 'judging';
143-
$results[] = 'queued';
141+
$results = array_keys($this->dj->getVerdicts(['final', 'in_progress']));
144142

145143
$data = [
146144
'refresh' => $refresh,

webapp/src/Form/Type/SubmissionsFilterType.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
115115
"attr" => ["data-filter-field" => "team-id"],
116116
]);
117117

118-
$verdicts = array_keys($this->dj->getVerdicts());
119-
$verdicts[] = "judging";
120-
$verdicts[] = "queued";
121-
$verdicts[] = "import-error";
118+
$verdicts = array_keys($this->dj->getVerdicts(['final', 'error', 'in_progress']));
122119
$builder->add("result", ChoiceType::class, [
123120
"label" => "Filter on result(s)",
124121
"multiple" => true,

webapp/src/Service/DOMJudgeService.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,14 +1485,19 @@ public function getCompileConfig(Submission $submission): string
14851485
/**
14861486
* @return array<string, string>
14871487
*/
1488-
public function getVerdicts(bool $mergeExternal = false): array
1488+
public function getVerdicts(array $groups = ['final']): array
14891489
{
14901490
$verdictsConfig = $this->getDomjudgeEtcDir() . '/verdicts.php';
1491-
$verdicts = include $verdictsConfig;
1491+
$verdictGroups = include $verdictsConfig;
14921492

1493-
if ($mergeExternal) {
1494-
foreach ($this->config->get('external_judgement_types') as $id => $name) {
1495-
$verdicts[$name] = $id;
1493+
$verdicts = [];
1494+
foreach( $groups as $group ) {
1495+
if ( $group === 'external' ) {
1496+
foreach ($this->config->get('external_judgement_types') as $id => $name) {
1497+
$verdicts[$name] = $id;
1498+
}
1499+
} else {
1500+
$verdicts = array_merge($verdicts, $verdictGroups[$group]);
14961501
}
14971502
}
14981503

webapp/src/Service/ExternalContestSourceService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function getLastReadEventId(): ?string
269269
public function import(bool $fromStart, array $eventsToSkip, ?callable $progressReporter = null): bool
270270
{
271271
// We need the verdicts to validate judgement-types.
272-
$this->verdicts = $this->dj->getVerdicts(mergeExternal: true);
272+
$this->verdicts = $this->dj->getVerdicts(['final', 'external']);
273273

274274
if (!$this->isValidContestSource()) {
275275
throw new LogicException('The contest source is not valid');
@@ -799,7 +799,7 @@ protected function importJudgementType(Event $event, EventData $data): void
799799
$customVerdicts = $this->config->get('external_judgement_types');
800800
$customVerdicts[$verdict] = str_replace(' ', '-', $data->name);
801801
$this->config->saveChanges(['external_judgement_types' => $customVerdicts], $this->eventLog, $this->dj);
802-
$this->verdicts = $this->dj->getVerdicts(mergeExternal: true);
802+
$this->verdicts = $this->dj->getVerdicts(['final', 'external']);
803803
$penalty = true;
804804
$solved = false;
805805
$this->logger->warning('Judgement type %s not found locally, importing as external verdict', [$verdict]);

0 commit comments

Comments
 (0)