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

This commit is contained in:
Tim Hunt 2012-01-12 16:42:19 +00:00 committed by kordan
parent f572ec93af
commit abd738223c

View file

@ -81,7 +81,7 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
SELECT AVG(quiza.sumgrades) AS grade, COUNT(quiza.sumgrades) AS numaveraged SELECT AVG(quiza.sumgrades) AS grade, COUNT(quiza.sumgrades) AS numaveraged
FROM $from FROM $from
WHERE $where", $params); 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()) { if ($this->is_downloading()) {
$namekey = 'lastname'; $namekey = 'lastname';
@ -127,7 +127,7 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
} else { } else {
$record = new stdClass(); $record = new stdClass();
$record->grade = null; $record->grade = null;
$record->numaveraged = null; $record->numaveraged = 0;
} }
$row['qsgrade' . $question->slot] = $this->format_average($record, true); $row['qsgrade' . $question->slot] = $this->format_average($record, true);
@ -151,7 +151,7 @@ class quiz_report_overview_table extends quiz_attempt_report_table {
if ($this->download) { if ($this->download) {
return $average; 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', return html_writer::tag('span', html_writer::tag('span',
$average, array('class' => 'average')), array('class' => 'avgcell')); $average, array('class' => 'average')), array('class' => 'avgcell'));
} else { } else {