Skip to content

Commit

Permalink
Split display of problems in current and other contests.
Browse files Browse the repository at this point in the history
This helps especially when there are many problems loaded.
  • Loading branch information
meisterT committed Mar 1, 2025
1 parent f82c83e commit c1d880a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
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

0 comments on commit c1d880a

Please sign in to comment.