|
10 | 10 | use App\Entity\Judging;
|
11 | 11 | use App\Entity\JudgingRun;
|
12 | 12 | use App\Entity\Language;
|
| 13 | +use App\Entity\Problem; |
13 | 14 | use App\Entity\Submission;
|
14 | 15 | use App\Entity\SubmissionFile;
|
15 | 16 | use App\Entity\Testcase;
|
@@ -124,6 +125,7 @@ public function getFilters(): array
|
124 | 125 | new TwigFilter('tsvField', [$this, 'toTsvField']),
|
125 | 126 | new TwigFilter('fileTypeIcon', [$this, 'fileTypeIcon']),
|
126 | 127 | new TwigFilter('problemBadge', [$this, 'problemBadge'], ['is_safe' => ['html']]),
|
| 128 | + new TwigFilter('problemBadgeForProblemAndContest', [$this, 'problemBadgeForProblemAndContest'], ['is_safe' => ['html']]), |
127 | 129 | new TwigFilter('printMetadata', [$this, 'printMetadata'], ['is_safe' => ['html']]),
|
128 | 130 | new TwigFilter('printWarningContent', [$this, 'printWarningContent'], ['is_safe' => ['html']]),
|
129 | 131 | new TwigFilter('entityIdBadge', [$this, 'entityIdBadge'], ['is_safe' => ['html']]),
|
@@ -1106,6 +1108,16 @@ public function problemBadge(ContestProblem $problem): string
|
1106 | 1108 | );
|
1107 | 1109 | }
|
1108 | 1110 |
|
| 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 | + |
1109 | 1121 | public function printMetadata(?string $metadata): string
|
1110 | 1122 | {
|
1111 | 1123 | if ($metadata === null) {
|
|
0 commit comments