Skip to content

Commit

Permalink
MDL-31143 quiz reports: average grade of null causes php error.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Jan 12, 2012
1 parent c1dc3a5 commit 9d2921b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mod/quiz/report/overview/overview_table.php
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 9d2921b

Please sign in to comment.