Skip to content

Commit bebe929

Browse files
committed
Basic import of score while shadowing. No display or comparison yet.
1 parent 5c9d385 commit bebe929

File tree

7 files changed

+115
-0
lines changed

7 files changed

+115
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20250804192300 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE external_judgement ADD score NUMERIC(32, 9) DEFAULT \'0.000000000\' NOT NULL COMMENT \'Optional score for this run, e.g. for partial scoring\'');
24+
}
25+
26+
public function down(Schema $schema): void
27+
{
28+
// this down() migration is auto-generated, please modify it to your needs
29+
$this->addSql('ALTER TABLE external_judgement DROP score');
30+
}
31+
32+
public function isTransactional(): bool
33+
{
34+
return false;
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DoctrineMigrations;
6+
7+
use Doctrine\DBAL\Schema\Schema;
8+
use Doctrine\Migrations\AbstractMigration;
9+
10+
/**
11+
* Auto-generated Migration: Please modify to your needs!
12+
*/
13+
final class Version20250804194436 extends AbstractMigration
14+
{
15+
public function getDescription(): string
16+
{
17+
return '';
18+
}
19+
20+
public function up(Schema $schema): void
21+
{
22+
// this up() migration is auto-generated, please modify it to your needs
23+
$this->addSql('ALTER TABLE external_run ADD score NUMERIC(32, 9) DEFAULT \'0.000000000\' NOT NULL COMMENT \'Optional score for this run, e.g. for partial scoring\'');
24+
}
25+
26+
public function down(Schema $schema): void
27+
{
28+
// this down() migration is auto-generated, please modify it to your needs
29+
$this->addSql('ALTER TABLE external_run DROP score');
30+
}
31+
32+
public function isTransactional(): bool
33+
{
34+
return false;
35+
}
36+
}

webapp/src/DataTransferObject/Shadowing/JudgementEvent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public function __construct(
1010
public readonly string $submissionId,
1111
public readonly ?string $endTime,
1212
public readonly ?string $judgementTypeId,
13+
public readonly string|float|null $score,
1314
) {}
1415
}

webapp/src/DataTransferObject/Shadowing/RunEvent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public function __construct(
1111
public readonly ?string $judgementTypeId,
1212
public readonly ?string $time,
1313
public readonly ?float $runTime,
14+
public readonly string|float|null $score,
1415
) {}
1516
}

webapp/src/Entity/ExternalJudgement.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ class ExternalJudgement
8484
)]
8585
private bool $valid = true;
8686

87+
#[ORM\Column(
88+
type: 'decimal',
89+
precision: 32,
90+
scale: 9,
91+
options: [
92+
'comment' => 'Optional score for this run, e.g. for partial scoring',
93+
'default' => '0.000000000',
94+
]
95+
)]
96+
private string|float $score = 0;
97+
8798
#[ORM\ManyToOne]
8899
#[ORM\JoinColumn(name: 'cid', referencedColumnName: 'cid', onDelete: 'CASCADE')]
89100
private Contest $contest;
@@ -249,4 +260,15 @@ public function getSumRuntime(): float
249260
}
250261
return $sum;
251262
}
263+
264+
public function getScore(): string|float
265+
{
266+
return $this->score;
267+
}
268+
269+
public function setScore(string|float $score): ExternalJudgement
270+
{
271+
$this->score = $score;
272+
return $this;
273+
}
252274
}

webapp/src/Entity/ExternalRun.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ class ExternalRun
6262
#[ORM\JoinColumn(name: 'cid', referencedColumnName: 'cid', onDelete: 'CASCADE')]
6363
private Contest $contest;
6464

65+
#[ORM\Column(
66+
type: 'decimal',
67+
precision: 32,
68+
scale: 9,
69+
options: [
70+
'comment' => 'Optional score for this run, e.g. for partial scoring',
71+
'default' => '0.000000000',
72+
]
73+
)]
74+
private string|float $score = 0;
75+
6576
public function getExtrunid(): int
6677
{
6778
return $this->extrunid;

webapp/src/Service/ExternalContestSourceService.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,10 @@ protected function importJudgement(Event $event, EventData $data): void
17051705
->setEndtime($endTime)
17061706
->setResult($judgementTypeId === null ? null : $verdictsFlipped[$judgementTypeId]);
17071707

1708+
if (isset($data->score)) {
1709+
$judgement->setScore($data->score);
1710+
}
1711+
17081712
if ($persist) {
17091713
$this->em->persist($judgement);
17101714
}
@@ -1855,6 +1859,10 @@ protected function importRun(Event $event, EventData $data): void
18551859
->setRuntime($runTime)
18561860
->setResult($judgementTypeId === null ? null : $verdictsFlipped[$judgementTypeId]);
18571861

1862+
if (isset($data->score)) {
1863+
$run->setScore($data->score);
1864+
}
1865+
18581866
if ($persist) {
18591867
$this->em->persist($run);
18601868
}

0 commit comments

Comments
 (0)