Skip to content

Commit 7a9500a

Browse files
committed
enhence return value at ScoreCache getOptScore
1 parent a8e0828 commit 7a9500a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

webapp/src/Entity/ScoreCache.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public function setOptScoreMaxRestricted(float $optscoreMaxRestricted): ScoreCac
212212

213213
public function getOptScoreMaxRestricted(): float
214214
{
215-
return $this->optscore_max_restricted;
215+
return $this->optscore_max_restricted ?? 0;
216216
}
217217

218218
public function setOptScoreMaxPublic(float $optscoreMaxPublic): ScoreCache
@@ -223,7 +223,7 @@ public function setOptScoreMaxPublic(float $optscoreMaxPublic): ScoreCache
223223

224224
public function getOptScoreMaxPublic(): float
225225
{
226-
return $this->optscore_max_public;
226+
return $this->optscore_max_public ?? 0;
227227
}
228228

229229
public function setOptScoreMinRestricted(float $optscoreMinRestricted): ScoreCache
@@ -234,7 +234,7 @@ public function setOptScoreMinRestricted(float $optscoreMinRestricted): ScoreCac
234234

235235
public function getOptScoreMinRestricted(): float
236236
{
237-
return $this->optscore_min_restricted;
237+
return $this->optscore_min_restricted ?? 0;
238238
}
239239

240240
public function setOptScoreMinPublic(float $optscoreMinPublic): ScoreCache
@@ -245,7 +245,7 @@ public function setOptScoreMinPublic(float $optscoreMinPublic): ScoreCache
245245

246246
public function getOptScoreMinPublic(): float
247247
{
248-
return $this->optscore_min_public;
248+
return $this->optscore_min_public ?? 0;
249249
}
250250

251251
public function setSubmissionsPublic(int $submissionsPublic): ScoreCache
@@ -371,4 +371,20 @@ public function getIsCorrect(bool $restricted): bool
371371
{
372372
return $restricted ? $this->getIsCorrectRestricted() : $this->getIsCorrectPublic();
373373
}
374+
375+
public function getMaxOptscore(bool $restricted): float
376+
{
377+
return $restricted ? $this->getOptScoreMaxRestricted() : $this->getOptScoreMaxPublic();
378+
}
379+
380+
public function getMinOptscore(bool $restricted): float
381+
{
382+
return $restricted ? $this->getOptScoreMinRestricted() : $this->getOptScoreMinPublic();
383+
}
384+
385+
public function getOptscore(bool $restricted): float
386+
{
387+
if ($this->contest->getOptScoreOrder() == 'asc') return $this->getMinOptscore($restricted);
388+
else return $this->getMaxOptscore($restricted);
389+
}
374390
}

0 commit comments

Comments
 (0)