Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions webapp/src/Entity/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ public function getJudgings(): Collection
return $this->judgings;
}

public function getValidJudging(): ?Judging
{
foreach ($this->judgings as $j) {
if ($j->getValid()) {
return $j;
}
}
return null;
Comment on lines +364 to +369
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
foreach ($this->judgings as $j) {
if ($j->getValid()) {
return $j;
}
}
return null;
return $this->judgings->findFirst(fn(Judging $j) => $j->getValid());

maybe?

}

public function setLanguage(?Language $language = null): Submission
{
$this->language = $language;
Expand Down Expand Up @@ -537,6 +547,16 @@ public function getExternalJudgements(): Collection
return $this->external_judgements;
}

public function getValidExternalJudgement(): ?ExternalJudgement
{
foreach ($this->external_judgements as $ej) {
if ($ej->getValid()) {
return $ej;
}
}
return null;
}

public function setFileForApi(?FileWithName $fileForApi = null): Submission
{
$this->fileForApi = $fileForApi;
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/Service/ScoreboardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ public function calculateScoreRow(
foreach ($submissions as $submission) {
/** @var Judging|ExternalJudgement|null $judging */
if ($useExternalJudgements) {
$judging = $submission->getExternalJudgements()->first() ?: null;
$judging = $submission->getValidExternalJudgement();
} else {
$judging = $submission->getJudgings()->first() ?: null;
$judging = $submission->getValidJudging();
}

// three things will happen in the loop in this order:
Expand Down
Loading