Skip to content

Commit b4885d2

Browse files
committed
Add option for ondemand mode to do a full judging in 1 buttonpress
Normally we would need 2 button presses, 1 to start judging and the other after the `lazy` eval finished to go further. In case we shadow onDemand we are probably more interested in full submissions as you want to see the behaviour on all testcases. In case of an analyst they would probably also want to know how far off a participant is.
1 parent 5d04d16 commit b4885d2

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

Diff for: webapp/src/Controller/Jury/SubmissionController.php

+18
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,15 @@ public function viewAction(
494494
->getSingleScalarResult();
495495
}
496496

497+
$evalOnDemand = false;
498+
$problemLazyEvalResults = $submission->getContestProblem()->getLazyEvalResults();
499+
if (((int)$problemLazyEvalResults === (int)DOMJudgeService::EVAL_DEFAULT
500+
&& (int)$this->config->get('lazy_eval_results') === (int)DOMJudgeService::EVAL_DEMAND)
501+
|| (int)$problemLazyEvalResults === (int)DOMJudgeService::EVAL_DEMAND
502+
) {
503+
$evalOnDemand = true;
504+
}
505+
497506
$twigData = [
498507
'submission' => $submission,
499508
'lastSubmission' => $lastSubmission,
@@ -515,6 +524,7 @@ public function viewAction(
515524
'combinedRunCompare' => $submission->getProblem()->getCombinedRunCompare(),
516525
'requestedOutputCount' => $requestedOutputCount,
517526
'version_warnings' => [],
527+
'evalOnDemand' => $evalOnDemand,
518528
];
519529

520530
if ($selectedJudging === null) {
@@ -1203,6 +1213,14 @@ public function createJudgeTasks(string $submitId): RedirectResponse
12031213
return $this->redirectToRoute('jury_submission', ['submitId' => $submitId]);
12041214
}
12051215

1216+
#[Route(path: '/{submitId<\d+>}/create-tasks-full', name: 'jury_submission_create_tasks_full')]
1217+
public function createJudgeTasksFull(string $submitId): RedirectResponse
1218+
{
1219+
$this->dj->unblockJudgeTasksForSubmission($submitId, true);
1220+
$this->addFlash('info', "Started judging all testcases for submission: $submitId");
1221+
return $this->redirectToRoute('jury_submission', ['submitId' => $submitId]);
1222+
}
1223+
12061224
/**
12071225
* @param string[] $allErrors
12081226
*/

Diff for: webapp/src/Service/DOMJudgeService.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ public function unblockJudgeTasksForProblem(int $probId): void
11261126
}
11271127
}
11281128

1129-
public function unblockJudgeTasksForSubmission(string $submissionId): void
1129+
public function unblockJudgeTasksForSubmission(string $submissionId, bool $judgeCompletely = false): void
11301130
{
11311131
// These are all the judgings that don't have associated judgetasks yet. Check whether we unblocked them.
11321132
$judgings = $this->helperUnblockJudgeTasks()
@@ -1136,7 +1136,7 @@ public function unblockJudgeTasksForSubmission(string $submissionId): void
11361136
->getQuery()
11371137
->getResult();
11381138
foreach ($judgings as $judging) {
1139-
$this->maybeCreateJudgeTasks($judging, JudgeTask::PRIORITY_DEFAULT, true);
1139+
$this->maybeCreateJudgeTasks($judging, JudgeTask::PRIORITY_DEFAULT, true, judgeCompletely: $judgeCompletely);
11401140
}
11411141
}
11421142

@@ -1151,7 +1151,7 @@ public function unblockJudgeTasks(): void
11511151
}
11521152
}
11531153

1154-
public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTask::PRIORITY_DEFAULT, bool $manualRequest = false): void
1154+
public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTask::PRIORITY_DEFAULT, bool $manualRequest = false, bool $judgeCompletely = false): void
11551155
{
11561156
$submission = $judging->getSubmission();
11571157
$problem = $submission->getContestProblem();
@@ -1181,6 +1181,10 @@ public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTas
11811181
return;
11821182
}
11831183

1184+
if ($judgeCompletely) {
1185+
$judging->setJudgeCompletely(true);
1186+
}
1187+
11841188
// We use a mass insert query, since that is way faster than doing a separate insert for each testcase.
11851189
// We first insert judgetasks, then select their ID's and finally insert the judging runs.
11861190

Diff for: webapp/templates/jury/submission.html.twig

+10-1
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,19 @@
395395
&nbsp;
396396
{% if selectedJudging is null or selectedJudging.result is empty %}
397397
{%- if not selectedJudging or not selectedJudging.started %}
398+
{% if evalOnDemand %}
399+
<a href="{{ path('jury_submission_create_tasks_full', {'submitId': submission.submitid}) }}">
400+
<button class="btn btn-sm btn-outline-secondary" >
401+
<i class="fas fa-gavel"></i>
402+
Judge submission (all testcases)
403+
</button>
404+
</a>
405+
&nbsp;
406+
{% endif %}
398407
<a href="{{ path('jury_submission_create_tasks', {'submitId': submission.submitid}) }}">
399408
<button class="btn btn-sm btn-outline-secondary" >
400409
<i class="fas fa-gavel"></i>
401-
Judge submission
410+
Judge submission {% if evalOnDemand %}(lazy){% endif %}
402411
</button>
403412
</a>
404413
{%- endif %}

0 commit comments

Comments
 (0)