Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-67003

Course participants list not showing a student (database sort problem)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not a bug
    • Icon: Major Major
    • None
    • 3.7
    • User management
    • MOODLE_37_STABLE

      There is a problem with PostgreSQL (probably other DBs also) that it will not grantee consistent sort no matter what LIMIT/OFFSET combination is used. This can cause problems in course participants list if there are students with the same name and they are needed to be split on two pages. It can cause the same student to be shown as last entry on first page and then first entry on second page.

      This problem is bit hard to reproduce as it's a problem with PostgreSQL. In attached pics it is visible directly from SQL query results (removed user info because of user privacy).

      Fix is very simple, just add sort by ID as second parameter in user/lib.php in function user_get_participants:

      function user_get_participants($courseid, $groupid = 0, $accesssince, $roleid, $enrolid = 0, $statusid, $search,function user_get_participants($courseid, $groupid = 0, $accesssince, $roleid, $enrolid = 0, $statusid, $search,                               $additionalwhere = '', $additionalparams = array(), $sort = '', $limitfrom = 0, $limitnum = 0) {
          global $DB;
          list($select, $from, $where, $params) = user_get_participants_sql($courseid, $groupid, $accesssince, $roleid, $enrolid,
              $statusid, $search, $additionalwhere, $additionalparams);
       
        if($sort != ''){ 
           $sort .= ', id'; 
        }
          return $DB->get_recordset_sql("$select $from $where $sort", $params, $limitfrom, $limitnum);
      }

       
      In screenshots take not of id 75462 and where it appears of first 3 pics depending on LIMIT/OFFSET combinations. With sort only by firstname there is no way to list user with id 80380 when listing pages.

        1. a.PNG
          a.PNG
          19 kB
        2. a.PNG
          a.PNG
          19 kB
        3. b.PNG
          b.PNG
          98 kB
        4. b.PNG
          b.PNG
          98 kB
        5. b.PNG
          b.PNG
          98 kB
        6. pic1.jpg
          pic1.jpg
          166 kB
        7. pic2.jpg
          pic2.jpg
          163 kB
        8. pic3.jpg
          pic3.jpg
          169 kB
        9. pic4.jpg
          pic4.jpg
          166 kB
        10. pic5.jpg
          pic5.jpg
          169 kB

            Unassigned Unassigned
            zmartinovic Zvonko Martinovic
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.