Skip to content

Commit 241751a

Browse files
Allow to set public property for contest during import.
1 parent 2293b4e commit 241751a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

webapp/src/Service/ImportExportService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ public function importContestData(mixed $data, ?string &$errorMessage = null, st
212212
->setWarningMessage($data['warning_message'] ?? $data['warning-message'] ?? null)
213213
->setStarttimeString(date_format($startTime, 'Y-m-d H:i:s e'))
214214
->setActivatetimeString(date_format($activateTime, 'Y-m-d H:i:s e'))
215-
->setEndtimeString(sprintf('+%s', $data['duration']));
215+
->setEndtimeString(sprintf('+%s', $data['duration']))
216+
->setPublic($data['public'] ?? true);
216217
if ($deactivateTime) {
217218
$contest->setDeactivatetimeString(date_format($deactivateTime, 'Y-m-d H:i:s e'));
218219
}

webapp/tests/Unit/Service/ImportExportServiceTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function testImportContestDataSuccess(mixed $data, string $expectedShortN
106106
$contest = $this->getContest($cid);
107107

108108
self::assertEquals($data['name'], $contest->getName());
109+
self::assertEquals($data['public'] ?? true, $contest->getPublic());
109110
self::assertEquals($expectedShortName, $contest->getShortname());
110111

111112
$problems = [];
@@ -154,6 +155,7 @@ public function provideImportContestDataSuccess(): Generator
154155
'scoreboard-freeze-length' => '30:00',
155156
'short-name' => 'practice',
156157
'start-time' => '2021-03-27 09:00:00+00:00',
158+
'public' => true,
157159
'problems' => [
158160
[
159161
'color' => '#FE9DAF',
@@ -187,6 +189,7 @@ public function provideImportContestDataSuccess(): Generator
187189
'duration' => '5:00:00',
188190
'start_time' => '2020-01-01T12:34:56+02:00',
189191
'scoreboard_freeze_duration' => '1:00:00',
192+
'public' => false,
190193
],
191194
'test-contest',
192195
];

0 commit comments

Comments
 (0)