From a8ab2cef73f0ea0e96520e547977bf1de1601d43 Mon Sep 17 00:00:00 2001 From: Matt Young Date: Mon, 20 Jan 2025 11:15:32 -0600 Subject: [PATCH] Fix division by 0 issue in scoring --- .../CalculateScoreSheetTotalDivideByWeightedPossible.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Actions/Tabulation/CalculateScoreSheetTotalDivideByWeightedPossible.php b/app/Actions/Tabulation/CalculateScoreSheetTotalDivideByWeightedPossible.php index c13c223..55107bc 100644 --- a/app/Actions/Tabulation/CalculateScoreSheetTotalDivideByWeightedPossible.php +++ b/app/Actions/Tabulation/CalculateScoreSheetTotalDivideByWeightedPossible.php @@ -48,7 +48,11 @@ class CalculateScoreSheetTotalDivideByWeightedPossible implements CalculateScore $weightsTotal += $weight; $weightedMaxPossible += $maxPossible; } - $finalScore = ($scoreTotal / $weightedMaxPossible) * 100; + if ($weightedMaxPossible > 0) { + $finalScore = ($scoreTotal / $weightedMaxPossible) * 100; + } else { + $finalScore = 0; + } // put $final score at the beginning of the $ScoreArray array_unshift($scoreArray, $finalScore);