Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix 2279 backport #2644

Open
wants to merge 9 commits into
base: 8.2
Choose a base branch
from
Prev Previous commit
Next Next commit
Executable page: use badges for current contest.
(cherry picked from commit ac40ef6)
  • Loading branch information
meisterT authored and cubercsl committed Aug 3, 2024
commit 984290f0186c4d52c23f893548d5761f076eda87
12 changes: 12 additions & 0 deletions webapp/src/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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\Testcase;
Expand Down Expand Up @@ -124,6 +125,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 @@ -1106,6 +1108,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