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

Remove unnecessary enrolledusercount from enrol_get_users_courses

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.2
    • Fix Version/s: 3.7
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      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"
    • Affected Branches:
      MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull Master Branch:
      MDL-64886_master

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              marxjohnson Mark Johnson
              Reporter:
              marxjohnson Mark Johnson
              Peer reviewer:
              Sam Marshall Sam Marshall
              Integrator:
              Andrew Lyons Andrew Lyons
              Tester:
              Jennifer Bauzon Jennifer Bauzon
              Participants:
              Component watchers:
              Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                20/May/19

                  Time Tracking

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