Skip to content
2 changes: 1 addition & 1 deletion webapp/src/Controller/Jury/ProblemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ public function editAction(Request $request, int $probId): Response
)) {
$this->dj->auditlog('problem', $problem->getProbid(), 'upload zip', $clientName);
} else {
$this->addFlash('danger', implode("\n", $messages));
$this->postMessages($messages);
return $this->redirectToRoute('jury_problem', ['probId' => $problem->getProbid()]);
}
} catch (Exception $e) {
Expand Down
8 changes: 2 additions & 6 deletions webapp/src/Controller/Team/MiscController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,10 @@ public function homeAction(Request $request): Response
$clarifications = $this->em->createQueryBuilder()
->from(Clarification::class, 'c')
->leftJoin('c.problem', 'p')
->leftJoin('p.contest_problems', 'cp')
->leftJoin('c.sender', 's')
->leftJoin('c.recipient', 'r')
->select('c', 'cp', 'p')
->select('c', 'p')
->andWhere('c.contest = :contest')
->andWhere('cp.contest = :contest')
->andWhere('c.sender IS NULL')
->andWhere('c.recipient = :team OR c.recipient IS NULL')
->setParameter('contest', $contest)
Expand All @@ -123,12 +121,10 @@ public function homeAction(Request $request): Response
$clarificationRequests = $this->em->createQueryBuilder()
->from(Clarification::class, 'c')
->leftJoin('c.problem', 'p')
->leftJoin('p.contest_problems', 'cp')
->leftJoin('c.sender', 's')
->leftJoin('c.recipient', 'r')
->select('c', 'cp', 'p')
->select('c', 'p')
->andWhere('c.contest = :contest')
->andWhere('cp.contest = :contest')
->andWhere('c.sender = :team')
->setParameter('contest', $contest)
->setParameter('team', $team)
Expand Down
8 changes: 8 additions & 0 deletions webapp/src/Entity/Clarification.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,14 @@ public function getProblem(): ?Problem
return $this->problem;
}

public function getContestProblem(): ?ContestProblem
{
if (!$this->problem) {
return null;
}
return $this->contest->getContestProblem($this->problem);
}

/**
* @Serializer\VirtualProperty()
* @Serializer\SerializedName("problem_id")
Expand Down
10 changes: 10 additions & 0 deletions webapp/src/Entity/Contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,16 @@ public function getProblems(): Collection
return $this->problems;
}

public function getContestProblem(Problem $problem): ?ContestProblem
{
foreach ($this->getProblems() as $contestProblem) {
if ($contestProblem->getProblem() === $problem) {
return $contestProblem;
}
}
return null;
}

public function addClarification(Clarification $clarification): Contest
{
$this->clarifications[] = $clarification;
Expand Down
9 changes: 9 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('problemBadgeForContest', [$this, 'problemBadgeForContest'], ['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,13 @@ public function problemBadge(ContestProblem $problem): string
);
}

public function problemBadgeForContest(Problem $problem, ?Contest $contest = null): string
{
$contest ??= $this->dj->getCurrentContest();
$contestProblem = $contest !== null ? $contest->getContestProblem($problem) : null;
return $contestProblem === null ? '' : $this->problemBadge($contestProblem);
}

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 | problemBadgeForContest }}
</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 | problemBadgeForContest }}
</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
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

<td><a href="{{ link }}">
{%- if clarification.problem -%}
problem {{ clarification.problem.contestProblems.first | problemBadge -}}
problem {{ clarification.contestProblem | problemBadge -}}
{%- elseif clarification.category -%}
{{- categories[clarification.category]|default('general') -}}
{%- else -%}
Expand Down
2 changes: 1 addition & 1 deletion webapp/templates/team/partials/clarification.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="col-sm">
Subject:
{% if clarification.problem %}
Problem {{ clarification.problem.contestProblems.first.shortname }}: {{ clarification.problem.name }}
Problem {{ clarification.contestProblem.shortname }}: {{ clarification.problem.name }}
{% elseif clarification.category %}
{{ categories[clarification.category]|default('general') }}
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<td>
<a data-ajax-modal data-ajax-modal-after="markSeen" href="{{ link }}">
{%- if clarification.problem -%}
problem {{ clarification.problem.contestProblems.first | problemBadge -}}
problem {{ clarification.contestProblem | problemBadge -}}
{%- elseif clarification.category -%}
{{- categories[clarification.category]|default('general') -}}
{%- else -%}
Expand Down
Loading