DivisionByZero error

Created on 1 November 2024, 4 months ago

Problem/Motivation

Same as described in https://www.drupal.org/project/quiz/issues/3346955 πŸ› Division by Zero while using getWeightedRatio() method Active (which was closed). The getWeightedRatio function doesn't check if the quiz question max score is 0 and therefore sometimes leads to diving by 0 and the error is thrown.

DivisionByZeroError: Division by zero in Drupal\quiz\Entity\QuizResultAnswer->getWeightedRatio() (line 219 of /var/www/web/modules/composer/quiz/src/Entity/QuizResultAnswerEntityTrait.php).

Steps to reproduce

  • Install Quiz module
  • Create quiz with Long Answer Question - giving a score of 10 and checking Auto Max Score
  • Take the quiz, observe WSOD and refer to logs for message

Proposed resolution

Code should check if either value in the division process is 0 before calculating.

πŸ› Bug report
Status

Active

Version

7.0

Component

Code - Quiz core

Created by

πŸ‡ΊπŸ‡ΈUnited States nsciacca

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024