Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If a contest is selected, only show clarifications for that contest. #2255

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions webapp/src/Controller/Jury/ClarificationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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()
Expand All @@ -240,16 +250,20 @@ 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) {
if ($cp->getCid()!=$cid) {
continue;
}
$subject_options[$cshort]["$cid-" . $cp->getProbid()] =
$cshort . ' - ' .$cp->getShortname() . ': ' . $cp->getProblem()->getName();
$namePrefix . $cp->getShortname() . ': ' . $cp->getProblem()->getName();
}
}

Expand Down
25 changes: 13 additions & 12 deletions webapp/templates/jury/partials/clarification_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@
</select>
</div>

<div class="mb-3">
<label for="subject" class="form-label">Subject:</label>
<select name="problem" id="subject" class="form-select">
{% for contest,subject in clarform.subjects %}
<optgroup label="{{ contest }}">
{% for id,descr in subject %}
<option value="{{id}}"{% if clarform.onsubject is defined and clarform.onsubject == id %} selected{% endif %}>{{descr}}</option>
{% endfor %}
</optgroup>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label for="subject" class="form-label">Subject:</label>
<select name="problem" id="subject" class="form-select">
{% for contest,subject in clarform.subjects %}
{% if current_contest is null %}<optgroup label="{{ contest }}">{% endif %}
{% for id,descr in subject %}
<option
value="{{ id }}"{% if clarform.onsubject is defined and clarform.onsubject == id %} selected{% endif %}>{{ descr }}</option>
{% endfor %}
{% if current_contest is null %}</optgroup>{% endif %}
{% endfor %}
</select>
</div>

<div class="list-group mb-3">
<div class="list-group-item">
Expand Down
4 changes: 2 additions & 2 deletions webapp/templates/jury/partials/clarification_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% if showExternalId %}
<th scope="col">external ID</th>
{% endif %}
{%- if current_contests | length > 1 %}
{%- if current_contest is null and current_contests | length > 1 %}
<th scope="col">contest</th>
{%- endif %}

Expand All @@ -31,7 +31,7 @@
{% if showExternalId %}
<td><a href="{{ link }}">{{ clarification.externalid }}</a></td>
{% endif %}
{%- if current_contests | length > 1 %}
{%- if current_contest is null and current_contests | length > 1 %}
<td><a href="{{ link }}">{{ clarification.contest.shortname }}</a></td>
{%- endif %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
Loading