Skip to content

Commit

Permalink
Test: Avoid Division By Zero
Browse files Browse the repository at this point in the history
  • Loading branch information
kergomard committed Oct 23, 2024
1 parent ef9cde5 commit 4a56a33
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function getAveragePoints(): float

public function getPercentageOfPointsAchieved(): float
{
if ($this->number_of_answers === 0) {
if ($this->number_of_answers === 0
|| $this->available_points === 0) {
return 0.0;
}
return ($this->total_achieved_points / ($this->number_of_answers * $this->available_points)) * 100;
Expand Down

0 comments on commit 4a56a33

Please sign in to comment.