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

Add a new option in get_enrolled_users to sort users by different fields

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1
    • 3.0
    • Web Services
    • MOODLE_30_STABLE
    • MOODLE_31_STABLE
    • MDL-51925-master
    • Hide
      1. Create or use a course without groups enabled and more than 5 users enrolled
      2. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      3. Create a Token for one of the users enrolled:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, courseid and the URL of your moodle instance.

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=4&options%5B0%5D%5Bname%5D=limitfrom&options%5B0%5D%5Bvalue%5D=0&options%5B1%5D%5Bname%5D=limitnumber&options%5B1%5D%5Bvalue%5D=50&moodlewssettingfilter=true&wsfunction=core_enrol_get_enrolled_users&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&options%5B2%5D%5Bname%5D=sortby&options%5B2%5D%5Bvalue%5D=lastname&options%5B3%5D%5Bname%5D=sortdirection&options%5B3%5D%5Bvalue%5D=DESC' --compressed | python -m "json.tool"

      5. Confirm that you receive a list of users sorted by lastname DESC (you can | grep fullname to see only relevant information)
      6. Modify the lastname and DESC values to order by id, firstname, lastname and siteorder and check that everything works as expected (note, siteorder uses the default Moodle ordering for users so in this case the sort direction in some cases won't be used)
      7. Use incorrect values, for example DESCC for sortdirection and idnumber for sortby and check that incorrect parameter errors are returned
      Show
      Create or use a course without groups enabled and more than 5 users enrolled As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for one of the users enrolled: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student user. You need to replace the wstoken, courseid and the URL of your moodle instance. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=4&options%5B0%5D%5Bname%5D=limitfrom&options%5B0%5D%5Bvalue%5D=0&options%5B1%5D%5Bname%5D=limitnumber&options%5B1%5D%5Bvalue%5D=50&moodlewssettingfilter=true&wsfunction=core_enrol_get_enrolled_users&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&options%5B2%5D%5Bname%5D=sortby&options%5B2%5D%5Bvalue%5D=lastname&options%5B3%5D%5Bname%5D=sortdirection&options%5B3%5D%5Bvalue%5D=DESC' --compressed | python -m "json.tool" Confirm that you receive a list of users sorted by lastname DESC (you can | grep fullname to see only relevant information) Modify the lastname and DESC values to order by id, firstname, lastname and siteorder and check that everything works as expected (note, siteorder uses the default Moodle ordering for users so in this case the sort direction in some cases won't be used) Use incorrect values, for example DESCC for sortdirection and idnumber for sortby and check that incorrect parameter errors are returned

      Currently this function return users ordered by id, this is not ideal if we want to display the returned data. For example, in the Mobile app the users are not ordered alphabetically.

            jleyva Juan Leyva
            jleyva Juan Leyva
            Adrian Greeve Adrian Greeve
            Dan Poltawski Dan Poltawski
            Ryan Wyllie Ryan Wyllie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

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