Skip to content

Commit 02bd5cb

Browse files
Change jury scoreboard page to use external IDs instead of internal IDs
Part of #3024
1 parent d590c34 commit 02bd5cb

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

webapp/src/Controller/Jury/ContestController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public function editAction(Request $request, string $contestId): Response
465465
if ($problems = $contestData['problems'] ?? null) {
466466
$existingProblemIndices = [];
467467
foreach ($contest->getProblems() as $index => $problem) {
468-
$existingProblemIndices[$problem->getProbId()] = $index;
468+
$existingProblemIndices[$problem->getExternalId()] = $index;
469469
}
470470
$indexForNew = $contest->getProblems()->count();
471471
$newProblems = [];
@@ -565,7 +565,7 @@ public function editAction(Request $request, string $contestId): Response
565565
$this->eventLogService->log('problems', $problem->getProbid(),
566566
EventLogService::ACTION_DELETE, $contest->getCid(), null, null, false);
567567
}
568-
return $this->redirectToRoute('jury_contest', ['contestId' => $contest->getcid()]);
568+
return $this->redirectToRoute('jury_contest', ['contestId' => $contest->getExternalId()]);
569569
}
570570

571571
$this->em->refresh($contest);

webapp/src/Controller/Jury/TeamAffiliationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function indexAction(
131131
]);
132132
}
133133

134-
#[Route(path: '/{affilId<\d+>}', name: 'jury_team_affiliation')]
134+
#[Route(path: '/{affilId}', name: 'jury_team_affiliation')]
135135
public function viewAction(Request $request, ScoreboardService $scoreboardService, int $affilId): Response
136136
{
137137
$teamAffiliation = $this->em->getRepository(TeamAffiliation::class)->find($affilId);

webapp/src/Controller/Jury/TeamController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use App\Controller\BaseController;
66
use App\DataTransferObject\SubmissionRestriction;
77
use App\Entity\Contest;
8+
use App\Entity\Language;
9+
use App\Entity\Problem;
810
use App\Entity\Role;
911
use App\Entity\Team;
1012
use App\Entity\User;
@@ -289,7 +291,12 @@ public function viewAction(
289291
'judgehost' => 'judgehost',
290292
default => throw new BadRequestHttpException(sprintf('Restriction on %s not allowed.', $key)),
291293
};
292-
$restrictions->$key = is_numeric($value) ? (int)$value : $value;
294+
$restrictionValue = match ($key) {
295+
'problemId' => $this->em->getRepository(Problem::class)->findByExternalId($value)->getProbid(),
296+
'languageId' => $this->em->getRepository(Language::class)->findByExternalId($value)->getLangid(),
297+
default => $value,
298+
};
299+
$restrictions->$key = is_numeric($restrictionValue) ? (int)$restrictionValue : $restrictionValue;
293300
$restrictionTexts[] = sprintf('%s %s', $restrictionKeyText, $value);
294301
}
295302
$restrictionText = implode(', ', $restrictionTexts);

webapp/templates/partials/scoreboard_table.html.twig

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
{% set target = '_self' %}
9595
{% if not static %}
9696
{% if jury %}
97-
{% set link = path('jury_problem', {'probId': problem.probid}) %}
97+
{% set link = path('jury_problem', {'probId': problem.externalid}) %}
9898
{% elseif problem.problem.problemstatementType is not empty %}
9999
{% if public %}
100100
{% set link = path('public_problem_statement', {probId: problem.externalid}) %}
@@ -188,7 +188,7 @@
188188
{% if score.team.affiliation %}
189189
{% set link = null %}
190190
{% if jury %}
191-
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.affilid}) %}
191+
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.externalid}) %}
192192
{% endif %}
193193
<a {% if link %}href="{{ link }}"{% endif %}>
194194
{{ score.team.affiliation.country|countryFlag }}
@@ -201,7 +201,7 @@
201201
{% if score.team.affiliation %}
202202
{% set link = null %}
203203
{% if jury %}
204-
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.affilid}) %}
204+
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.externalid}) %}
205205
{% endif %}
206206
<a {% if link %}href="{{ link }}"{% endif %}>
207207
{% set affiliationId = score.team.affiliation.externalid %}
@@ -225,10 +225,10 @@
225225
{% set extra = null %}
226226
{% if static %}
227227
{% set link = '#' %}
228-
{% set extra = 'data-bs-toggle="modal" data-bs-target="#team-modal-' ~ score.team.teamid ~ '"' %}
228+
{% set extra = 'data-bs-toggle="modal" data-bs-target="#team-modal-' ~ score.team.externalid ~ '"' %}
229229
{% else %}
230230
{% if jury %}
231-
{% set link = path('jury_team', {teamId: score.team.teamid}) %}
231+
{% set link = path('jury_team', {teamId: score.team.externalid}) %}
232232
{% elseif public %}
233233
{% set link = path('public_team', {teamId: score.team.externalid}) %}
234234
{% set extra = 'data-ajax-modal' %}
@@ -321,8 +321,8 @@
321321
{% set link = null %}
322322
{% set extra = null %}
323323
{% if jury %}
324-
{% set restrict = {problemId: problem.probid} %}
325-
{% set link = path('jury_team', {teamId: score.team.teamid, restrict: restrict}) %}
324+
{% set restrict = {problemId: problem.externalid} %}
325+
{% set link = path('jury_team', {teamId: score.team.externalid, restrict: restrict}) %}
326326
{% elseif static %}
327327
{% set link = '#' %}
328328
{% set extra = 'data-submissions-url="' ~ path('public_submissions_data') ~ '"' %}
@@ -462,7 +462,7 @@
462462
{% if score.team.affiliation %}
463463
{% set link = null %}
464464
{% if jury %}
465-
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.affilid}) %}
465+
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.externalid}) %}
466466
{% endif %}
467467
<a {% if link %}href="{{ link }}"{% endif %}>
468468
{{ score.team.affiliation.country|countryFlag }}
@@ -475,7 +475,7 @@
475475
{% if score.team.affiliation %}
476476
{% set link = null %}
477477
{% if jury %}
478-
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.affilid}) %}
478+
{% set link = path('jury_team_affiliation', {'affilId': score.team.affiliation.externalid}) %}
479479
{% endif %}
480480
<a {% if link %}href="{{ link }}"{% endif %}>
481481
{% set affiliationId = score.team.affiliation.externalid %}
@@ -499,12 +499,12 @@
499499
{% set extra = null %}
500500
{% if static %}
501501
{% set link = '#' %}
502-
{% set extra = 'data-bs-toggle="modal" data-bs-target="#team-modal-' ~ score.team.teamid ~ '"' %}
502+
{% set extra = 'data-bs-toggle="modal" data-bs-target="#team-modal-' ~ score.team.externalid ~ '"' %}
503503
{% else %}
504504
{% if jury %}
505-
{% set link = path('jury_team', {teamId: score.team.teamid}) %}
505+
{% set link = path('jury_team', {teamId: score.team.externalid}) %}
506506
{% elseif public %}
507-
{% set link = path('public_team', {teamId: score.team.teamid}) %}
507+
{% set link = path('public_team', {teamId: score.team.externalid}) %}
508508
{% set extra = 'data-ajax-modal' %}
509509
{% else %}
510510
{% set link = path('team_team', {teamId: score.team.externalid}) %}
@@ -572,7 +572,7 @@
572572
573573
{% if static %}
574574
{% for score in scores %}
575-
{% embed 'partials/modal.html.twig' with {'modalId': 'team-modal-' ~ score.team.teamid} %}
575+
{% embed 'partials/modal.html.twig' with {'modalId': 'team-modal-' ~ score.team.externalid} %}
576576
{% block title %}{{ score.team.effectiveName }}{% endblock %}
577577
{% block content %}
578578
{% include 'partials/team.html.twig' with {size: 6, team: score.team} %}
@@ -604,7 +604,7 @@
604604
<td>
605605
{% set link = null %}
606606
{% if jury %}
607-
{% set link = path('jury_team_category', {'categoryId': category.categoryid}) %}
607+
{% set link = path('jury_team_category', {'categoryId': category.externalid}) %}
608608
{% endif %}
609609
<a {% if link %}href="{{ link }}"{% endif %}>{{ category.name }}</a>
610610
</td>

0 commit comments

Comments
 (0)