From 4e18943088bbda7ba2b5243145af61386b73a1ac Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Sun, 13 Jul 2025 14:44:21 +0200 Subject: [PATCH 1/5] Add all Contest API endpoints and properties we support to access endpoint Include also the endpoints accounts and clarifications that were missing. --- .../src/Controller/API/AccessController.php | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/webapp/src/Controller/API/AccessController.php b/webapp/src/Controller/API/AccessController.php index 546c81a43d..0b97ff309f 100644 --- a/webapp/src/Controller/API/AccessController.php +++ b/webapp/src/Controller/API/AccessController.php @@ -100,9 +100,13 @@ public function getStatusAction(Request $request): Access 'name', 'formal_name', 'start_time', + 'countdown_pause_time', 'duration', 'scoreboard_freeze_duration', + 'scoreboard_thaw_time', + 'scoreboard_type', 'penalty_time', + 'banner', ], ), new AccessEndpoint( @@ -122,9 +126,8 @@ public function getStatusAction(Request $request): Access 'entry_point_required', 'entry_point_name', 'extensions', - // TODO: we don't support these yet -// 'compiler.command', -// 'runner.command', + 'compiler', + 'runner', ], ), new AccessEndpoint( @@ -160,9 +163,24 @@ public function getStatusAction(Request $request): Access 'id', 'icpc_id', 'name', + 'label', 'display_name', 'organization_id', 'group_ids', + 'hidden', + 'location', + 'photo', + ] + ), + new AccessEndpoint( + type: 'accounts', + properties: [ + 'id', + 'username', + 'name', + 'type', + 'ip', + 'team_id', ] ), new AccessEndpoint( @@ -205,6 +223,19 @@ public function getStatusAction(Request $request): Access 'run_time', ], ), + new AccessEndpoint( + type: 'clarifications', + properties: [ + 'id', + 'from_team_id', + 'to_team_id', + 'reply_to_id', + 'problem_id', + 'text', + 'time', + 'contest_time', + ], + ), new AccessEndpoint( type: 'awards', properties: [ From 2103bfc57f4530c20271093ad79daacb7aa064a7 Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Sun, 13 Jul 2025 14:44:43 +0200 Subject: [PATCH 2/5] Add DOMjudge specific properties to the API access endpoint --- .../src/Controller/API/AccessController.php | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/webapp/src/Controller/API/AccessController.php b/webapp/src/Controller/API/AccessController.php index 0b97ff309f..cd1b6064ea 100644 --- a/webapp/src/Controller/API/AccessController.php +++ b/webapp/src/Controller/API/AccessController.php @@ -49,6 +49,9 @@ public function getStatusAction(Request $request): Access 'icpc_id', 'name', 'formal_name', + // DOMjudge specific properties: + 'affilid', + 'shortname', ]; // Add country data to organizations if supported @@ -65,6 +68,9 @@ public function getStatusAction(Request $request): Access 'time', 'contest_time', 'entry_point', + // DOMjudge specific properties: + 'submitid', + 'import_error', ]; // Add files to submissions if allowed @@ -107,6 +113,14 @@ public function getStatusAction(Request $request): Access 'scoreboard_type', 'penalty_time', 'banner', + // DOMjudge specific properties: + 'cid', + 'short_name', + 'end_time', + 'allow_submit', + 'runtime_as_score_tiebreaker', + 'warning_message', + 'problemset', ], ), new AccessEndpoint( @@ -128,6 +142,10 @@ public function getStatusAction(Request $request): Access 'extensions', 'compiler', 'runner', + // DOMjudge specific properties: + 'allow_judge', + 'time_factor', + 'filter_compiler_files', ], ), new AccessEndpoint( @@ -142,6 +160,8 @@ public function getStatusAction(Request $request): Access 'time_limit', 'test_data_count', 'statement', + // DOMjudge specific properties: + 'probid', ], ), new AccessEndpoint( @@ -151,6 +171,11 @@ public function getStatusAction(Request $request): Access 'icpc_id', 'name', 'hidden', + // DOMjudge specific properties: + 'categoryid', + 'sortorder', + 'color', + 'allow_self_registration', ], ), new AccessEndpoint( @@ -170,6 +195,11 @@ public function getStatusAction(Request $request): Access 'hidden', 'location', 'photo', + // DOMjudge specific properties: + 'teamid', + 'affiliation', + 'nationality', + 'public_description', ] ), new AccessEndpoint( @@ -181,6 +211,16 @@ public function getStatusAction(Request $request): Access 'type', 'ip', 'team_id', + // DOMjudge specific properties: + 'first_login_time', + 'last_login_time', + 'last_api_login_time', + 'team', + 'roles', + 'userid', + 'email', + 'last_ip', + 'enabled', ] ), new AccessEndpoint( @@ -209,6 +249,8 @@ public function getStatusAction(Request $request): Access 'end_time', 'end_contest_time', 'max_run_time', + // DOMjudge specific properties: + 'valid', ], ), new AccessEndpoint( @@ -234,6 +276,9 @@ public function getStatusAction(Request $request): Access 'text', 'time', 'contest_time', + // DOMjudge specific properties: + 'clarid', + 'answered', ], ), new AccessEndpoint( From cf0f314ef39ce7d78227a3004fa17114e4de417d Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Sun, 13 Jul 2025 14:52:10 +0200 Subject: [PATCH 3/5] Don't expose problem types_to_string constants in the API --- webapp/src/Entity/Problem.php | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/src/Entity/Problem.php b/webapp/src/Entity/Problem.php index 343e7ec4f3..688063fec9 100644 --- a/webapp/src/Entity/Problem.php +++ b/webapp/src/Entity/Problem.php @@ -111,6 +111,7 @@ class Problem extends BaseApiEntity implements /** * @var array */ + #[Serializer\Exclude] private array $typesToString = [ self::TYPE_PASS_FAIL => 'pass-fail', self::TYPE_SCORING => 'scoring', From f76e59a7c0dbac9f614f65c77dd5dd62317d508d Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Sun, 13 Jul 2025 15:14:54 +0200 Subject: [PATCH 4/5] Also expose organization logos when configured --- webapp/src/Controller/API/AccessController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webapp/src/Controller/API/AccessController.php b/webapp/src/Controller/API/AccessController.php index cd1b6064ea..8f4196983e 100644 --- a/webapp/src/Controller/API/AccessController.php +++ b/webapp/src/Controller/API/AccessController.php @@ -59,6 +59,9 @@ public function getStatusAction(Request $request): Access $organizationProperties[] = 'country'; $organizationProperties[] = 'country_flag'; } + if ($this->config->get('show_affiliation_logos')) { + $organizationProperties[] = 'logo'; + } $submissionsProperties = [ 'id', From 9992568663ca210ee4abfb51a786520c9641eb27 Mon Sep 17 00:00:00 2001 From: Jaap Eldering Date: Sun, 13 Jul 2025 15:33:02 +0200 Subject: [PATCH 5/5] Update tests Don't exactly check for each property as that's just silly repeating of lists. --- webapp/tests/Unit/Controller/API/AccessControllerTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webapp/tests/Unit/Controller/API/AccessControllerTest.php b/webapp/tests/Unit/Controller/API/AccessControllerTest.php index 433dcf84f0..3831faa8a9 100644 --- a/webapp/tests/Unit/Controller/API/AccessControllerTest.php +++ b/webapp/tests/Unit/Controller/API/AccessControllerTest.php @@ -36,10 +36,12 @@ public function testAccessAsAdmin(): void 'groups' => ['id', 'icpc_id', 'name', 'hidden'], 'organizations' => ['id', 'icpc_id', 'name', 'formal_name', 'country', 'country_flag'], 'teams' => ['id', 'icpc_id', 'name', 'display_name', 'organization_id', 'group_ids'], + 'accounts' => ['id', 'username', 'name', 'type'], 'state' => ['started', 'frozen', 'ended', 'thawed', 'finalized', 'end_of_updates'], 'submissions' => ['id', 'language_id', 'problem_id', 'team_id', 'time', 'contest_time', 'entry_point', 'files'], 'judgements' => ['id', 'submission_id', 'judgement_type_id', 'start_time', 'start_contest_time', 'end_time', 'end_contest_time', 'max_run_time'], 'runs' => ['id', 'judgement_id', 'ordinal', 'judgement_type_id', 'time', 'contest_time', 'run_time'], + 'clarifications' => ['id', 'from_team_id', 'problem_id', 'text', 'time', 'contest_time'], 'awards' => ['id', 'citation', 'team_ids'], ]; @@ -54,7 +56,9 @@ public function testAccessAsAdmin(): void break; } } - self::assertSame($expectedProperties, $actualProperties); + foreach ($expectedProperties as $property) { + self::assertContains($property, $actualProperties); + } } } }