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

Return file summary information in core_course_get_course_contents

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.3
    • Fix Version/s: 3.7
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a new course
      3. Turn editing on and add a new "file" resource in any section:
        • In the "Select files" area of the new "file" resource being created include at least 3 different types of files: a pdf, a txt file and a html file
        • Click on the html file and in the popup click on "Set main file"
        • Save changes
      4. Enrol one user as student in the course
      5. Create a Token in the mobile app service for the user created in the previous step
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours and the courseid with the id of the course created in step 2

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool"

      1. Now check that:
        • You see a contents field listing all the 3 files you added
        • The first file in the "contents" field is the HTML field
        • You see a "contentsinfo" field with subfields: filescount set to 3, filessize indicating the total of the size of the 3 files, lastmodified indicating the bigger timemodified value of the 3 files and finally mimetypes listing first "text/html" and then the rest of the mimetypes (text/plain and application/pdf)
      2. Now, execute the following curl request doing the same replacements

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6&options[0][name]=excludecontents&options[0][value]=1' --compressed | python -m "json.tool"

      1. And check that you see the "contents" field empty but the "contentsinfo" field is populated with the same data that the previous request
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a new course Turn editing on and add a new "file" resource in any section: In the "Select files" area of the new "file" resource being created include at least 3 different types of files: a pdf, a txt file and a html file Click on the html file and in the popup click on "Set main file" Save changes Enrol one user as student in the course Create a Token in the mobile app service for the user created in the previous step Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours and the courseid with the id of the course created in step 2 curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed | python -m "json.tool" Now check that: You see a contents field listing all the 3 files you added The first file in the "contents" field is the HTML field You see a "contentsinfo" field with subfields: filescount set to 3, filessize indicating the total of the size of the 3 files, lastmodified indicating the bigger timemodified value of the 3 files and finally mimetypes listing first "text/html" and then the rest of the mimetypes (text/plain and application/pdf) Now, execute the following curl request doing the same replacements curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&wsfunction=core_course_get_contents&wstoken=3af67232a7596ceb658df4db329e5ad6&options [0] [name] =excludecontents&options [0] [value] =1' --compressed | python -m "json.tool" And check that you see the "contents" field empty but the "contentsinfo" field is populated with the same data that the previous request
    • Affected Branches:
      MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-64026-master

      Description

      In order to reduce the number of WS requests the app needs to perform to display basic information (or to calculate the amount of data that will be downloaded when fetching a course to be used offline) it would be good if we could return some summary information about files in resource modules.

      We'd need to obtaing the number of files, the total file size and the different mimetypes withouth having to retrieve all the module contents.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 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 - 4 hours, 20 minutes
                  4h 20m