MDL-37527 Assignment - Change query for print_overview so it uses an index (postgres)
authorDamyon Wiese <damyon@moodle.com>
Wed, 16 Jan 2013 04:26:23 +0000 (12:26 +0800)
committerDamyon Wiese <damyon@moodle.com>
Wed, 16 Jan 2013 05:20:27 +0000 (13:20 +0800)
Reported by Mark Neilsen.

mod/assign/lib.php

index e2d7e01..81c9456 100644 (file)
@@ -358,7 +358,7 @@ function assign_print_overview($courses, &$htmlarray) {
     $rs->close();
 
     // Get all user submissions, indexed by assignment id.
-    $dbparams = array_merge(array($USER->id, $USER->id), $assignmentidparams);
+    $dbparams = array($USER->id, $USER->id);
     $mysubmissions = $DB->get_records_sql('SELECT
                                                a.id AS assignment,
                                                a.nosubmissions AS nosubmissions,
@@ -372,8 +372,8 @@ function assign_print_overview($courses, &$htmlarray) {
                                                g.userid = ?
                                            LEFT JOIN {assign_submission} s ON
                                                s.assignment = a.id AND
-                                               s.userid = ? AND
-                                               a.id ' . $sqlassignmentids, $dbparams);
+                                               s.userid = ?
+                                           WHERE a.id ' . $sqlassignmentids, $dbparams);
 
     foreach ($assignments as $assignment) {
         // Do not show assignments that are not open.