Skip to content

Commit

Permalink
Executable page: use badges for current contest.
Browse files Browse the repository at this point in the history
  • Loading branch information
meisterT committed Mar 22, 2024
1 parent 8fead6b commit 13975e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']]),
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions webapp/templates/jury/executable.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@
{% if executable.type == 'compare' %}
{% for problem in executable.problemsCompare %}
<a href="{{ path('jury_problem', {'probId': problem.probid}) }}">
p{{ problem.probid }}
p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }}
</a>
{% set used = true %}
{% endfor %}
{% elseif executable.type == 'run' %}
{% for problem in executable.problemsRun %}
<a href="{{ path('jury_problem', {'probId': problem.probid}) }}">
p{{ problem.probid }}
p{{ problem.probid }} {{ problem | problemBadgeForProblemAndContest(current_contest) }}
</a>
{% set used = true %}
{% endfor %}
{% elseif executable.type == 'compile' %}
{% for language in executable.languages %}
<a href="{{ path('jury_language', {'langId': language.langid}) }}">
{{ language.langid }}
{{ language | entityIdBadge }}
</a>
{% set used = true %}
{% endfor %}
Expand Down

0 comments on commit 13975e6

Please sign in to comment.