From 5cf65a46bbaa4c00491c3073f8766399d2929d0a Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Sat, 23 Mar 2024 13:13:00 +0100 Subject: [PATCH] Improve data on problems overview page. --- webapp/public/style_domjudge.css | 4 ++++ .../src/Controller/Jury/ProblemController.php | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/webapp/public/style_domjudge.css b/webapp/public/style_domjudge.css index b019e8fa91a..53230ff7a6b 100644 --- a/webapp/public/style_domjudge.css +++ b/webapp/public/style_domjudge.css @@ -646,3 +646,7 @@ blockquote { font-style: italic; font-size: smaller; } + +.right { + text-align: right; +} diff --git a/webapp/src/Controller/Jury/ProblemController.php b/webapp/src/Controller/Jury/ProblemController.php index 61b689377ec..e030d07da14 100644 --- a/webapp/src/Controller/Jury/ProblemController.php +++ b/webapp/src/Controller/Jury/ProblemController.php @@ -73,6 +73,7 @@ public function indexAction(): Response $table_fields = [ 'probid' => ['title' => 'ID', 'sort' => true, 'default_sort' => true], 'name' => ['title' => 'name', 'sort' => true], + 'badges' => ['title' => '', 'sort' => false], 'num_contests' => ['title' => '# contests', 'sort' => true], 'timelimit' => ['title' => 'time limit', 'sort' => true], 'memlimit' => ['title' => 'memory limit', 'sort' => true], @@ -165,22 +166,38 @@ public function indexAction(): Response } $problemactions[] = $deleteAction; } + $default_memlimit = $this->config->get('memory_limit'); + $default_output_limit = $this->config->get('output_limit'); // Add formatted {mem,output}limit row data for the table. foreach (['memlimit', 'outputlimit'] as $col) { $orig_value = @$problemdata[$col]['value']; if (!isset($orig_value)) { + $value = 'default'; + if ($col == 'memlimit' && !empty($default_memlimit)) { + $value .= ' (' . Utils::printsize(1024 * $default_memlimit) . ')'; + } + if ($col == 'outputlimit' && !empty($default_output_limit)) { + $value .= ' (' . Utils::printsize(1024 * $default_output_limit) . ')'; + } $problemdata[$col] = [ - 'value' => 'default', + 'value' => $value, 'cssclass' => 'disabled', ]; } else { $problemdata[$col] = [ 'value' => Utils::printsize(1024 * $orig_value), 'sortvalue' => $orig_value, + 'cssclass' => 'right', ]; } } + $problemdata['timelimit']['value'] = @$problemdata['timelimit']['value'] . 's'; + $problemdata['timelimit']['cssclass'] = 'right'; + + $contestProblems = $p->getContestProblems()->toArray(); + $badges = array_filter($contestProblems, fn($cp) => $cp->getCid() === $this->dj->getCurrentContest()->getCid()); + $problemdata['badges'] = ['value' => $badges]; // merge in the rest of the data $problemdata = array_merge($problemdata, [