From 3b96dbf9d5c4bbf8666a0d116df51ddd0e1f6daf Mon Sep 17 00:00:00 2001
From: Michael Vasseur <14887731+vmcj@users.noreply.github.com>
Date: Sun, 17 Mar 2024 19:11:47 +0100
Subject: [PATCH] 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.
---
.../Controller/Jury/SubmissionController.php | 17 +++++++++++++++++
webapp/src/Service/DOMJudgeService.php | 10 +++++++---
webapp/templates/jury/submission.html.twig | 11 ++++++++++-
3 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/webapp/src/Controller/Jury/SubmissionController.php b/webapp/src/Controller/Jury/SubmissionController.php
index 590079e06aa..c56818309c5 100644
--- a/webapp/src/Controller/Jury/SubmissionController.php
+++ b/webapp/src/Controller/Jury/SubmissionController.php
@@ -494,6 +494,14 @@ public function viewAction(
->getSingleScalarResult();
}
+ $evalOnDemand = false;
+ if (((int)$submission->getContestProblem()->getLazyEvalResults() === (int)DOMJudgeService::EVAL_DEFAULT
+ && (int)$this->config->get('lazy_eval_results') === (int)DOMJudgeService::EVAL_DEMAND)
+ || (int)$problem->getLazyEvalResults() === (int)DOMJudgeService::EVAL_DEMAND
+ ) {
+ $evalOnDemand = true;
+ }
+
$twigData = [
'submission' => $submission,
'lastSubmission' => $lastSubmission,
@@ -515,6 +523,7 @@ public function viewAction(
'combinedRunCompare' => $submission->getProblem()->getCombinedRunCompare(),
'requestedOutputCount' => $requestedOutputCount,
'version_warnings' => [],
+ 'evalOnDemand' => $evalOnDemand,
];
if ($selectedJudging === null) {
@@ -1203,6 +1212,14 @@ public function createJudgeTasks(string $submitId): RedirectResponse
return $this->redirectToRoute('jury_submission', ['submitId' => $submitId]);
}
+ #[Route(path: '/{submitId<\d+>}/create-tasks-full', name: 'jury_submission_create_tasks_full')]
+ public function createJudgeTasksFull(string $submitId): RedirectResponse
+ {
+ $this->dj->unblockJudgeTasksForSubmission($submitId, true);
+ $this->addFlash('info', "Started judging all testcases for submission: $submitId");
+ return $this->redirectToRoute('jury_submission', ['submitId' => $submitId]);
+ }
+
/**
* @param string[] $allErrors
*/
diff --git a/webapp/src/Service/DOMJudgeService.php b/webapp/src/Service/DOMJudgeService.php
index 7b14dd1f263..260d86066f4 100644
--- a/webapp/src/Service/DOMJudgeService.php
+++ b/webapp/src/Service/DOMJudgeService.php
@@ -1126,7 +1126,7 @@ public function unblockJudgeTasksForProblem(int $probId): void
}
}
- public function unblockJudgeTasksForSubmission(string $submissionId): void
+ public function unblockJudgeTasksForSubmission(string $submissionId, bool $judgeCompletely = false): void
{
// These are all the judgings that don't have associated judgetasks yet. Check whether we unblocked them.
$judgings = $this->helperUnblockJudgeTasks()
@@ -1136,7 +1136,7 @@ public function unblockJudgeTasksForSubmission(string $submissionId): void
->getQuery()
->getResult();
foreach ($judgings as $judging) {
- $this->maybeCreateJudgeTasks($judging, JudgeTask::PRIORITY_DEFAULT, true);
+ $this->maybeCreateJudgeTasks($judging, JudgeTask::PRIORITY_DEFAULT, true, judgeCompletely: $judgeCompletely);
}
}
@@ -1151,7 +1151,7 @@ public function unblockJudgeTasks(): void
}
}
- public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTask::PRIORITY_DEFAULT, bool $manualRequest = false): void
+ public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTask::PRIORITY_DEFAULT, bool $manualRequest = false, bool $judgeCompletely = false): void
{
$submission = $judging->getSubmission();
$problem = $submission->getContestProblem();
@@ -1181,6 +1181,10 @@ public function maybeCreateJudgeTasks(Judging $judging, int $priority = JudgeTas
return;
}
+ if ($judgeCompletely) {
+ $judging->setJudgeCompletely(true);
+ }
+
// We use a mass insert query, since that is way faster than doing a separate insert for each testcase.
// We first insert judgetasks, then select their ID's and finally insert the judging runs.
diff --git a/webapp/templates/jury/submission.html.twig b/webapp/templates/jury/submission.html.twig
index 8dc109b7af4..e2cbba77d34 100644
--- a/webapp/templates/jury/submission.html.twig
+++ b/webapp/templates/jury/submission.html.twig
@@ -395,10 +395,19 @@
{% if selectedJudging is null or selectedJudging.result is empty %}
{%- if not selectedJudging or not selectedJudging.started %}
+ {% if evalOnDemand %}
+
+
+
+
+ {% endif %}
{%- endif %}