Permalink
Browse files

MDL-21934 Removing all questions from the quiz should not delet overa…

…ll 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.
  • Loading branch information...
1 parent 3a5778e commit 5e54da0a69ba059028353174e7257e4bebdd03ab @timhunt timhunt committed Aug 15, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 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);
}
}

0 comments on commit 5e54da0

Please sign in to comment.