From 13975e6196fefd369c947ca8396d8ddb52549a05 Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Fri, 22 Mar 2024 15:24:52 +0100 Subject: [PATCH] Executable page: use badges for current contest. --- webapp/src/Twig/TwigExtension.php | 12 ++++++++++++ webapp/templates/jury/executable.html.twig | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index fb8dfd965d..b724fb5e70 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -11,6 +11,7 @@ use App\Entity\Judging; use App\Entity\JudgingRun; use App\Entity\Language; +use App\Entity\Problem; use App\Entity\Submission; use App\Entity\SubmissionFile; use App\Entity\TeamCategory; @@ -107,6 +108,7 @@ public function getFilters(): array new TwigFilter('tsvField', $this->toTsvField(...)), new TwigFilter('fileTypeIcon', $this->fileTypeIcon(...)), new TwigFilter('problemBadge', $this->problemBadge(...), ['is_safe' => ['html']]), + new TwigFilter('problemBadgeForProblemAndContest', $this->problemBadgeForProblemAndContest(...), ['is_safe' => ['html']]), new TwigFilter('printMetadata', $this->printMetadata(...), ['is_safe' => ['html']]), new TwigFilter('printWarningContent', $this->printWarningContent(...), ['is_safe' => ['html']]), new TwigFilter('entityIdBadge', $this->entityIdBadge(...), ['is_safe' => ['html']]), @@ -1079,6 +1081,16 @@ public function problemBadge(ContestProblem $problem): string ); } + public function problemBadgeForProblemAndContest(Problem $problem, Contest $contest): string + { + foreach ($problem->getContestProblems() as $contestProblem) { + if ($contestProblem->getContest() === $contest) { + return $this->problemBadge($contestProblem); + } + } + return ''; + } + public function printMetadata(?string $metadata): string { if ($metadata === null) { diff --git a/webapp/templates/jury/executable.html.twig b/webapp/templates/jury/executable.html.twig index 883dde5002..95cbe3956e 100644 --- a/webapp/templates/jury/executable.html.twig +++ b/webapp/templates/jury/executable.html.twig @@ -48,21 +48,21 @@ {% if executable.type == 'compare' %} {% for problem in executable.problemsCompare %} - p{{ problem.probid }} + p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }} {% set used = true %} {% endfor %} {% elseif executable.type == 'run' %} {% for problem in executable.problemsRun %} - p{{ problem.probid }} + p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }} {% set used = true %} {% endfor %} {% elseif executable.type == 'compile' %} {% for language in executable.languages %} - {{ language.langid }} + {{ language | entityIdBadge }} {% set used = true %} {% endfor %}