Skip to content

Commit da2dbec

Browse files
committed
Restrict clarifications to teams in the contest
When you have shared DOMjudge instance with 2 different contests with teams limited by categories (or directly assigned) we would still show all known teams (even teams not in that contest). We now let the DOMjudge service handle this.
1 parent c1c71c3 commit da2dbec

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

webapp/src/Form/Type/JuryClarificationType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
4444
$recipientOptions[$this->getTeamLabel($limitToTeam)] = $limitToTeam->getTeamid();
4545
} else {
4646
/** @var Team|null $limitToTeam */
47-
$teams = $this->em->getRepository(Team::class)->findAll();
47+
$teams = $this->dj->getTeamsForContest($this->dj->getCurrentContest());
4848
foreach ($teams as $team) {
4949
$recipientOptions[$this->getTeamLabel($team)] = $team->getTeamid();
5050
}

webapp/src/Service/DOMJudgeService.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,4 +1699,20 @@ public function getAllowedLanguagesForContest(?Contest $contest) : array {
16991699
->getQuery()
17001700
->getResult();
17011701
}
1702+
1703+
/** @return Team[] */
1704+
public function getTeamsForContest(?Contest $contest) : array {
1705+
if ($contest && !$contest->isOpenToAllTeams()) {
1706+
$contestTeams = $contest->getTeams()->toArray();
1707+
foreach ($contest->getTeamCategories() as $category) {
1708+
$contestTeams = array_merge($contestTeams, $category->getTeams()->toArray());
1709+
}
1710+
return $contestTeams;
1711+
}
1712+
return $this->em->createQueryBuilder()
1713+
->select('l')
1714+
->from(Team::class, 'l')
1715+
->getQuery()
1716+
->getResult();
1717+
}
17021718
}

0 commit comments

Comments
 (0)