Skip to content

Commit 96822c1

Browse files
meisterTcubercsl
authored andcommitted
Executable page: use badges for current contest.
(cherry picked from commit ac40ef6)
1 parent 5da9cb0 commit 96822c1

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
@@ -10,6 +10,7 @@
1010
use App\Entity\Judging;
1111
use App\Entity\JudgingRun;
1212
use App\Entity\Language;
13+
use App\Entity\Problem;
1314
use App\Entity\Submission;
1415
use App\Entity\SubmissionFile;
1516
use App\Entity\Testcase;
@@ -124,6 +125,7 @@ public function getFilters(): array
124125
new TwigFilter('tsvField', [$this, 'toTsvField']),
125126
new TwigFilter('fileTypeIcon', [$this, 'fileTypeIcon']),
126127
new TwigFilter('problemBadge', [$this, 'problemBadge'], ['is_safe' => ['html']]),
128+
new TwigFilter('problemBadgeForProblemAndContest', [$this, 'problemBadgeForProblemAndContest'], ['is_safe' => ['html']]),
127129
new TwigFilter('printMetadata', [$this, 'printMetadata'], ['is_safe' => ['html']]),
128130
new TwigFilter('printWarningContent', [$this, 'printWarningContent'], ['is_safe' => ['html']]),
129131
new TwigFilter('entityIdBadge', [$this, 'entityIdBadge'], ['is_safe' => ['html']]),
@@ -1106,6 +1108,16 @@ public function problemBadge(ContestProblem $problem): string
11061108
);
11071109
}
11081110

1111+
public function problemBadgeForProblemAndContest(Problem $problem, Contest $contest): string
1112+
{
1113+
foreach ($problem->getContestProblems() as $contestProblem) {
1114+
if ($contestProblem->getContest() === $contest) {
1115+
return $this->problemBadge($contestProblem);
1116+
}
1117+
}
1118+
return '';
1119+
}
1120+
11091121
public function printMetadata(?string $metadata): string
11101122
{
11111123
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)