From 84fde36933dce4896b843b2c551f41d0798f3d6e Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Fri, 28 Feb 2025 12:08:47 +0000 Subject: [PATCH] Handle problemBadges for problems w/o explicit color gracefully. --- webapp/src/Twig/TwigExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/Twig/TwigExtension.php b/webapp/src/Twig/TwigExtension.php index 5ed73d6f14..f66a0acff9 100644 --- a/webapp/src/Twig/TwigExtension.php +++ b/webapp/src/Twig/TwigExtension.php @@ -1147,7 +1147,7 @@ public function fileTypeIcon(string $type): string public function problemBadge(ContestProblem $problem, bool $grayedOut = false): string { $rgb = Utils::convertToHex($problem->getColor() ?? '#ffffff'); - if ($grayedOut) { + if ($grayedOut || empty($rgb)) { $rgb = Utils::convertToHex('whitesmoke'); } $background = Utils::parseHexColor($rgb); @@ -1177,7 +1177,7 @@ public function problemBadge(ContestProblem $problem, bool $grayedOut = false): public function problemBadgeMaybe(ContestProblem $problem, ScoreboardMatrixItem $matrixItem): string { $rgb = Utils::convertToHex($problem->getColor() ?? '#ffffff'); - if (!$matrixItem->isCorrect) { + if (!$matrixItem->isCorrect || empty($rgb)) { $rgb = Utils::convertToHex('whitesmoke'); } $background = Utils::parseHexColor($rgb);