Skip to content

Split display of problems in current and other contests. #2920

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

Merged
merged 1 commit into from
Mar 1, 2025
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
21 changes: 11 additions & 10 deletions webapp/src/Controller/Jury/ProblemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,11 @@ public function indexAction(): Response
->groupBy('p.probid')
->getQuery()->getResult();

$badgeTitle = '';
$currentContest = $this->dj->getCurrentContest();
if ($currentContest !== null) {
$badgeTitle = 'in ' . $currentContest->getShortname();
}
$table_fields = [
'probid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true],
'externalid' => ['title' => 'external ID', 'sort' => true],
'name' => ['title' => 'name', 'sort' => true],
'badges' => ['title' => $badgeTitle, 'sort' => false],
'badges' => ['title' => '', 'sort' => false],
'num_contests' => ['title' => '# contests', 'sort' => true],
'timelimit' => ['title' => 'time limit', 'sort' => true],
'memlimit' => ['title' => 'memory limit', 'sort' => true],
Expand All @@ -107,7 +102,8 @@ public function indexAction(): Response
}

$propertyAccessor = PropertyAccess::createPropertyAccessor();
$problems_table = [];
$problems_table_current = [];
$problems_table_other = [];
foreach ($problems as $row) {
/** @var Problem $p */
$p = $row[0];
Expand Down Expand Up @@ -221,15 +217,20 @@ public function indexAction(): Response
'type' => ['value' => $type],
]);

// Save this to our list of rows
$problems_table[] = [
$data_to_add = [
'data' => $problemdata,
'actions' => $problemactions,
'link' => $this->generateUrl('jury_problem', ['probId' => $p->getProbid()]),
];
if ($badges) {
$problems_table_current[] = $data_to_add;
} else {
$problems_table_other[] = $data_to_add;
}
}
$data = [
'problems' => $problems_table,
'problems_current' => $problems_table_current,
'problems_other' => $problems_table_other,
'table_fields' => $table_fields,
];

Expand Down
15 changes: 13 additions & 2 deletions webapp/templates/jury/problems.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@

{% block content %}

<h1>Problems</h1>
{% if current_contest %}
<h1>Problems in contest {{ current_contest.name }}</h1>
{% if problems_current is empty %}
<em>There are no problems in this contest.</em>
{% endif %}

{{ macros.table(problems, table_fields) }}
{{ macros.table(problems_current, table_fields) }}
{% endif %}

{% if problems_other is not empty %}
<h1>Problems in other contests</h1>

{{ macros.table(problems_other, table_fields) }}
{% endif %}

{% if is_granted('ROLE_ADMIN') %}
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ProblemControllerTest extends JuryControllerTestCase
protected static string $getIDFunc = 'getProbid';
protected static string $className = Problem::class;
protected static array $DOM_elements = [
'h1' => ['Problems'],
'h1' => ['Problems in contest Demo contest'],
'a.btn[title="Import problem"]' => ['admin' => [" Import problem"], 'jury' => []]
];
protected static string $identifyingEditAttribute = 'name';
Expand Down
Loading