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

Added problem badges #2151

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions webapp/src/Controller/Jury/ExecutableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Controller\Jury;

use App\Controller\BaseController;
use App\Entity\ContestProblem;
use App\Entity\Executable;
use App\Entity\ExecutableFile;
use App\Entity\ImmutableExecutable;
Expand Down Expand Up @@ -62,6 +63,7 @@
'icon' => ['title' => 'type', 'sort' => false],
'execid' => ['title' => 'ID', 'sort' => true,],
'type' => ['title' => 'type', 'sort' => true,],
'badges' => ['title' => 'problems', 'sort' => false],
'description' => ['title' => 'description', 'sort' => true,],
];

Expand All @@ -76,7 +78,46 @@
}
}

$contestProblemsWithExecutables = [];
$executablesWithContestProblems = [];
if ($this->dj->getCurrentContest()) {
$contestProblemsWithExecutables = $em->createQueryBuilder()
->select('cp', 'p', 'ecomp')
->from(ContestProblem::class, 'cp')
->where('cp.contest = :contest')
->setParameter('contest', $this->dj->getCurrentContest())
->join('cp.problem', 'p')
->leftJoin('p.compare_executable', 'ecomp')
->leftJoin('p.run_executable', 'erun')
->andWhere('ecomp IS NOT NULL OR erun IS NOT NULL')
->getQuery()->getResult();
$executablesWithContestProblems = $em->createQueryBuilder()
->select('e')
->from(Executable::class, 'e')
->leftJoin('e.problems_compare', 'pcomp')
->leftJoin('e.problems_run', 'prun')
->where('pcomp IS NOT NULL OR prun IS NOT NULL')
->leftJoin('pcomp.contest_problems', 'cpcomp')
->leftJoin('prun.contest_problems', 'cprun')
->andWhere('cprun.contest = :contest OR cpcomp.contest = :contest')
->setParameter('contest', $this->dj->getCurrentContest())
->getQuery()->getResult();
}

foreach ($executables as $e) {
$badges = [];
if (in_array($e, $executablesWithContestProblems)) {
foreach (array_merge($e->getProblemsRun()->toArray(), $e->getProblemsCompare()->toArray()) as $execProblem) {
$execContestProblems = $execProblem->getContestProblems();
foreach($contestProblemsWithExecutables as $cp) {

Check failure on line 112 in webapp/src/Controller/Jury/ExecutableController.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space(s) after FOREACH keyword; 0 found
if ($execContestProblems->contains($cp)) {
$badges[] = $cp;
}
}
}
}
sort($badges);

$execdata = [];
$execactions = [];
// Get whatever fields we can from the team object itself.
Expand All @@ -103,6 +144,7 @@
default:
$execdata['icon']['icon'] = 'question';
}
$execdata['badges']['value'] = $badges;
vmcj marked this conversation as resolved.
Show resolved Hide resolved

if ($this->isGranted('ROLE_ADMIN')) {
$execactions[] = [
Expand Down
4 changes: 4 additions & 0 deletions webapp/templates/jury/jury_macros.twig
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@
{{- (item.value|default(item.default|default('')))|affiliationLogo(item.title) -}}
{% elseif key == "warning_content" %}
{{- item.value|printWarningContent -}}
{% elseif key == "badges" %}
{% for badge in item.value %}
{{- badge|problemBadge }}
{% endfor %}
{% elseif (column.render | default('')) == "entity_id_badge" %}
{% if item.value %}{{- item.value|entityIdBadge(item.idPrefix|default('')) -}}{% endif %}
{% else %}
Expand Down
Loading