From b00a8ec5d1451c90d56fdc91abe009a19a4ff2a4 Mon Sep 17 00:00:00 2001 From: Soha Jin Date: Mon, 17 Jun 2024 20:10:57 +0800 Subject: [PATCH] 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 e451e39b5f9..ece9a65311e 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 44b22234cc5..282a0411e6e 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 a0d72d26cd0..3900963f761 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 a36c1e0f30a..47b154c5423 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 -%}