Skip to content

Commit

Permalink
Add option for ondemand mode to do a full judging in 1 buttonpress
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vmcj committed Mar 17, 2024
1 parent 5d04d16 commit 3b96dbf
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
17 changes: 17 additions & 0 deletions webapp/src/Controller/Jury/SubmissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 500 in webapp/src/Controller/Jury/SubmissionController.php

View workflow job for this annotation

GitHub Actions / phpstan

Undefined variable: $problem
) {
$evalOnDemand = true;
}

$twigData = [
'submission' => $submission,
'lastSubmission' => $lastSubmission,
Expand All @@ -515,6 +523,7 @@ public function viewAction(
'combinedRunCompare' => $submission->getProblem()->getCombinedRunCompare(),
'requestedOutputCount' => $requestedOutputCount,
'version_warnings' => [],
'evalOnDemand' => $evalOnDemand,
];

if ($selectedJudging === null) {
Expand Down Expand Up @@ -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
*/
Expand Down
10 changes: 7 additions & 3 deletions webapp/src/Service/DOMJudgeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
}
}

Expand All @@ -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();
Expand Down Expand Up @@ -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.

Expand Down
11 changes: 10 additions & 1 deletion webapp/templates/jury/submission.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,19 @@
&nbsp;
{% if selectedJudging is null or selectedJudging.result is empty %}
{%- if not selectedJudging or not selectedJudging.started %}
{% if evalOnDemand %}
<a href="{{ path('jury_submission_create_tasks_full', {'submitId': submission.submitid}) }}">
<button class="btn btn-sm btn-outline-secondary" >
<i class="fas fa-gavel"></i>
Judge submission (all testcases)
</button>
</a>
&nbsp;
{% endif %}
<a href="{{ path('jury_submission_create_tasks', {'submitId': submission.submitid}) }}">
<button class="btn btn-sm btn-outline-secondary" >
<i class="fas fa-gavel"></i>
Judge submission
Judge submission {% if evalOnDemand %}(lazy){% endif %}
</button>
</a>
{%- endif %}
Expand Down

0 comments on commit 3b96dbf

Please sign in to comment.