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

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0
    • Fix Version/s: 3.1
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      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
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-51925-master

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Adrian Greeve
              Integrator:
              Dan Poltawski
              Tester:
              Ryan Wyllie
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                23/May/16