Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added problem badges for executables
Browse files Browse the repository at this point in the history
vmcj committed Oct 6, 2023
1 parent f141784 commit a5685de
Showing 2 changed files with 46 additions and 0 deletions.
42 changes: 42 additions & 0 deletions webapp/src/Controller/Jury/ExecutableController.php
Original file line number Diff line number Diff line change
@@ -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;
@@ -62,6 +63,7 @@ public function indexAction(Request $request): Response
'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,],
];

@@ -76,7 +78,46 @@ public function indexAction(Request $request): Response
}
}

$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

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.
@@ -103,6 +144,7 @@ public function indexAction(Request $request): Response
default:
$execdata['icon']['icon'] = 'question';
}
$execdata['badges']['value'] = $badges;

if ($this->isGranted('ROLE_ADMIN')) {
$execactions[] = [
4 changes: 4 additions & 0 deletions webapp/templates/jury/jury_macros.twig
Original file line number Diff line number Diff line change
@@ -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 %}

0 comments on commit a5685de

Please sign in to comment.