diff --git a/webapp/src/Service/ScoreboardService.php b/webapp/src/Service/ScoreboardService.php index e1292937b5..f7f870dd95 100644 --- a/webapp/src/Service/ScoreboardService.php +++ b/webapp/src/Service/ScoreboardService.php @@ -554,7 +554,7 @@ public function updateRankCache(Contest $contest, Team $team): void } } - const SCALE = 9; + public const SCALE = 9; // Converts integer or bcmath floats to a string that can be used as a key in a score cache. // The resulting key will be a string with 33 characters, 23 before the decimal dot and 9 after. diff --git a/webapp/src/Utils/Scoreboard/Scoreboard.php b/webapp/src/Utils/Scoreboard/Scoreboard.php index b0e53fce1b..7773939f88 100644 --- a/webapp/src/Utils/Scoreboard/Scoreboard.php +++ b/webapp/src/Utils/Scoreboard/Scoreboard.php @@ -5,6 +5,7 @@ use App\Entity\Contest; use App\Entity\ContestProblem; use App\Entity\RankCache; +use App\Entity\ScoreboardType; use App\Entity\ScoreCache; use App\Entity\Team; use App\Entity\TeamCategory; @@ -152,22 +153,32 @@ protected function calculateScoreboard(): void !array_key_exists($probId, $this->problems)) { continue; } + $isCorrect = $scoreCell->getIsCorrect($this->restricted); $penalty = Utils::calcPenaltyTime( - $scoreCell->getIsCorrect($this->restricted), + $isCorrect, $scoreCell->getSubmissions($this->restricted), $this->penaltyTime, $this->scoreIsInSeconds ); + $contestProblem = $scoreCell->getContest()->getContestProblem($scoreCell->getProblem()); + // TODO: For actual scoring problems, we need to calculate the score here and + // output it with the correct precision. For now, this is always an integer. + $points = strval( + $isCorrect ? + $contestProblem->getPoints() : 0 + ); + $this->matrix[$teamId][$probId] = new ScoreboardMatrixItem( - isCorrect: $scoreCell->getIsCorrect($this->restricted), - isFirst: $scoreCell->getIsCorrect($this->restricted) && $scoreCell->getIsFirstToSolve(), + isCorrect: $isCorrect, + isFirst: $isCorrect && $scoreCell->getIsFirstToSolve(), numSubmissions: $scoreCell->getSubmissions($this->restricted), numSubmissionsPending: $scoreCell->getPending($this->restricted), time: $scoreCell->getSolveTime($this->restricted), penaltyTime: $penalty, runtime: $scoreCell->getRuntime($this->restricted), numSubmissionsInFreeze: $scoreCell->getPending(false), + points: $points, ); } @@ -257,6 +268,11 @@ public function showPoints(): bool return false; } + public function isScoring(): bool + { + return $this->contest->getScoreboardType() === ScoreboardType::SCORING; + } + /** * Return the used team categories for this scoreboard. * diff --git a/webapp/src/Utils/Scoreboard/ScoreboardMatrixItem.php b/webapp/src/Utils/Scoreboard/ScoreboardMatrixItem.php index d1df0cd422..2683d789e9 100644 --- a/webapp/src/Utils/Scoreboard/ScoreboardMatrixItem.php +++ b/webapp/src/Utils/Scoreboard/ScoreboardMatrixItem.php @@ -13,5 +13,6 @@ public function __construct( public int $penaltyTime, public int $runtime, public ?int $numSubmissionsInFreeze = null, + public string $points = "", ) {} } diff --git a/webapp/templates/partials/scoreboard_summary.html.twig b/webapp/templates/partials/scoreboard_summary.html.twig index 2ba3c08ebf..c5811b9436 100644 --- a/webapp/templates/partials/scoreboard_summary.html.twig +++ b/webapp/templates/partials/scoreboard_summary.html.twig @@ -23,7 +23,9 @@ {{ scoreboard.summary.numberOfPoints(sortOrder) }} {% endif %} - + {% if not scoringScoreboard %} + + {% endif %} {% endif %} {% for problem in scoreboard.problems %} {% set summary = scoreboard.summary.problem(problem.probid) %} diff --git a/webapp/templates/partials/scoreboard_table.html.twig b/webapp/templates/partials/scoreboard_table.html.twig index 6b2da2f314..1503c978f0 100644 --- a/webapp/templates/partials/scoreboard_table.html.twig +++ b/webapp/templates/partials/scoreboard_table.html.twig @@ -14,6 +14,7 @@ {% set static = false %} {% endif %} {% set showPoints = scoreboard.showPoints %} +{% set scoringScoreboard = scoreboard.isScoring %} {% set usedCategories = scoreboard.usedCategories(limitToTeamIds) %} {% set hasDifferentCategoryColors = scoreboard.categoryColors(limitToTeamIds) %} {% set scores = scoreboard.scores | filter(score => limitToTeams is null or score.team.teamid in limitToTeamIds) %} @@ -62,7 +63,9 @@ {% if enable_ranking %} - + {% if not scoringScoreboard %} + + {% endif %} {% endif %} @@ -79,7 +82,11 @@ {% endif %} team {% if enable_ranking %} - score + {% if scoringScoreboard %} + score + {% else %} + score + {% endif %} {% endif %} {% if showTeamSubmissions or jury %} {% for problem in problems %} @@ -101,7 +108,8 @@ {{ problem | problemBadge }} - {% if showPoints %} + {% if showPoints and not scoringScoreboard %} +
[{% if problem.points == 1 %}1 point{% else %}{{ problem.points }} points{% endif %}] @@ -248,10 +256,12 @@ {% if enable_ranking %} {% set totalPoints = score.numPoints %} {{ totalPoints }} - {% if scoreboard.getRuntimeAsScoreTiebreaker() %} - {{ "%0.3f s" | format(score.totalRuntime/1000.0) }} - {% else %} - {{ totalTime }} + {% if not scoringScoreboard %} + {% if scoreboard.getRuntimeAsScoreTiebreaker() %} + {{ "%0.3f s" | format(score.totalRuntime/1000.0) }} + {% else %} + {{ totalTime }} + {% endif %} {% endif %} {% endif %} @@ -311,8 +321,17 @@ {% if numSubmissions != '0' %}
-
- {% if matrixItem.isCorrect %}{{ time }}{% else %} {% endif %} +
+ {% if scoringScoreboard %} + {% if matrixItem.isCorrect %}{{ matrixItem.points }}{% else %} {% endif %} + {% else %} + {% if matrixItem.isCorrect %}{{ time }}{% else %} {% endif %} + {% endif %} {% if numSubmissions is same as(1) %} 1 try diff --git a/webapp/tests/Unit/Service/AwardServiceTest.php b/webapp/tests/Unit/Service/AwardServiceTest.php index b4a33fd7e9..12a250f7bc 100644 --- a/webapp/tests/Unit/Service/AwardServiceTest.php +++ b/webapp/tests/Unit/Service/AwardServiceTest.php @@ -82,6 +82,7 @@ protected function setUp(): void ) ->setContest($this->contest) ->setShortname($problemLabel); + $this->contest->addProblem($problem); $reflectedProblem = new ReflectionClass(Problem::class); $probIdProperty = $reflectedProblem->getProperty('probid'); $probIdProperty->setAccessible(true); diff --git a/webapp/tests/Unit/Service/ImportExportServiceTest.php b/webapp/tests/Unit/Service/ImportExportServiceTest.php index e7cc24a9e5..801b91459f 100644 --- a/webapp/tests/Unit/Service/ImportExportServiceTest.php +++ b/webapp/tests/Unit/Service/ImportExportServiceTest.php @@ -1252,6 +1252,7 @@ public function testGetResultsData(bool $full, bool $honors, string $dataSet, st ->setShortname($problemData['label']); $em->persist($problem); $em->persist($contestProblem); + $contest->addProblem($contestProblem); $em->flush(); $contestProblemsById[$contestProblem->getExternalid()] = $contestProblem; }