]> git.mjollnir.org Git - moodle.git/commitdiff
Applied DISTINCT as per Martin Langhoff's solution in MDL-11381
authormoodler <moodler>
Tue, 2 Oct 2007 06:18:30 +0000 (06:18 +0000)
committermoodler <moodler>
Tue, 2 Oct 2007 06:18:30 +0000 (06:18 +0000)
user/index: ensure each user appears only once in participants list

Regardless of the number of enrolments, ensure we list a single entry
per user using DISTINCT. Much easier to manage than a GROUP BY.

user/index.php

index f76090231dd7dff96c2bbd431297ac99c8617dce..c637b8422e0cf12a53f435143797a910131d9f05 100644 (file)
     }
     
     if ($context->id != $frontpagectx->id) {
-        $select = 'SELECT u.id, u.username, u.firstname, u.lastname,
+        $select = 'SELECT DISTINCT u.id, u.username, u.firstname, u.lastname,
                       u.email, u.city, u.country, u.picture,
                       u.lang, u.timezone, u.emailstop, u.maildisplay, u.imagealt,
                       COALESCE(ul.timeaccess, 0) AS lastaccess,
                       ctx.depth AS ctxdepth, ctx.contextlevel AS ctxlevel ';    
         $select .= $course->enrolperiod?', r.timeend ':'';
     } else {
-        $select = 'SELECT u.id, u.username, u.firstname, u.lastname,
+        $select = 'SELECT DISTINCT u.id, u.username, u.firstname, u.lastname,
                       u.email, u.city, u.country, u.picture,
                       u.lang, u.timezone, u.emailstop, u.maildisplay, u.imagealt,
                       u.lastaccess,