Skip to content

Commit c1d880a

Browse files
committed
Split display of problems in current and other contests.
This helps especially when there are many problems loaded.
1 parent f82c83e commit c1d880a

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

webapp/src/Controller/Jury/ProblemController.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,11 @@ public function indexAction(): Response
7575
->groupBy('p.probid')
7676
->getQuery()->getResult();
7777

78-
$badgeTitle = '';
79-
$currentContest = $this->dj->getCurrentContest();
80-
if ($currentContest !== null) {
81-
$badgeTitle = 'in ' . $currentContest->getShortname();
82-
}
8378
$table_fields = [
8479
'probid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true],
8580
'externalid' => ['title' => 'external ID', 'sort' => true],
8681
'name' => ['title' => 'name', 'sort' => true],
87-
'badges' => ['title' => $badgeTitle, 'sort' => false],
82+
'badges' => ['title' => '', 'sort' => false],
8883
'num_contests' => ['title' => '# contests', 'sort' => true],
8984
'timelimit' => ['title' => 'time limit', 'sort' => true],
9085
'memlimit' => ['title' => 'memory limit', 'sort' => true],
@@ -107,7 +102,8 @@ public function indexAction(): Response
107102
}
108103

109104
$propertyAccessor = PropertyAccess::createPropertyAccessor();
110-
$problems_table = [];
105+
$problems_table_current = [];
106+
$problems_table_other = [];
111107
foreach ($problems as $row) {
112108
/** @var Problem $p */
113109
$p = $row[0];
@@ -221,15 +217,20 @@ public function indexAction(): Response
221217
'type' => ['value' => $type],
222218
]);
223219

224-
// Save this to our list of rows
225-
$problems_table[] = [
220+
$data_to_add = [
226221
'data' => $problemdata,
227222
'actions' => $problemactions,
228223
'link' => $this->generateUrl('jury_problem', ['probId' => $p->getProbid()]),
229224
];
225+
if ($badges) {
226+
$problems_table_current[] = $data_to_add;
227+
} else {
228+
$problems_table_other[] = $data_to_add;
229+
}
230230
}
231231
$data = [
232-
'problems' => $problems_table,
232+
'problems_current' => $problems_table_current,
233+
'problems_other' => $problems_table_other,
233234
'table_fields' => $table_fields,
234235
];
235236

webapp/templates/jury/problems.html.twig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010

1111
{% block content %}
1212

13-
<h1>Problems</h1>
13+
{% if current_contest %}
14+
<h1>Problems in contest {{ current_contest.name }}</h1>
15+
{% if problems_current is empty %}
16+
<em>There are no problems in this contest.</em>
17+
{% endif %}
1418

15-
{{ macros.table(problems, table_fields) }}
19+
{{ macros.table(problems_current, table_fields) }}
20+
{% endif %}
21+
22+
{% if problems_other is not empty %}
23+
<h1>Problems in other contests</h1>
24+
25+
{{ macros.table(problems_other, table_fields) }}
26+
{% endif %}
1627

1728
{% if is_granted('ROLE_ADMIN') %}
1829
<p>

webapp/tests/Unit/Controller/Jury/ProblemControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ProblemControllerTest extends JuryControllerTestCase
1919
protected static string $getIDFunc = 'getProbid';
2020
protected static string $className = Problem::class;
2121
protected static array $DOM_elements = [
22-
'h1' => ['Problems'],
22+
'h1' => ['Problems in contest Demo contest'],
2323
'a.btn[title="Import problem"]' => ['admin' => [" Import problem"], 'jury' => []]
2424
];
2525
protected static string $identifyingEditAttribute = 'name';

0 commit comments

Comments
 (0)