Skip to content

Commit 94940dd

Browse files
committed
Improve RejudgingFirstToSolveFixture.
Instead of using arbitrary submission times in the past way before contest start, use submission times within the contest duration.
1 parent c4e03ea commit 94940dd

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

webapp/src/DataFixtures/Test/RejudgingFirstToSolveFixture.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ public function load(ObjectManager $manager): void
2222

2323
$manager->persist($team2);
2424

25+
$contest = $manager->getRepository(Contest::class)->findOneBy(['shortname' => 'demo']);
26+
// Two submissions, one for each team, the incorrect one before the correct one.
27+
// Later, in the test, we will flip the 'wrong-answer' to correct in
28+
// order to produce a new first to solve.
2529
$submissionData = [
26-
// team, submittime, result]
27-
[$team1, '2021-01-01 12:34:56', 'correct'],
28-
[$team2, '2021-01-01 12:33:56', 'wrong-answer'],
30+
// team, submittime, result]
31+
[$team2, $contest->getStarttime() + 300, 'wrong-answer'],
32+
[$team1, $contest->getStarttime() + 400, 'correct'],
2933
];
3034

31-
$contest = $manager->getRepository(Contest::class)->findOneBy(['shortname' => 'demo']);
3235
$language = $manager->getRepository(Language::class)->find('cpp');
3336
$problem = $contest->getProblems()->filter(fn(ContestProblem $problem) => $problem->getShortname() === 'A')->first();
3437

@@ -39,11 +42,11 @@ public function load(ObjectManager $manager): void
3942
->setContestProblem($problem)
4043
->setLanguage($language)
4144
->setValid(true)
42-
->setSubmittime(Utils::toEpochFloat($submissionItem[1]));
45+
->setSubmittime($submissionItem[1]);
4346
$judging = (new Judging())
4447
->setContest($contest)
45-
->setStarttime(Utils::toEpochFloat($submissionItem[1]))
46-
->setEndtime(Utils::toEpochFloat($submissionItem[1]) + 5)
48+
->setStarttime($submissionItem[1])
49+
->setEndtime($submissionItem[1] + 5)
4750
->setValid(true)
4851
->setResult($submissionItem[2]);
4952
$judging->setSubmission($submission);

0 commit comments

Comments
 (0)