MDL-24690 fixed incorrect cohort condition when auto-creating groups
[moodle.git] / group / lib.php
index cdfa2e5..8fd4c12 100644 (file)
@@ -542,8 +542,8 @@ function groups_get_potential_members($courseid, $roleid = null, $cohortid = nul
     }
 
     if ($cohortid) {
-        $cohortjoin = "JOIN {cohort_members} cm ON cm.userid = u.id
-                       JOIN {cohort} c ON c.id = cm.cohortid";
+        $cohortjoin = "JOIN {cohort_members} cm ON (cm.userid = u.id AND cm.cohortid = :cohortid)";
+        $params['cohortid'] = $cohortid;
     } else {
         $cohortjoin = "";
     }