MDL-30144 Assignment 2.2: Download all as zip should only contain submission from...
authorMichael Hughes <michaelhughes@strath.ac.uk>
Fri, 1 Feb 2013 06:49:55 +0000 (14:49 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 4 Feb 2013 05:55:38 +0000 (13:55 +0800)
mod/assignment/lib.php

index 3688ac9..6544c0e 100644 (file)
@@ -3553,12 +3553,15 @@ function assignment_get_all_submissions($assignment, $sort="", $dir="DESC") {
     if ($assignment->course == SITEID) {
         $select = '';
     }*/
-
+    $context = context_module::instance($assignment->id);
+    list($enroledsql, $params) = get_enrolled_sql($context, 'mod/assignment:submit');
+    $params['assignmentid'] = $assignment->id;
     return $DB->get_records_sql("SELECT a.*
-                                   FROM {assignment_submissions} a, {user} u
+                                    FROM {assignment_submissions} a
+                                    INNER JOIN (". $enroledsql .") u ON u.id = a.userid
                                   WHERE u.id = a.userid
-                                        AND a.assignment = ?
-                               ORDER BY $sort", array($assignment->id));
+                                        AND a.assignment = :assignmentid
+                                  ORDER BY $sort", $params);
 
 }