Merge branch 'MDL-61951-master' of git://github.com/sarjona/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 11 May 2018 11:21:58 +0000 (13:21 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Fri, 11 May 2018 11:21:58 +0000 (13:21 +0200)
grade/grading/classes/privacy/provider.php

index 73f632f..490cc79 100644 (file)
@@ -160,18 +160,22 @@ class provider implements
             $params['raterid'] = $userid;
         }
 
-        $sql = "SELECT DISTINCT d.id,
-                                d.method,
-                                d.name,
-                                d.description,
-                                d.timecopied,
-                                d.timecreated,
-                                d.usercreated,
-                                d.timemodified,
-                                d.usermodified
-                           FROM {grading_definitions} d
-                           $join
-                           WHERE $select";
+        $sql = "SELECT gd.id,
+                       gd.method,
+                       gd.name,
+                       gd.description,
+                       gd.timecopied,
+                       gd.timecreated,
+                       gd.usercreated,
+                       gd.timemodified,
+                       gd.usermodified
+                  FROM (
+                        SELECT DISTINCT d.id
+                                   FROM {grading_definitions} d
+                                  $join
+                                  WHERE $select
+                  ) ids
+                  JOIN {grading_definitions} gd ON gd.id = ids.id";
         $definitions = $DB->get_recordset_sql($sql, $params);
         $defdata = [];
         foreach ($definitions as $definition) {