diff --git a/webapp/src/Controller/Jury/ProblemController.php b/webapp/src/Controller/Jury/ProblemController.php index cfd509f905..5b6ae258bb 100644 --- a/webapp/src/Controller/Jury/ProblemController.php +++ b/webapp/src/Controller/Jury/ProblemController.php @@ -962,7 +962,7 @@ public function editAction(Request $request, int $probId): Response )) { $this->dj->auditlog('problem', $problem->getProbid(), 'upload zip', $clientName); } else { - $this->addFlash('danger', implode("\n", $messages)); + $this->postMessages($messages); return $this->redirectToRoute('jury_problem', ['probId' => $problem->getProbid()]); } } catch (Exception $e) { diff --git a/webapp/src/Controller/Team/MiscController.php b/webapp/src/Controller/Team/MiscController.php index 83e15f62b1..073c2506c6 100644 --- a/webapp/src/Controller/Team/MiscController.php +++ b/webapp/src/Controller/Team/MiscController.php @@ -104,12 +104,10 @@ public function homeAction(Request $request): Response $clarifications = $this->em->createQueryBuilder() ->from(Clarification::class, 'c') ->leftJoin('c.problem', 'p') - ->leftJoin('p.contest_problems', 'cp') ->leftJoin('c.sender', 's') ->leftJoin('c.recipient', 'r') - ->select('c', 'cp', 'p') + ->select('c', 'p') ->andWhere('c.contest = :contest') - ->andWhere('cp.contest = :contest') ->andWhere('c.sender IS NULL') ->andWhere('c.recipient = :team OR c.recipient IS NULL') ->setParameter('contest', $contest) @@ -123,12 +121,10 @@ public function homeAction(Request $request): Response $clarificationRequests = $this->em->createQueryBuilder() ->from(Clarification::class, 'c') ->leftJoin('c.problem', 'p') - ->leftJoin('p.contest_problems', 'cp') ->leftJoin('c.sender', 's') ->leftJoin('c.recipient', 'r') - ->select('c', 'cp', 'p') + ->select('c', 'p') ->andWhere('c.contest = :contest') - ->andWhere('cp.contest = :contest') ->andWhere('c.sender = :team') ->setParameter('contest', $contest) ->setParameter('team', $team) diff --git a/webapp/src/Entity/Clarification.php b/webapp/src/Entity/Clarification.php index e451e39b5f..ece9a65311 100644 --- a/webapp/src/Entity/Clarification.php +++ b/webapp/src/Entity/Clarification.php @@ -267,6 +267,14 @@ public function getProblem(): ?Problem return $this->problem; } + public function getContestProblem(): ?ContestProblem + { + if (!$this->problem) { + return null; + } + return $this->contest->getContestProblem($this->problem); + } + /** * @Serializer\VirtualProperty() * @Serializer\SerializedName("problem_id") diff --git a/webapp/src/Entity/Contest.php b/webapp/src/Entity/Contest.php index 28ced7e847..da37be007b 100644 --- a/webapp/src/Entity/Contest.php +++ b/webapp/src/Entity/Contest.php @@ -862,6 +862,16 @@ public function getProblems(): Collection return $this->problems; } + public function getContestProblem(Problem $problem): ?ContestProblem + { + foreach ($this->getProblems() as $contestProblem) { + if ($contestProblem->getProblem() === $problem) { + return $contestProblem; + } + } + return null; + } + public function addClarification(Clarification $clarification): Contest { $this->clarifications[] = $clarification; diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 4e1470b1b9..ca0418fa5c 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -10,6 +10,7 @@ use App\Entity\Judging; use App\Entity\JudgingRun; use App\Entity\Language; +use App\Entity\Problem; use App\Entity\Submission; use App\Entity\SubmissionFile; use App\Entity\Testcase; @@ -124,6 +125,7 @@ public function getFilters(): array new TwigFilter('tsvField', [$this, 'toTsvField']), new TwigFilter('fileTypeIcon', [$this, 'fileTypeIcon']), new TwigFilter('problemBadge', [$this, 'problemBadge'], ['is_safe' => ['html']]), + new TwigFilter('problemBadgeForContest', [$this, 'problemBadgeForContest'], ['is_safe' => ['html']]), new TwigFilter('printMetadata', [$this, 'printMetadata'], ['is_safe' => ['html']]), new TwigFilter('printWarningContent', [$this, 'printWarningContent'], ['is_safe' => ['html']]), new TwigFilter('entityIdBadge', [$this, 'entityIdBadge'], ['is_safe' => ['html']]), @@ -1106,6 +1108,13 @@ public function problemBadge(ContestProblem $problem): string ); } + public function problemBadgeForContest(Problem $problem, ?Contest $contest = null): string + { + $contest ??= $this->dj->getCurrentContest(); + $contestProblem = $contest !== null ? $contest->getContestProblem($problem) : null; + return $contestProblem === null ? '' : $this->problemBadge($contestProblem); + } + public function printMetadata(?string $metadata): string { if ($metadata === null) { diff --git a/webapp/templates/jury/executable.html.twig b/webapp/templates/jury/executable.html.twig index 15a07a295f..01de2206b7 100644 --- a/webapp/templates/jury/executable.html.twig +++ b/webapp/templates/jury/executable.html.twig @@ -48,21 +48,21 @@ {% if executable.type == 'compare' %} {% for problem in executable.problemsCompare %} - p{{ problem.probid }} + p{{ problem.probid }} {{ problem | problemBadgeForContest }} {% set used = true %} {% endfor %} {% elseif executable.type == 'run' %} {% for problem in executable.problemsRun %} - p{{ problem.probid }} + p{{ problem.probid }} {{ problem | problemBadgeForContest }} {% set used = true %} {% endfor %} {% elseif executable.type == 'compile' %} {% for language in executable.languages %} - {{ language.langid }} + {{ language | entityIdBadge }} {% set used = true %} {% endfor %} diff --git a/webapp/templates/jury/partials/clarification_list.html.twig b/webapp/templates/jury/partials/clarification_list.html.twig index 44b22234cc..282a0411e6 100644 --- a/webapp/templates/jury/partials/clarification_list.html.twig +++ b/webapp/templates/jury/partials/clarification_list.html.twig @@ -71,7 +71,7 @@