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

Remove unnecessary enrolledusercount from enrol_get_users_courses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.7
    • 3.6.2
    • Web Services
    • MOODLE_36_STABLE
    • MOODLE_37_STABLE
    • MDL-64886_master
    • Hide
      1. Go to Site Administration > Plugins > Web Services > Manage Tokens
      2. Click "Add" at the bottom of the page, and generate a web service token for a user, for the Moodle Mobile web service.
      3. Open your terminal.
      4. Run the following curl command (substituting the approrpiate values for the parts in CAPITALS):

        curl 'YOURMOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_enrol_get_users_courses&wstoken=WEBSERVICETOKEN&userid=USERID' | python -m "json.tool"
        

      5. Confirm that the result for each course does contain a field called "enrolledusercount"
      6. Run the following curl command with the "returnusercount" parameter set to 1:

        curl 'YOURMOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_enrol_get_users_courses&wstoken=WEBSERVICETOKEN&userid=USERID&returnusercount=1' | python -m "json.tool"
        

      7. Confirm that the result for each course does contain a field called "enrolledusercount"
      8. Run the following curl command with the "returnusercount" parameter set to 0:

        curl 'YOURMOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_enrol_get_users_courses&wstoken=WEBSERVICETOKEN&userid=USERID&returnusercount=0' | python -m "json.tool"
        

      9. Confirm that the result for each course does not contain a field called "enrolledusercount"
      Show
      Go to Site Administration > Plugins > Web Services > Manage Tokens Click "Add" at the bottom of the page, and generate a web service token for a user, for the Moodle Mobile web service. Open your terminal. Run the following curl command (substituting the approrpiate values for the parts in CAPITALS): curl 'YOURMOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_enrol_get_users_courses&wstoken=WEBSERVICETOKEN&userid=USERID' | python -m "json.tool" Confirm that the result for each course does contain a field called "enrolledusercount" Run the following curl command with the "returnusercount" parameter set to 1: curl 'YOURMOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_enrol_get_users_courses&wstoken=WEBSERVICETOKEN&userid=USERID&returnusercount=1' | python -m "json.tool" Confirm that the result for each course does contain a field called "enrolledusercount" Run the following curl command with the "returnusercount" parameter set to 0: curl 'YOURMOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_enrol_get_users_courses&wstoken=WEBSERVICETOKEN&userid=USERID&returnusercount=0' | python -m "json.tool" Confirm that the result for each course does not contain a field called "enrolledusercount"

      We have had some issues with the mobile app web service requests for enrol_get_users_courses timing out when the user first logs in.

      One of the issues we have identified is the query to count the number if users on each course the user is enrolled on.  As an example, we have a course with about 32000 users on (not our largest course), for which this query takes about half a second to complete. Given that the app times out the web service call after 30 seconds, doing this for several courses can take a significant amount of time.  The result of this query is not actually used in the app, so we should remove it if possible.

      The only issue with this would be if anyone is using this web service for something other than the mobile app, which might then be actually using the enrolled user count. However we're not aware of anything so it seems a bit pointless to have it in there just in case anyone might use it, given the performance cost.

            marxjohnson Mark Johnson
            marxjohnson Mark Johnson
            Sam Marshall Sam Marshall
            Andrew Lyons Andrew Lyons
            Jennifer Bauzon Jennifer Bauzon
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours
                2h

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