MDL-47585 stats: fixed incorrect user dropdown
authorMarina Glancy <marina@moodle.com>
Thu, 9 Oct 2014 06:35:15 +0000 (14:35 +0800)
committerSam Hemelryk <sam@moodle.com>
Mon, 27 Oct 2014 21:51:02 +0000 (10:51 +1300)
report/stats/locallib.php

index 0a0b6f1..1a671c2 100644 (file)
@@ -111,7 +111,8 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
 
         list($sort, $moreparams) = users_order_by_sql('u');
         $moreparams['courseid'] = $course->id;
-        $sql = "SELECT DISTINCT u.id, u.firstname, u.lastname, u.idnumber
+        $fields = user_picture::fields('u', array('idnumber'));
+        $sql = "SELECT DISTINCT $fields
                   FROM {stats_user_{$param->table}} s
                   JOIN {user} u ON u.id = s.userid
                  WHERE courseid = :courseid";
@@ -128,9 +129,8 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
         if (!$us = $DB->get_records_sql($sql, array_merge($param->params, $moreparams))) {
             print_error('nousers');
         }
-
         foreach ($us as $u) {
-            $users[$u->userid] = fullname($u, true);
+            $users[$u->id] = fullname($u, true);
         }
 
         $table->align = array('left','left','left','left','left','left','left','left');