From 114d0e7e260bc2bbee4d9e8be9c119ebcb01446a Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Sun, 2 Mar 2025 12:38:38 +0000 Subject: [PATCH] Associate internal error with judging run if available. In this case, display relevant information for corresponding test case and link to specific run on the submission page. --- webapp/migrations/Version20250302114442.php | 40 +++++++++++++++++++ .../Controller/API/JudgehostController.php | 5 +++ webapp/src/Entity/InternalError.php | 15 +++++++ .../templates/jury/internal_error.html.twig | 29 ++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 webapp/migrations/Version20250302114442.php diff --git a/webapp/migrations/Version20250302114442.php b/webapp/migrations/Version20250302114442.php new file mode 100644 index 0000000000..10b63e8b43 --- /dev/null +++ b/webapp/migrations/Version20250302114442.php @@ -0,0 +1,40 @@ +addSql('ALTER TABLE internal_error ADD runid INT UNSIGNED DEFAULT NULL COMMENT \'Run ID\''); + $this->addSql('ALTER TABLE internal_error ADD CONSTRAINT FK_518727D8A5788799 FOREIGN KEY (runid) REFERENCES judging_run (runid) ON DELETE SET NULL'); + $this->addSql('CREATE INDEX IDX_518727D8A5788799 ON internal_error (runid)'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE internal_error DROP FOREIGN KEY FK_518727D8A5788799'); + $this->addSql('DROP INDEX IDX_518727D8A5788799 ON internal_error'); + $this->addSql('ALTER TABLE internal_error DROP runid'); + } + + public function isTransactional(): bool + { + return false; + } +} diff --git a/webapp/src/Controller/API/JudgehostController.php b/webapp/src/Controller/API/JudgehostController.php index e26ed64ad2..a190281bfb 100644 --- a/webapp/src/Controller/API/JudgehostController.php +++ b/webapp/src/Controller/API/JudgehostController.php @@ -729,6 +729,7 @@ public function internalErrorAction(Request $request): ?int $judging = null; $judgingId = null; $cid = null; + $judgingRun = null; if ($judgeTaskId) { /** @var JudgeTask $judgeTask */ $judgeTask = $this->em->getRepository(JudgeTask::class)->findOneBy(['judgetaskid' => $judgeTaskId]); @@ -738,6 +739,7 @@ public function internalErrorAction(Request $request): ?int $judging = $this->em->getRepository(Judging::class)->findOneBy(['judgingid' => $judgingId]); $cid = $judging->getContest()->getCid(); } + $judgingRun = $this->em->getRepository(JudgingRun::class)->findOneBy(['judgetaskid' => $judgeTaskId]); } $disabled = Utils::jsonDecode($disabled); @@ -796,6 +798,9 @@ public function internalErrorAction(Request $request): ?int ->setJudgehostlog($judgehostlog) ->setTime(Utils::now()) ->setDisabled($disabled); + if ($judgingRun) { + $error->setJudgingRun($judgingRun); + } $this->em->persist($error); // Even if there are no remaining judge tasks for this judging open (which is covered by the transaction below), // we need to mark this judging as internal error. diff --git a/webapp/src/Entity/InternalError.php b/webapp/src/Entity/InternalError.php index eb2e75ec88..32cd54a6d6 100644 --- a/webapp/src/Entity/InternalError.php +++ b/webapp/src/Entity/InternalError.php @@ -69,6 +69,10 @@ class InternalError #[ORM\JoinColumn(name: 'judgingid', referencedColumnName: 'judgingid', onDelete: 'SET NULL')] private ?Judging $judging = null; + #[ORM\ManyToOne] + #[ORM\JoinColumn(name: 'runid', referencedColumnName: 'runid', onDelete: 'SET NULL')] + private ?JudgingRun $judgingRun = null; + /** * @var Collection */ @@ -182,4 +186,15 @@ public function getAffectedJudgings(): Collection { return $this->affectedJudgings; } + + public function getJudgingRun(): ?JudgingRun + { + return $this->judgingRun; + } + + public function setJudgingRun(?JudgingRun $judgingRun = null): InternalError + { + $this->judgingRun = $judgingRun; + return $this; + } } diff --git a/webapp/templates/jury/internal_error.html.twig b/webapp/templates/jury/internal_error.html.twig index fb809430ac..d380ebb89e 100644 --- a/webapp/templates/jury/internal_error.html.twig +++ b/webapp/templates/jury/internal_error.html.twig @@ -43,6 +43,35 @@ {% endif %} + {% if internalError.judgingRun is not null %} + + Related judging run / testcase + + {% set tc = internalError.judgingRun.testcase %} + + + + {% endif %} {% if internalError.affectedJudgings is not null %} Additional affected judgings