From b7ab57f3afe25e94564bc5d4def9a499dcd4ee5b Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 18 Jan 2012 17:32:00 +0000 Subject: [PATCH] MDL-30033 quiz overall feedback not show for attempts with a -ve grade This can happen, for example, if a student does really badly on a CBM quiz. --- mod/quiz/locallib.php | 4 ++++ mod/quiz/report/reportlib.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index e47522d09e7..63d82b678f4 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -353,6 +353,10 @@ function quiz_feedback_for_grade($grade, $quiz, $context) { return ''; } + // With CBM etc, it is possible to get -ve grades, which would then not match + // any feedback. Therefore, we replace -ve grades with 0. + $grade = max($grade, 0); + $feedback = $DB->get_record_select('quiz_feedback', 'quizid = ? AND mingrade <= ? AND ? < maxgrade', array($quiz->id, $grade, $grade)); diff --git a/mod/quiz/report/reportlib.php b/mod/quiz/report/reportlib.php index 53fa2b6763d..8154d4dfd4a 100644 --- a/mod/quiz/report/reportlib.php +++ b/mod/quiz/report/reportlib.php @@ -265,6 +265,10 @@ function quiz_report_feedback_for_grade($grade, $quizid, $context) { $feedbackcache[$quizid] = $DB->get_records('quiz_feedback', array('quizid' => $quizid)); } + // With CBM etc, it is possible to get -ve grades, which would then not match + // any feedback. Therefore, we replace -ve grades with 0. + $grade = max($grade, 0); + $feedbacks = $feedbackcache[$quizid]; $feedbackid = 0; $feedbacktext = '';