From 264239449ab57ee8438cf330f8c38c0c4bc51838 Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Thu, 27 Feb 2025 18:48:32 +0000 Subject: [PATCH] Render contest validation errors more nicely. Fixes #2891 --- webapp/src/Service/CheckConfigService.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/webapp/src/Service/CheckConfigService.php b/webapp/src/Service/CheckConfigService.php index 26a43c9ac7..de57fdd7c6 100644 --- a/webapp/src/Service/CheckConfigService.php +++ b/webapp/src/Service/CheckConfigService.php @@ -472,16 +472,23 @@ public function checkContestsValidate(): ConfigCheckItem foreach ($contest->getProblems() as $cp) { if (empty($cp->getColor())) { $result = ($result === 'E' ? 'E' : 'W'); - $cperrors[$cid] .= "No color for problem " . $cp->getShortname() . " in contest c" . $cid . "\n"; + $cperrors[$cid] .= " - No color for problem " . $cp->getShortname() . " in contest c" . $cid . "\n"; } } } $desc = ''; foreach ($contesterrors as $cid => $errors) { - $desc .= "Contest: c$cid: " . - /* @phpstan-ignore-next-line */ - (count($errors) == 0 ? 'no errors' : (string)$errors) ."\n" .$cperrors[$cid]; + $desc .= "Contest: c$cid: "; + if (count($errors) == 0 && empty($cperrors[$cid])) { + $desc .= "no errors\n"; + } else { + $desc .= "errors:\n"; + foreach ($errors as $error) { + $desc .= " - " . $error->getPropertyPath() . ": " . $error->getMessage() . "\n"; + } + $desc .= $cperrors[$cid]; + } } $this->stopwatch->stop(__FUNCTION__);