Skip to content

Commit e1c592a

Browse files
committed
Fix highlighting of in-freeze submissions by introducing separate metadata.
Previously, we did try to use the same metadata attribute in different scenarios and this was causing unrelated things to break (e.g. when having the triangles on the jury scoreboard, we would also incorrectly still show pending submissions in the scoreboard.json in the API). Note that as a side effect, this will no longer show "x + y tries" for submissions that happened in the freeze on the jury scoreboard (as we did before we introduced the blue triangles).
1 parent 7a6ac2e commit e1c592a

File tree

4 files changed

+36
-22
lines changed

4 files changed

+36
-22
lines changed

webapp/src/Utils/Scoreboard/Scoreboard.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,14 @@ protected function calculateScoreboard(): void
152152
);
153153

154154
$this->matrix[$teamId][$probId] = new ScoreboardMatrixItem(
155-
$scoreRow->getIsCorrect($this->restricted),
156-
$scoreRow->getIsCorrect($this->restricted) && $scoreRow->getIsFirstToSolve(),
157-
$scoreRow->getSubmissions($this->restricted),
158-
$scoreRow->getPending($this->restricted),
159-
$scoreRow->getSolveTime($this->restricted),
160-
$penalty,
161-
$scoreRow->getRuntime($this->restricted)
155+
isCorrect: $scoreRow->getIsCorrect($this->restricted),
156+
isFirst: $scoreRow->getIsCorrect($this->restricted) && $scoreRow->getIsFirstToSolve(),
157+
numSubmissions: $scoreRow->getSubmissions($this->restricted),
158+
numSubmissionsPending: $scoreRow->getPending($this->restricted),
159+
time: $scoreRow->getSolveTime($this->restricted),
160+
penaltyTime: $penalty,
161+
runtime: $scoreRow->getRuntime($this->restricted),
162+
numSubmissionsInFreeze: $scoreRow->getPending(false),
162163
);
163164

164165
if ($scoreRow->getIsCorrect($this->restricted)) {
@@ -216,7 +217,14 @@ protected function calculateScoreboard(): void
216217
$problemId = $contestProblem->getProbid();
217218
// Provide default scores when nothing submitted for this team + problem yet
218219
if (!isset($this->matrix[$teamId][$problemId])) {
219-
$this->matrix[$teamId][$problemId] = new ScoreboardMatrixItem(false, false, 0, 0, 0, 0, 0);
220+
$this->matrix[$teamId][$problemId] = new ScoreboardMatrixItem(
221+
isCorrect: false,
222+
isFirst: false,
223+
numSubmissions: 0,
224+
numSubmissionsPending: 0,
225+
time: 0,
226+
penaltyTime: 0,
227+
runtime: 0);
220228
}
221229

222230
$problemMatrixItem = $this->matrix[$teamId][$problemId];

webapp/src/Utils/Scoreboard/ScoreboardMatrixItem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public function __construct(
1111
public int $numSubmissionsPending,
1212
public float|string $time,
1313
public int $penaltyTime,
14-
public int $runtime
14+
public int $runtime,
15+
public ?int $numSubmissionsInFreeze = null,
1516
) {}
1617
}

webapp/src/Utils/Scoreboard/SingleTeamScoreboard.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ protected function calculateScoreboard(): void
6363
);
6464

6565
$this->matrix[$scoreRow->getTeam()->getTeamid()][$scoreRow->getProblem()->getProbid()] = new ScoreboardMatrixItem(
66-
$scoreRow->getIsCorrect($this->restricted),
67-
$scoreRow->getIsCorrect($this->showRestrictedFts) && $scoreRow->getIsFirstToSolve(),
68-
// When public scoreboard is frozen, also show "x + y tries" for jury
69-
$scoreRow->getSubmissions($this->freezeData->showFrozen() ? false : $this->restricted),
70-
$scoreRow->getPending($this->freezeData->showFrozen() ? false : $this->restricted),
71-
$scoreRow->getSolveTime($this->restricted),
72-
$penalty,
73-
$scoreRow->getRuntime($this->restricted)
66+
isCorrect: $scoreRow->getIsCorrect($this->restricted),
67+
isFirst: $scoreRow->getIsCorrect($this->showRestrictedFts) && $scoreRow->getIsFirstToSolve(),
68+
numSubmissions: $scoreRow->getSubmissions($this->restricted),
69+
numSubmissionsPending: $scoreRow->getPending($this->restricted),
70+
time: $scoreRow->getSolveTime($this->restricted),
71+
penaltyTime: $penalty,
72+
runtime: $scoreRow->getRuntime($this->restricted),
73+
numSubmissionsInFreeze: $scoreRow->getPending(false),
7474
);
7575
}
7676

@@ -80,7 +80,14 @@ protected function calculateScoreboard(): void
8080
$teamId = $this->team->getTeamid();
8181
$problemId = $contestProblem->getProbid();
8282
if (!isset($this->matrix[$teamId][$problemId])) {
83-
$this->matrix[$teamId][$problemId] = new ScoreboardMatrixItem(false, false, 0, 0, 0, 0, 0);
83+
$this->matrix[$teamId][$problemId] = new ScoreboardMatrixItem(
84+
isCorrect: false,
85+
isFirst: false,
86+
numSubmissions: 0,
87+
numSubmissionsPending: 0,
88+
time: 0,
89+
penaltyTime: 0,
90+
runtime: 0);
8491
}
8592
}
8693
}

webapp/templates/partials/scoreboard_table.html.twig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,8 @@
257257
{% elseif matrixItem.numSubmissions > 0 %}
258258
{% set scoreCssClass = 'score_incorrect' %}
259259
{% endif %}
260-
{% if jury and showPending and matrixItem.numSubmissionsPending > 0 %}
261-
{% if scoreCssClass == 'score_pending' %}
262-
{% set scoreCssClass = scoreCssClass ~ ' score_incorrect' %}
263-
{% else %}
260+
{% if jury and showPending and matrixItem.numSubmissionsInFreeze > 0 %}
261+
{% if scoreCssClass != 'score_pending' %}
264262
{% set scoreCssClass = scoreCssClass ~ ' score_pending' %}
265263
{% endif %}
266264
{% endif %}

0 commit comments

Comments
 (0)