diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 80ecc390ac4..a0c8974dbd7 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -64,7 +64,8 @@ if (!empty($cm->groupingid)) { ORDER BY $sort"; } -if (! $students = $DB->get_records_sql($sql, $params)) { +$students = $DB->get_recordset_sql($sql, $params); +if (!$students->valid()) { $nothingtodisplay = true; } @@ -83,7 +84,8 @@ if ($action == 'reportoverview') { $lessonoutput = $PAGE->get_renderer('mod_lesson'); -if (! $attempts = $DB->get_records('lesson_attempts', array('lessonid' => $lesson->id), 'timeseen')) { +$attempts = $DB->get_recordset('lesson_attempts', array('lessonid' => $lesson->id), 'timeseen'); +if (!$attempts->valid()) { $nothingtodisplay = true; } @@ -221,6 +223,7 @@ if ($action === 'delete') { "userid" => $attempt->userid); } } + $attempts->close(); // set all the stats variables $numofattempts = 0; $avescore = 0; @@ -306,6 +309,7 @@ if ($action === 'delete') { $table->data[] = array($studentname, $attempts, $bestgrade."%"); } } + $students->close(); // print it all out ! if (has_capability('mod/lesson:edit', $context)) { echo "
\n @@ -535,7 +539,7 @@ if ($action === 'delete') { $table->data[] = array(get_string("notcompleted", "lesson")); } else { - $user = $students[$userid]; + $user = $DB->get_record('user', array('id' => $userid)); $gradeinfo = lesson_grade($lesson, $try, $user->id);