Skip to content

Commit 2d9333d

Browse files
Change jury submission pages to use external IDs instead of internal IDs
Part of #3024 # Conflicts: # webapp/templates/jury/partials/submission_diff.html.twig # webapp/templates/jury/submission_source.html.twig
1 parent 02bd5cb commit 2d9333d

File tree

15 files changed

+199
-177
lines changed

15 files changed

+199
-177
lines changed

webapp/public/js/domjudge.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ function initDiffEditor(editorId) {
14031403
'onDiffSelectChange': (f) => {
14041404
select.change((e) => {
14051405
const noDiff = e.target.value === "";
1406-
const submitId = parseInt(e.target.value);
1406+
const submitId = e.target.value;
14071407
f(submitId, noDiff);
14081408
});
14091409
}
@@ -1432,10 +1432,10 @@ function initDiffEditor(editorId) {
14321432
diffTitle.style.display = 'inline';
14331433
diffTag.innerText = selected.dataset.tag;
14341434
diffLink.href = selected.dataset.url;
1435-
diffLink.innerText = `s${submitId}`;
1435+
diffLink.innerText = submitId;
14361436
}
14371437
};
1438-
updateSelect(parseInt(select[0].value), select[0].value === "");
1438+
updateSelect(select[0].value, select[0].value === "");
14391439
editor.onDiffSelectChange(updateSelect);
14401440
}
14411441

@@ -1559,7 +1559,7 @@ function initDiffEditorTab(editorId, diffId, submissionId, models) {
15591559
return;
15601560
}
15611561

1562-
const submitId = parseInt(editors[editorId].getDiffSelection());
1562+
const submitId = editors[editorId].getDiffSelection();
15631563
const noDiff = editors[editorId].getDiffSelection() === "";
15641564
if (noDiff) {
15651565
setIcon('file');

webapp/src/Controller/Jury/RejudgingController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ public function createAction(Request $request): Response
704704
'judgehost' => 'jt.judgehost',
705705
'language' => 'l.externalid',
706706
'problem' => 'p.externalid',
707-
'submission' => 's.submitid',
707+
'submission' => 's.externalid',
708708
'team' => 's.team',
709709
'user' => 's.user',
710710
'rejudging' => 'j2.rejudging',

webapp/src/Controller/Jury/SubmissionController.php

Lines changed: 72 additions & 74 deletions
Large diffs are not rendered by default.

webapp/src/DataTransferObject/SubmissionRestriction.php

Lines changed: 42 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,51 @@
22

33
namespace App\DataTransferObject;
44

5+
use App\DataTransferObject\Scoreboard\Problem;
6+
use App\Entity\Language;
7+
use App\Entity\Team;
8+
use App\Entity\TeamAffiliation;
9+
use App\Entity\TeamCategory;
10+
511
class SubmissionRestriction
612
{
713
/**
8-
* @param int|null $rejudgingId ID of a rejudging to filter on
9-
* @param bool|null $verified If true, only return verified submissions
10-
* If false, only return unverified or unjudged submissions
11-
* @param bool|null $judged If true, only return judged submissions
12-
* If false, only return unjudged submissions
13-
* @param bool|null $judging If true, only return submissions currently being judged
14-
* If false, only return submssions which are already judged or still
15-
* need to be judged
16-
* @param bool|null $rejudgingDifference If true, only return judgings that differ from their
17-
* original result in final verdict. Vice versa if false
18-
* @param int|null $teamId ID of a team to filter on
19-
* @param list<int>|null $teamIds ID's of teams to filter on
20-
* @param int|null $categoryId ID of a category to filter on
21-
* @param list<int>|null $categoryIds ID's of categories to filter on
22-
* @param int|null $affiliationId ID of an affiliation to filter on
23-
* @param list<int>|null $affiliationIds ID's of affiliations to filter on
24-
* @param int|null $problemId ID of a problem to filter on
25-
* @param list<int>|null $problemIds ID's of problems to filter on
26-
* @param int|null $languageId ID of a language to filter on
27-
* @param list<int>|null $languageIds ID's of languages to filter on
28-
* @param string|null $judgehost Hostname of a judgehost to filter on
29-
* @param string|null $oldResult Result of old judging to filter on
30-
* @param string|null $result Result of current judging to filter on
31-
* @param list<string>|null $results Results of current judging to filter on
32-
* @param int|null $userId Filter on specific user
33-
* @param bool|null $visible If true, only return submissions from visible teams
34-
* @param bool|null $externalDifference If true, only return results with a difference with an
35-
* external system
36-
* If false, only return results without a difference with an
37-
* external system
38-
* @param string|null $externalResult Result in the external system
39-
* @param bool|null $externallyJudged If true, only return externally judged submissions
40-
* If false, only return externally unjudged submissions
41-
* @param bool|null $externallyVerified If true, only return verified submissions
42-
* If false, only return unverified or unjudged submissions
43-
* @param bool|null $withExternalId If true, only return submissions with an external ID.
14+
* @param int|null $rejudgingId ID of a rejudging to filter on
15+
* @param bool|null $verified If true, only return verified submissions
16+
* If false, only return unverified or unjudged submissions
17+
* @param bool|null $judged If true, only return judged submissions
18+
* If false, only return unjudged submissions
19+
* @param bool|null $judging If true, only return submissions currently being judged
20+
* If false, only return submssions which are already judged or still
21+
* need to be judged
22+
* @param bool|null $rejudgingDifference If true, only return judgings that differ from their
23+
* original result in final verdict. Vice versa if false
24+
* @param int|null $teamId ID of a team to filter on
25+
* @param list<int>|list<Team>|null $teamIds ID's of teams to filter on
26+
* @param int|null $categoryId ID of a category to filter on
27+
* @param list<int>|list<TeamCategory>|null $categoryIds ID's of categories to filter on
28+
* @param int|null $affiliationId ID of an affiliation to filter on
29+
* @param list<int>|list<TeamAffiliation>|null $affiliationIds ID's of affiliations to filter on
30+
* @param int|null $problemId ID of a problem to filter on
31+
* @param list<int>|list<Problem>|null $problemIds ID's of problems to filter on
32+
* @param int|null $languageId ID of a language to filter on
33+
* @param list<int>|list<Language>|null $languageIds ID's of languages to filter on
34+
* @param string|null $judgehost Hostname of a judgehost to filter on
35+
* @param string|null $oldResult Result of old judging to filter on
36+
* @param string|null $result Result of current judging to filter on
37+
* @param list<string>|null $results Results of current judging to filter on
38+
* @param int|null $userId Filter on specific user
39+
* @param bool|null $visible If true, only return submissions from visible teams
40+
* @param bool|null $externalDifference If true, only return results with a difference with an
41+
* external system
42+
* If false, only return results without a difference with an
43+
* external system
44+
* @param string|null $externalResult Result in the external system
45+
* @param bool|null $externallyJudged If true, only return externally judged submissions
46+
* If false, only return externally unjudged submissions
47+
* @param bool|null $externallyVerified If true, only return verified submissions
48+
* If false, only return unverified or unjudged submissions
49+
* @param bool|null $withExternalId If true, only return submissions with an external ID.
4450
*/
4551
public function __construct(
4652
public ?int $rejudgingId = null,

webapp/src/Entity/Submission.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Controller\API\AbstractRestController as ARC;
66
use App\DataTransferObject\FileWithName;
7+
use App\Repository\SubmissionRepository;
78
use App\Utils\Utils;
89
use Doctrine\Common\Collections\ArrayCollection;
910
use Doctrine\Common\Collections\Collection;
@@ -16,7 +17,7 @@
1617
/**
1718
* All incoming submissions.
1819
*/
19-
#[ORM\Entity]
20+
#[ORM\Entity(repositoryClass: SubmissionRepository::class)]
2021
#[ORM\Table(options: [
2122
'collation' => 'utf8mb4_unicode_ci',
2223
'charset' => 'utf8mb4',

webapp/src/Form/Type/SubmissionsFilterType.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
4545
"class" => Problem::class,
4646
"required" => false,
4747
"choice_label" => "name",
48+
"choice_value" => "externalid",
4849
"choices" => $problems,
4950
"attr" => ["data-filter-field" => "problem-id"],
5051
]);
@@ -54,6 +55,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5455
"class" => Language::class,
5556
"required" => false,
5657
"choice_label" => "name",
58+
"choice_value" => "externalid",
5759
"query_builder" => fn(EntityRepository $er) => $er
5860
->createQueryBuilder("l")
5961
->where("l.allowSubmit = 1")
@@ -66,6 +68,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
6668
"class" => TeamCategory::class,
6769
"required" => false,
6870
"choice_label" => "name",
71+
"choice_value" => "externalid",
6972
"query_builder" => fn(EntityRepository $er) => $er
7073
->createQueryBuilder("tc")
7174
->orderBy("tc.name"),
@@ -77,6 +80,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
7780
"class" => TeamAffiliation::class,
7881
"required" => false,
7982
"choice_label" => "name",
83+
"choice_value" => "externalid",
8084
"query_builder" => fn(EntityRepository $er) => $er
8185
->createQueryBuilder("ta")
8286
->orderBy("ta.name"),
@@ -114,6 +118,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
114118
"class" => Team::class,
115119
"required" => false,
116120
"choice_label" => "name",
121+
"choice_value" => "externalid",
117122
"choices" => $teams,
118123
"attr" => ["data-filter-field" => "team-id"],
119124
]);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace App\Repository;
4+
5+
use App\Entity\Submission;
6+
use Doctrine\ORM\EntityRepository;
7+
8+
/**
9+
* @extends EntityRepository<Submission>
10+
*/
11+
class SubmissionRepository extends EntityRepository
12+
{
13+
/**
14+
* @use FindByExternalidTrait<Submission>
15+
*/
16+
use FindByExternalidTrait;
17+
}

webapp/src/Service/DOMJudgeService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ public function unblockJudgeTasksForSubmission(string $submissionId): void
11971197
// These are all the judgings that don't have associated judgetasks yet. Check whether we unblocked them.
11981198
$judgings = $this->helperUnblockJudgeTasks()
11991199
->join(Submission::class, 's', Join::WITH, 'j.submission = s.submitid')
1200-
->andWhere('j.submission = :submissionid')
1200+
->andWhere('s.externalid = :submissionid')
12011201
->setParameter('submissionid', $submissionId)
12021202
->getQuery()
12031203
->getResult();

webapp/src/Service/SubmissionService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getSubmissionList(
8989
->join('s.contest_problem', 'cp')
9090
->join('s.language', 'l')
9191
->andWhere('s.contest IN (:contests)')
92-
->setParameter('contests', array_keys($contests))
92+
->setParameter('contests', $contests)
9393
->orderBy('s.submittime', 'DESC')
9494
->addOrderBy('s.submitid', 'DESC');
9595

webapp/src/Twig/TwigExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,15 +935,15 @@ public function codeEditor(
935935
* source: string,
936936
* renamedFrom?: string
937937
* }> $files */
938-
public function showDiff(string $editorId, string $diffId, int $submissionId, string $filename, array $files): string
938+
public function showDiff(string $editorId, string $diffId, string $submissionId, string $filename, array $files): string
939939
{
940940
$editor = <<<HTML
941941
<div class="editor" id="$diffId"></div>
942942
<script>
943943
$(function() {
944944
const editorId = '%s';
945945
const diffId = '%s';
946-
const submissionId = %d;
946+
const submissionId = '%s';
947947
const models = %s;
948948
require(['vs/editor/editor.main'], () => {
949949
initDiffEditorTab(editorId, diffId, submissionId, models);

0 commit comments

Comments
 (0)