Skip to content
Snippets Groups Projects
Commit 9237bddf authored by Sivaji Ganesh Jojodae's avatar Sivaji Ganesh Jojodae
Browse files

Fix #489040 warning: Division by zero in long_answer and short_answer module...

Fix #489040 warning: Division by zero in long_answer and short_answer module when the max score is 0.
parent fee37fc1
No related branches found
No related tags found
No related merge requests found
......@@ -208,7 +208,8 @@ class LongAnswerResponse extends AbstractQuizQuestionResponse {
public function isCorrect() {
$possible = _quiz_question_get_instance($this->question)->getMaximumScore();
$actual = $this->score;
// To prevent Division by zero warning
$possible = ($possible == 0) ? 1 : $possible;
return (($actual / $possible) * 100 > 50);
}
......@@ -217,7 +218,7 @@ class LongAnswerResponse extends AbstractQuizQuestionResponse {
}
public function formatReport($showpoints = TRUE, $showfeedback = TRUE) {
$slug = '<div class="quiz_summary_question"><span class="quiz_question_bullet">Q:</span> '.
check_markup($this->question->body, $this->question->filter) .
'</div>';
......
......@@ -337,12 +337,15 @@ class ShortAnswerResponse extends AbstractQuizQuestionResponse {
$this->score = $score;
return $score;
}
public function isCorrect() {
$possible = _quiz_question_get_instance($this->question)->getMaximumScore();
$actual = $this->score;
// To prevent Division by zero warning
$possible = ($possible == 0) ? 1 : $possible;
return (($actual / $possible) > 0.5);
}
public function getResponse() {
return $this->answer;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment