From 5e54da0a69ba059028353174e7257e4bebdd03ab Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 15 Aug 2011 18:47:03 +0100 Subject: [PATCH] MDL-21934 Removing all questions from the quiz should not delet overall feedback. Overall feedback was being wiped because the quiz max grade was being set to zero when sumgrades was set to 0. The correct logic is to only set maxgrade to 0 if there are questions in the quiz and sumgrades is 0. --- mod/quiz/locallib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 601f9a5a175..7243170deb9 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -414,7 +414,9 @@ function quiz_update_sumgrades($quiz) { WHERE id = ?'; $DB->execute($sql, array($quiz->id)); $quiz->sumgrades = $DB->get_field('quiz', 'sumgrades', array('id' => $quiz->id)); - if ($quiz->sumgrades < 0.000005) { + if ($quiz->sumgrades < 0.000005 && quiz_clean_layout($quiz->questions, true)) { + // If there is at least one question in the quiz, and the sumgrades has been + // set to 0, then also set the maximum possible grade to 0. quiz_set_grade(0, $quiz); } }