Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit b6e71d5

Browse files
committed
fix(overview): Handle totalQuestions == 0 case
1 parent 6fb712d commit b6e71d5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Controller/OverviewCardsController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ public function level(
6464
$solvedQuestions = $solutionEventRepository->findSolvedQuestions($user);
6565
$totalQuestions = $questionRepository->count();
6666

67+
if (0 === $totalQuestions) {
68+
return $this->render('overview/cards/level.html.twig', [
69+
'level' => Level::cases()[0],
70+
'rawLevelIndex' => 0,
71+
]);
72+
}
73+
6774
$solvedQuestionPercent = \count($solvedQuestions) / $totalQuestions;
6875
$levelIndex = ceil(\count(Level::cases()) * $solvedQuestionPercent);
6976

0 commit comments

Comments
 (0)