Permalink
Browse files

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

  • Loading branch information...
1 parent c1dc3a5 commit 9d2921b9304cd729ab5682973f3179312e11c124 @timhunt timhunt committed Jan 12, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 mod/quiz/report/overview/overview_table.php
@@ -81,7 +81,7 @@ protected function add_average_row($label, $users) {
SELECT AVG(quiza.sumgrades) AS grade, COUNT(quiza.sumgrades) AS numaveraged
FROM $from
WHERE $where", $params);
- $record->grade = quiz_rescale_grade($record->grade, $this->quiz);
+ $record->grade = quiz_rescale_grade($record->grade, $this->quiz, false);
if ($this->is_downloading()) {
$namekey = 'lastname';
@@ -127,7 +127,7 @@ protected function format_average_grade_for_questions($gradeaverages) {
} else {
$record = new stdClass();
$record->grade = null;
- $record->numaveraged = null;
+ $record->numaveraged = 0;
}
$row['qsgrade' . $question->slot] = $this->format_average($record, true);
@@ -151,7 +151,7 @@ protected function format_average($record, $question = false) {
if ($this->download) {
return $average;
- } else if (is_null($record->numaveraged)) {
+ } else if (is_null($record->numaveraged) || $record->numaveraged == 0) {
return html_writer::tag('span', html_writer::tag('span',
$average, array('class' => 'average')), array('class' => 'avgcell'));
} else {

0 comments on commit 9d2921b

Please sign in to comment.