MDL-61421 cohort: Fix cohort_role_sync when a user is in two cohorts
authorSara Arjona <sara@moodle.com>
Mon, 12 Feb 2018 07:55:38 +0000 (08:55 +0100)
committerSara Arjona <sara@moodle.com>
Mon, 12 Feb 2018 07:55:38 +0000 (08:55 +0100)
admin/tool/cohortroles/classes/api.php

index 8357e70..b3f0e54 100644 (file)
@@ -167,7 +167,7 @@ class api {
                 $params['roleid'] = $roleid;
                 $params['userid'] = $userid;
 
-                $sql = 'SELECT u.id AS userid, ra.id, ctx.id AS contextid
+                $sql = 'SELECT DISTINCT u.id AS userid, ra.id, ctx.id AS contextid
                           FROM {user} u
                           JOIN {cohort_members} cm ON u.id = cm.userid
                           JOIN {context} ctx ON u.id = ctx.instanceid AND ctx.contextlevel = :usercontext