Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31143 quiz reports: average grade of null causes php error.

  • Loading branch information...
commit b3c02fae5497a3b134e3196781e947ea8bffb4ff 1 parent f70f6e9
Tim Hunt authored January 12, 2012
6  mod/quiz/report/overview/overview_table.php
@@ -81,7 +81,7 @@ protected function add_average_row($label, $users) {
81 81
                 SELECT AVG(quiza.sumgrades) AS grade, COUNT(quiza.sumgrades) AS numaveraged
82 82
                   FROM $from
83 83
                  WHERE $where", $params);
84  
-        $record->grade = quiz_rescale_grade($record->grade, $this->quiz);
  84
+        $record->grade = quiz_rescale_grade($record->grade, $this->quiz, false);
85 85
 
86 86
         if ($this->is_downloading()) {
87 87
             $namekey = 'lastname';
@@ -127,7 +127,7 @@ protected function format_average_grade_for_questions($gradeaverages) {
127 127
             } else {
128 128
                 $record = new stdClass();
129 129
                 $record->grade = null;
130  
-                $record->numaveraged = null;
  130
+                $record->numaveraged = 0;
131 131
             }
132 132
 
133 133
             $row['qsgrade' . $question->slot] = $this->format_average($record, true);
@@ -151,7 +151,7 @@ protected function format_average($record, $question = false) {
151 151
 
152 152
         if ($this->download) {
153 153
             return $average;
154  
-        } else if (is_null($record->numaveraged)) {
  154
+        } else if (is_null($record->numaveraged) || $record->numaveraged == 0) {
155 155
             return html_writer::tag('span', html_writer::tag('span',
156 156
                     $average, array('class' => 'average')), array('class' => 'avgcell'));
157 157
         } else {

0 notes on commit b3c02fa

Please sign in to comment.
Something went wrong with that request. Please try again.