Skip to content

Commit

Permalink
MDL-46015 lesson: Optimise report - use recordsets
Browse files Browse the repository at this point in the history
Change-Id: I61f3ed30c6dbd8f88d1dfb1adfe2fc291853e0e1
  • Loading branch information
euven authored and Jean-Michel Vedrine committed Dec 28, 2014
1 parent eb1dc9f commit 5333943
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mod/lesson/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
ORDER BY $sort";
}

if (! $students = $DB->get_records_sql($sql, $params)) {
$students = $DB->get_recordset_sql($sql, $params);
if (!$students->valid()) {
$nothingtodisplay = true;
}

Expand All @@ -83,7 +84,8 @@

$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;
}

Expand Down Expand Up @@ -221,6 +223,7 @@
"userid" => $attempt->userid);
}
}
$attempts->close();
// set all the stats variables
$numofattempts = 0;
$avescore = 0;
Expand Down Expand Up @@ -306,6 +309,7 @@
$table->data[] = array($studentname, $attempts, $bestgrade."%");
}
}
$students->close();
// print it all out !
if (has_capability('mod/lesson:edit', $context)) {
echo "<form id=\"theform\" method=\"post\" action=\"report.php\">\n
Expand Down Expand Up @@ -535,7 +539,7 @@

$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);

Expand Down

0 comments on commit 5333943

Please sign in to comment.