Skip to content

Commit f467913

Browse files
KevinjilmeisterT
authored andcommitted
Add a route including external contest ID
Analysts want to link from ICAT to submissions. As the external ID is only unique within contests, we added a route that links directly.
1 parent b9d9431 commit f467913

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

webapp/src/Controller/Jury/SubmissionController.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,30 @@ public function viewForExternalJudgementAction(ExternalJudgement $externalJudgem
668668
]);
669669
}
670670

671+
#[Route(path: '/by-contest-and-external-id/{externalContestId}/{externalId}', name: 'jury_submission_by_context_external_id')]
672+
public function viewForContestExternalIdAction(string $externalContestId, string $externalId): Response
673+
{
674+
$contest = $this->em->getRepository(Contest::class)->findOneBy(['externalid' => $externalContestId]);
675+
if ($contest === null) {
676+
throw new NotFoundHttpException("Cannot find the contest with the given external id.");
677+
}
678+
679+
$submission = $this->em->getRepository(Submission::class)
680+
->findOneBy([
681+
'contest' => $this->dj->getCurrentContest(),
682+
'externalid' => $externalId
683+
]);
684+
685+
if (!$submission) {
686+
throw new NotFoundHttpException(sprintf('No submission found with external ID %s', $externalId));
687+
}
688+
689+
$response = $this->redirectToRoute('jury_submission', [
690+
'submitId' => $submission->getSubmitid(),
691+
]);
692+
return $this->dj->setCookie('domjudge_cid', (string)$contest->getCid(), 0, null, '', false, false, $response);
693+
}
694+
671695
#[Route(path: '/by-external-id/{externalId}', name: 'jury_submission_by_external_id')]
672696
public function viewForExternalIdAction(string $externalId): RedirectResponse
673697
{

0 commit comments

Comments
 (0)