Skip to content

Commit

Permalink
Added problem badges for executables
Browse files Browse the repository at this point in the history
  • Loading branch information
vmcj committed Oct 7, 2023
1 parent f141784 commit 82a1cd0
Show file tree
Hide file tree
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
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 @@ 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,],
];

Expand All @@ -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) {
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 @@ public function indexAction(Request $request): Response
default:
$execdata['icon']['icon'] = 'question';
}
$execdata['badges']['value'] = $badges;

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

0 comments on commit 82a1cd0

Please sign in to comment.