Skip to content

Commit ac40ef6

Browse files
committed
Executable page: use badges for current contest.
1 parent 80234e9 commit ac40ef6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

webapp/src/Twig/TwigExtension.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use App\Entity\Judging;
1212
use App\Entity\JudgingRun;
1313
use App\Entity\Language;
14+
use App\Entity\Problem;
1415
use App\Entity\Submission;
1516
use App\Entity\SubmissionFile;
1617
use App\Entity\TeamCategory;
@@ -107,6 +108,7 @@ public function getFilters(): array
107108
new TwigFilter('tsvField', $this->toTsvField(...)),
108109
new TwigFilter('fileTypeIcon', $this->fileTypeIcon(...)),
109110
new TwigFilter('problemBadge', $this->problemBadge(...), ['is_safe' => ['html']]),
111+
new TwigFilter('problemBadgeForProblemAndContest', $this->problemBadgeForProblemAndContest(...), ['is_safe' => ['html']]),
110112
new TwigFilter('printMetadata', $this->printMetadata(...), ['is_safe' => ['html']]),
111113
new TwigFilter('printWarningContent', $this->printWarningContent(...), ['is_safe' => ['html']]),
112114
new TwigFilter('entityIdBadge', $this->entityIdBadge(...), ['is_safe' => ['html']]),
@@ -1079,6 +1081,16 @@ public function problemBadge(ContestProblem $problem): string
10791081
);
10801082
}
10811083

1084+
public function problemBadgeForProblemAndContest(Problem $problem, Contest $contest): string
1085+
{
1086+
foreach ($problem->getContestProblems() as $contestProblem) {
1087+
if ($contestProblem->getContest() === $contest) {
1088+
return $this->problemBadge($contestProblem);
1089+
}
1090+
}
1091+
return '';
1092+
}
1093+
10821094
public function printMetadata(?string $metadata): string
10831095
{
10841096
if ($metadata === null) {

webapp/templates/jury/executable.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,21 @@
4848
{% if executable.type == 'compare' %}
4949
{% for problem in executable.problemsCompare %}
5050
<a href="{{ path('jury_problem', {'probId': problem.probid}) }}">
51-
p{{ problem.probid }}
51+
p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }}
5252
</a>
5353
{% set used = true %}
5454
{% endfor %}
5555
{% elseif executable.type == 'run' %}
5656
{% for problem in executable.problemsRun %}
5757
<a href="{{ path('jury_problem', {'probId': problem.probid}) }}">
58-
p{{ problem.probid }}
58+
p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }}
5959
</a>
6060
{% set used = true %}
6161
{% endfor %}
6262
{% elseif executable.type == 'compile' %}
6363
{% for language in executable.languages %}
6464
<a href="{{ path('jury_language', {'langId': language.langid}) }}">
65-
{{ language.langid }}
65+
{{ language | entityIdBadge }}
6666
</a>
6767
{% set used = true %}
6868
{% endfor %}

0 commit comments

Comments
 (0)