diff --git a/webapp/migrations/Version20250302132831.php b/webapp/migrations/Version20250302132831.php new file mode 100644 index 0000000000..4758c71686 --- /dev/null +++ b/webapp/migrations/Version20250302132831.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE contest ADD scoreboard_type VARCHAR(255) DEFAULT \'pass-fail\' NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE contest DROP scoreboard_type'); + } + + public function isTransactional(): bool + { + return false; + } +} diff --git a/webapp/src/Controller/Jury/ContestController.php b/webapp/src/Controller/Jury/ContestController.php index 1e4c8b7bc9..c480400e57 100644 --- a/webapp/src/Controller/Jury/ContestController.php +++ b/webapp/src/Controller/Jury/ContestController.php @@ -81,14 +81,15 @@ public function indexAction(Request $request): Response ->getQuery()->getResult(); $table_fields = [ - 'cid' => ['title' => 'CID', 'sort' => true], - 'externalid' => ['title' => "external ID", 'sort' => true], - 'shortname' => ['title' => 'shortname', 'sort' => true], - 'name' => ['title' => 'name', 'sort' => true], - 'activatetime' => ['title' => 'activate', 'sort' => true], - 'starttime' => ['title' => 'start', 'sort' => true, - 'default_sort' => true, 'default_sort_order' => 'desc'], - 'endtime' => ['title' => 'end', 'sort' => true], + 'cid' => ['title' => 'CID', 'sort' => true], + 'externalid' => ['title' => "external ID", 'sort' => true], + 'shortname' => ['title' => 'shortname', 'sort' => true], + 'name' => ['title' => 'name', 'sort' => true], + 'scoreboard_type' => ['title' => 'scoreboard type', 'sort' => true], + 'activatetime' => ['title' => 'activate', 'sort' => true], + 'starttime' => ['title' => 'start', 'sort' => true, + 'default_sort' => true, 'default_sort_order' => 'desc'], + 'endtime' => ['title' => 'end', 'sort' => true], ]; $currentContests = $this->dj->getCurrentContests(); @@ -137,7 +138,9 @@ public function indexAction(Request $request): Response $contestactions = []; // Get whatever fields we can from the contest object itself foreach ($table_fields as $k => $v) { - if ($propertyAccessor->isReadable($contest, $k)) { + if ($k == 'scoreboard_type') { + $contestdata[$k] = ['value' => $contest->getScoreboardType()->value]; + } elseif ($propertyAccessor->isReadable($contest, $k)) { $contestdata[$k] = ['value' => $propertyAccessor->getValue($contest, $k)]; } } diff --git a/webapp/src/Entity/Contest.php b/webapp/src/Entity/Contest.php index ba2e168be3..98ec34e1b0 100644 --- a/webapp/src/Entity/Contest.php +++ b/webapp/src/Entity/Contest.php @@ -43,11 +43,6 @@ exp: 'object.getName()', options: [new Serializer\Type('string')] )] -#[Serializer\VirtualProperty( - name: 'scoreboard_type', - exp: '"pass-fail"', - options: [new Serializer\Type('string')] -)] #[UniqueEntity(fields: 'shortname')] #[UniqueEntity(fields: 'externalid')] class Contest extends BaseApiEntity implements @@ -161,6 +156,18 @@ class Contest extends BaseApiEntity implements #[Serializer\Exclude] private ?int $b = 0; + #[ORM\Column(type: 'string', enumType: ScoreboardType::class, options: ['default' => 'pass-fail'])] + #[Serializer\Exclude] + private ScoreboardType $scoreboardType = ScoreboardType::PASS_FAIL; + + #[Serializer\VirtualProperty] + #[Serializer\SerializedName('scoreboard_type')] + #[Serializer\Type('string')] + public function getScoreboardTypeString(): string + { + return $this->scoreboardType->value; + } + #[ORM\Column( options: ['default' => 0] )] @@ -861,6 +868,17 @@ public function getPublic(): bool return $this->public; } + public function setScoreboardType(ScoreboardType $scoreboardType): Contest + { + $this->scoreboardType = $scoreboardType; + return $this; + } + + public function getScoreboardType(): ScoreboardType + { + return $this->scoreboardType; + } + public function setOpenToAllTeams(bool $openToAllTeams): Contest { $this->openToAllTeams = $openToAllTeams; diff --git a/webapp/src/Entity/ScoreboardType.php b/webapp/src/Entity/ScoreboardType.php new file mode 100644 index 0000000000..760f2d5c2d --- /dev/null +++ b/webapp/src/Entity/ScoreboardType.php @@ -0,0 +1,9 @@ +{{ contest.shortname }}