Skip to content

Commit 1f4cc32

Browse files
committed
Improve data on problems overview page.
1 parent 3aebb25 commit 1f4cc32

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

webapp/public/style_domjudge.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,3 +646,7 @@ blockquote {
646646
font-style: italic;
647647
font-size: smaller;
648648
}
649+
650+
.right {
651+
text-align: right;
652+
}

webapp/src/Controller/Jury/ProblemController.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,15 @@ public function indexAction(): Response
7070
->groupBy('p.probid')
7171
->getQuery()->getResult();
7272

73+
$badgeTitle = '';
74+
$currentContest = $this->dj->getCurrentContest();
75+
if ($currentContest !== null) {
76+
$badgeTitle = 'in ' . $currentContest->getShortname();
77+
}
7378
$table_fields = [
7479
'probid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true],
7580
'name' => ['title' => 'name', 'sort' => true],
81+
'badges' => ['title' => $badgeTitle, 'sort' => false],
7682
'num_contests' => ['title' => '# contests', 'sort' => true],
7783
'timelimit' => ['title' => 'time limit', 'sort' => true],
7884
'memlimit' => ['title' => 'memory limit', 'sort' => true],
@@ -165,22 +171,41 @@ public function indexAction(): Response
165171
}
166172
$problemactions[] = $deleteAction;
167173
}
174+
$default_memlimit = $this->config->get('memory_limit');
175+
$default_output_limit = $this->config->get('output_limit');
168176

169177
// Add formatted {mem,output}limit row data for the table.
170178
foreach (['memlimit', 'outputlimit'] as $col) {
171179
$orig_value = @$problemdata[$col]['value'];
172180
if (!isset($orig_value)) {
181+
$value = 'default';
182+
if ($col == 'memlimit' && !empty($default_memlimit)) {
183+
$value .= ' (' . Utils::printsize(1024 * $default_memlimit) . ')';
184+
}
185+
if ($col == 'outputlimit' && !empty($default_output_limit)) {
186+
$value .= ' (' . Utils::printsize(1024 * $default_output_limit) . ')';
187+
}
173188
$problemdata[$col] = [
174-
'value' => 'default',
189+
'value' => $value,
175190
'cssclass' => 'disabled',
176191
];
177192
} else {
178193
$problemdata[$col] = [
179194
'value' => Utils::printsize(1024 * $orig_value),
180195
'sortvalue' => $orig_value,
196+
'cssclass' => 'right',
181197
];
182198
}
183199
}
200+
$problemdata['timelimit']['value'] = @$problemdata['timelimit']['value'] . 's';
201+
$problemdata['timelimit']['cssclass'] = 'right';
202+
203+
$contestProblems = $p->getContestProblems()->toArray();
204+
$badges = [];
205+
if ($this->dj->getCurrentContest() !== null) {
206+
$badges = array_filter($contestProblems, fn($cp) => $cp->getCid() === $this->dj->getCurrentContest()->getCid());
207+
}
208+
$problemdata['badges'] = ['value' => $badges];
184209

185210
// merge in the rest of the data
186211
$problemdata = array_merge($problemdata, [

0 commit comments

Comments
 (0)