From 4e189d76c8301dd73be932a32c49a6d42ced6e43 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Tue, 5 Mar 2024 21:26:20 +0900 Subject: [PATCH 1/8] Fix displayed messages when importing a problem from zip Previous attempts 019ec2ffdd3e0c51c97b3760d96a48f34a9c8d82 and a6640d5a5f9357cb0c41d2b51811524efe1fb567 fixed most cases reported in an issue #1708, but there's still a case where a wrong error message is shown. This fixes it. (cherry picked from commit 07e32354adfe9e2b9809d53f6d5899f06ec46525) --- webapp/src/Controller/Jury/ProblemController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { From f2c32cbe46ef1a6c8fa1fab8010e8417ea7e7048 Mon Sep 17 00:00:00 2001 From: cubercsl <2014cais01@gmail.com> Date: Sat, 3 Aug 2024 16:10:11 +0800 Subject: [PATCH 2/8] Revert "Select shortname from current contestproblem" This reverts commit a714386a70060bc9a98aac35a43d85916117bbbf. --- webapp/src/Controller/Team/MiscController.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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) From 984290f0186c4d52c23f893548d5761f076eda87 Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Fri, 22 Mar 2024 15:24:52 +0100 Subject: [PATCH 3/8] Executable page: use badges for current contest. (cherry picked from commit ac40ef6eab44ce9e190ae272fc18bf981f8d373e) --- webapp/src/Twig/TwigExtension.php | 12 ++++++++++++ webapp/templates/jury/executable.html.twig | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 4e1470b1b9..b83ab95cd8 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('problemBadgeForProblemAndContest', [$this, 'problemBadgeForProblemAndContest'], ['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,16 @@ public function problemBadge(ContestProblem $problem): string ); } + public function problemBadgeForProblemAndContest(Problem $problem, Contest $contest): string + { + foreach ($problem->getContestProblems() as $contestProblem) { + if ($contestProblem->getContest() === $contest) { + return $this->problemBadge($contestProblem); + } + } + return ''; + } + 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..f27d30b811 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 | problemBadgeForProblemAndContest(current_contest) }} {% set used = true %} {% endfor %} {% elseif executable.type == 'run' %} {% for problem in executable.problemsRun %} - p{{ problem.probid }} + p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }} {% set used = true %} {% endfor %} {% elseif executable.type == 'compile' %} {% for language in executable.languages %} - {{ language.langid }} + {{ language | entityIdBadge }} {% set used = true %} {% endfor %} From 094f9538c84f44727f423cbab203a62613410b03 Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Fri, 22 Mar 2024 16:51:46 +0100 Subject: [PATCH 4/8] Fix problem badge for "no contest". (cherry picked from commit b26ebfb622011abb433c03b91ae9443a3b6cc04e) --- webapp/src/Twig/TwigExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index b83ab95cd8..e28461d863 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -1108,7 +1108,7 @@ public function problemBadge(ContestProblem $problem): string ); } - public function problemBadgeForProblemAndContest(Problem $problem, Contest $contest): string + public function problemBadgeForProblemAndContest(Problem $problem, ?Contest $contest): string { foreach ($problem->getContestProblems() as $contestProblem) { if ($contestProblem->getContest() === $contest) { From f81ec56e96b7a2562ea648e514225931c62a71c9 Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 20:10:24 +0800 Subject: [PATCH 5/8] Add `getContestProblem` to Contest for getting an associated ContestProblem (cherry picked from commit 56104f63024f11599719b1e4553d732cf8e6cbce) --- webapp/src/Entity/Contest.php | 10 ++++++++++ webapp/src/Twig/TwigExtension.php | 11 ++++------- 2 files changed, 14 insertions(+), 7 deletions(-) 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 e28461d863..619830eef8 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -1108,14 +1108,11 @@ public function problemBadge(ContestProblem $problem): string ); } - public function problemBadgeForProblemAndContest(Problem $problem, ?Contest $contest): string + public function problemBadgeForProblemAndContest(Problem $problem, ?Contest $contest = null): string { - foreach ($problem->getContestProblems() as $contestProblem) { - if ($contestProblem->getContest() === $contest) { - return $this->problemBadge($contestProblem); - } - } - return ''; + $contest ??= $this->dj->getCurrentContest(); + $contestProblem = $contest?->getContestProblem($problem); + return $contestProblem === null ? '' : $this->problemBadge($contestProblem); } public function printMetadata(?string $metadata): string From 827c1831f6a471d823665adefc08dbb2cad3c0f1 Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 22:45:39 +0800 Subject: [PATCH 6/8] Rename `problemBadgeForProblemAndContest` to `problemBadgeForContest` (cherry picked from commit eaf95fecd838f6774494db1411bb07710ce41d88) --- webapp/src/Twig/TwigExtension.php | 4 ++-- webapp/templates/jury/executable.html.twig | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 619830eef8..745b201826 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -125,7 +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('problemBadgeForProblemAndContest', [$this, 'problemBadgeForProblemAndContest'], ['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']]), @@ -1108,7 +1108,7 @@ public function problemBadge(ContestProblem $problem): string ); } - public function problemBadgeForProblemAndContest(Problem $problem, ?Contest $contest = null): string + public function problemBadgeForContest(Problem $problem, ?Contest $contest = null): string { $contest ??= $this->dj->getCurrentContest(); $contestProblem = $contest?->getContestProblem($problem); diff --git a/webapp/templates/jury/executable.html.twig b/webapp/templates/jury/executable.html.twig index f27d30b811..01de2206b7 100644 --- a/webapp/templates/jury/executable.html.twig +++ b/webapp/templates/jury/executable.html.twig @@ -48,14 +48,14 @@ {% if executable.type == 'compare' %} {% for problem in executable.problemsCompare %} - p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }} + p{{ problem.probid }} {{ problem | problemBadgeForContest }} {% set used = true %} {% endfor %} {% elseif executable.type == 'run' %} {% for problem in executable.problemsRun %} - p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }} + p{{ problem.probid }} {{ problem | problemBadgeForContest }} {% set used = true %} {% endfor %} From b36292c51d118eccdf90c649b2f95b1897c2ca3c Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 20:10:57 +0800 Subject: [PATCH 7/8] Fix #2279: get associated ContestProblem with Clarification entity (cherry picked from commit affacb4ed043efd88c5d7e51f2ea8fdddb9a0576) --- webapp/src/Entity/Clarification.php | 8 ++++++++ .../templates/jury/partials/clarification_list.html.twig | 2 +- webapp/templates/team/partials/clarification.html.twig | 2 +- .../templates/team/partials/clarification_list.html.twig | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) 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/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 @@ {%- if clarification.problem -%} - problem {{ clarification.problem.contestProblems.first | problemBadge -}} + problem {{ clarification.contestProblem | problemBadge -}} {%- elseif clarification.category -%} {{- categories[clarification.category]|default('general') -}} {%- else -%} diff --git a/webapp/templates/team/partials/clarification.html.twig b/webapp/templates/team/partials/clarification.html.twig index a0d72d26cd..3900963f76 100644 --- a/webapp/templates/team/partials/clarification.html.twig +++ b/webapp/templates/team/partials/clarification.html.twig @@ -4,7 +4,7 @@
Subject: {% if clarification.problem %} - Problem {{ clarification.problem.contestProblems.first.shortname }}: {{ clarification.problem.name }} + Problem {{ clarification.contestProblem.shortname }}: {{ clarification.problem.name }} {% elseif clarification.category %} {{ categories[clarification.category]|default('general') }} {% else %} diff --git a/webapp/templates/team/partials/clarification_list.html.twig b/webapp/templates/team/partials/clarification_list.html.twig index a36c1e0f30..47b154c542 100644 --- a/webapp/templates/team/partials/clarification_list.html.twig +++ b/webapp/templates/team/partials/clarification_list.html.twig @@ -44,7 +44,7 @@ {%- if clarification.problem -%} - problem {{ clarification.problem.contestProblems.first | problemBadge -}} + problem {{ clarification.contestProblem | problemBadge -}} {%- elseif clarification.category -%} {{- categories[clarification.category]|default('general') -}} {%- else -%} From 9ec1f2b784da53b2339596b9c9196c3cb5ca85dc Mon Sep 17 00:00:00 2001 From: cubercsl <2014cais01@gmail.com> Date: Sat, 3 Aug 2024 18:55:31 +0800 Subject: [PATCH 8/8] chore: avoid using nullsafe operator in php7 Nullsafe operator is supported since PHP8. Avoid using nullsafe operators in PHP7, as domjudge 8.2 branch needs to support PHP 7.4 Signed-off-by: cubercsl <2014cais01@gmail.com> --- webapp/src/Twig/TwigExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 745b201826..ca0418fa5c 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -1111,7 +1111,7 @@ public function problemBadge(ContestProblem $problem): string public function problemBadgeForContest(Problem $problem, ?Contest $contest = null): string { $contest ??= $this->dj->getCurrentContest(); - $contestProblem = $contest?->getContestProblem($problem); + $contestProblem = $contest !== null ? $contest->getContestProblem($problem) : null; return $contestProblem === null ? '' : $this->problemBadge($contestProblem); }