gradebook MDL-25769 fixed some problems identified by peer review
authorandyjdavis <andrew@moodle.com>
Fri, 7 Jan 2011 02:02:31 +0000 (10:02 +0800)
committerSam Hemelryk <sam@moodle.com>
Tue, 18 Jan 2011 03:56:06 +0000 (11:56 +0800)
grade/import/lib.php
grade/report/grader/lib.php

index 5c438ee..8d7463b 100644 (file)
@@ -167,7 +167,8 @@ function get_unenrolled_users_in_import($importcode, $courseid) {
     list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr0');
 
     //enrolled users
-    list($enrolledsql, $enrolledparams) = get_enrolled_sql($this->context);
+    $context = get_context_instance(CONTEXT_COURSE, $courseid);
+    list($enrolledsql, $enrolledparams) = get_enrolled_sql($context);
 
     $sql = "SELECT giv.id, u.firstname, u.lastname, u.idnumber AS useridnumber,
                 COALESCE(gi.idnumber, gin.itemname) AS gradeidnumber
@@ -175,7 +176,7 @@ function get_unenrolled_users_in_import($importcode, $courseid) {
                 {grade_import_values} giv
                 JOIN {user} u ON giv.userid = u.id
                 LEFT JOIN {grade_items} gi ON gi.id = giv.itemid
-                LEFT JOIN {grade_import_newitem} gin ON gin.id = giv.newgradeitem                
+                LEFT JOIN {grade_import_newitem} gin ON gin.id = giv.newgradeitem
                 LEFT JOIN ($enrolledsql) je ON je.id = u.id
                 LEFT JOIN {role_assignments} ra ON (giv.userid = ra.userid AND
                     ra.roleid $gradebookrolessql AND
@@ -183,9 +184,10 @@ function get_unenrolled_users_in_import($importcode, $courseid) {
                 WHERE giv.importcode = ?
                     AND (ra.id IS NULL OR je.id IS NULL)
                 ORDER BY gradeidnumber, u.lastname, u.firstname";
+    $params = array_merge($gradebookrolesparams, $enrolledparams);
     $params[] = $importcode;
 
-    return $DB->get_records_sql($sql, array_merge($gradebookrolesparams, $enrolledparams));
+    return $DB->get_records_sql($sql, $params);
 }
 
 /**
index 65c274a..e90c491 100644 (file)
@@ -1311,7 +1311,6 @@ class grade_report_grader extends grade_report {
 
             // MDL-10875 Empty grades must be evaluated as grademin, NOT always 0
             // This query returns a count of ungraded grades (NULL finalgrade OR no matching record in grade_grades table)
-            $params = array_merge(array('courseid'=>$this->courseid), $params);
             $SQL = "SELECT gi.id, COUNT(u.id) AS count
                       FROM {grade_items} gi
                            CROSS JOIN {user} u