From 11aa0b396132be7642295bd4d9cc172b6f99c94a Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Sat, 25 Nov 2023 14:34:31 +0100 Subject: [PATCH] If a contest is selected, only show clarifications for that contest. Fixes #2254. --- .../Jury/ClarificationController.php | 28 ++++++++++++++----- .../partials/clarification_form.html.twig | 25 +++++++++-------- .../partials/clarification_list.html.twig | 4 +-- .../Jury/ClarificationControllerTest.php | 2 +- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/webapp/src/Controller/Jury/ClarificationController.php b/webapp/src/Controller/Jury/ClarificationController.php index dcb3d085e0..2030dcc1d5 100644 --- a/webapp/src/Controller/Jury/ClarificationController.php +++ b/webapp/src/Controller/Jury/ClarificationController.php @@ -41,10 +41,14 @@ public function indexAction( string $currentQueue = 'all', ): Response { $categories = $this->config->get('clar_categories'); - $contestIds = array_keys($this->dj->getCurrentContests()); - // cid -1 will never happen, but otherwise the array is empty and that is not supported. - if (empty($contestIds)) { - $contestIds = [-1]; + if ($contest = $this->dj->getCurrentContest()) { + $contestIds = [$contest->getCid()]; + } else { + $contestIds = array_keys($this->dj->getCurrentContests()); + // cid -1 will never happen, but otherwise the array is empty and that is not supported. + if (empty($contestIds)) { + $contestIds = [-1]; + } } if ($currentFilter === 'all') { @@ -226,7 +230,13 @@ protected function getClarificationFormData(?Team $team = null): array $subject_options = []; $categories = $this->config->get('clar_categories'); - $contests = $this->dj->getCurrentContests(); + $contest = $this->dj->getCurrentContest(); + $hasCurrentContest = $contest !== null; + if ($hasCurrentContest) { + $contests = [$contest->getCid() => $contest]; + } else { + $contests = $this->dj->getCurrentContests(); + } /** @var ContestProblem[] $contestproblems */ $contestproblems = $this->em->createQueryBuilder() @@ -240,8 +250,12 @@ protected function getClarificationFormData(?Team $team = null): array foreach ($contests as $cid => $cdata) { $cshort = $cdata->getShortName(); + $namePrefix = ''; + if (!$hasCurrentContest) { + $namePrefix = $cshort . ' - '; + } foreach ($categories as $name => $desc) { - $subject_options[$cshort]["$cid-$name"] = "$cshort - $desc"; + $subject_options[$cshort]["$cid-$name"] = "$namePrefix $desc"; } foreach ($contestproblems as $cp) { @@ -249,7 +263,7 @@ protected function getClarificationFormData(?Team $team = null): array continue; } $subject_options[$cshort]["$cid-" . $cp->getProbid()] = - $cshort . ' - ' .$cp->getShortname() . ': ' . $cp->getProblem()->getName(); + $namePrefix . $cp->getShortname() . ': ' . $cp->getProblem()->getName(); } } diff --git a/webapp/templates/jury/partials/clarification_form.html.twig b/webapp/templates/jury/partials/clarification_form.html.twig index d4bfbaac0a..7184466bf3 100644 --- a/webapp/templates/jury/partials/clarification_form.html.twig +++ b/webapp/templates/jury/partials/clarification_form.html.twig @@ -13,18 +13,19 @@ -
- - -
+
+ + +
diff --git a/webapp/templates/jury/partials/clarification_list.html.twig b/webapp/templates/jury/partials/clarification_list.html.twig index 6c0688e4f7..337499bb1c 100644 --- a/webapp/templates/jury/partials/clarification_list.html.twig +++ b/webapp/templates/jury/partials/clarification_list.html.twig @@ -6,7 +6,7 @@ {% if showExternalId %} external ID {% endif %} - {%- if current_contests | length > 1 %} + {%- if current_contest is null and current_contests | length > 1 %} contest {%- endif %} @@ -31,7 +31,7 @@ {% if showExternalId %} {{ clarification.externalid }} {% endif %} - {%- if current_contests | length > 1 %} + {%- if current_contest is null and current_contests | length > 1 %} {{ clarification.contest.shortname }} {%- endif %} diff --git a/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php b/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php index 965b0f086d..e09121e267 100644 --- a/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php +++ b/webapp/tests/Unit/Controller/Jury/ClarificationControllerTest.php @@ -115,7 +115,7 @@ public function testClarificationRequestComposeForm(): void self::assertSelectorTextContains('div.col-sm strong', 'All'); self::assertSelectorTextContains('span.clarification-subject', - 'demo - Technical issue'); + 'Technical issue'); self::assertSelectorTextContains('div.card-text', 'This is a clarification'); }