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

Improve course download in the app making use of the new ZipStream library

XMLWordPrintable

    • MOODLE_310_STABLE
    • MDL-69952-master
    • Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create or use an existing course with one student (u1) enrolled
      3. Create inside the course, a file and folder resource including some files in both of them
      4. Create a Token in the mobile app service for the user u1 in the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Now, log-in as the user u1 in the Moodle site and go to your "Private files"
      6. Use the browser "View page source code" option to display the source code
      7. From the source code, copy the "itemid" numeric value you will see referenced in the code a couple of times. Do not close the "Private files" page, keep it open always because you will need to go back avoiding any reload.
      8. Open the system console an execute this new curl request, replacing WS_TOKEN with the token you just created, the course id and also the item id you just copied and the site url with yours.

        curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_contents' --data 'courseid=COURSE_ID&options%5B0%5D%5Bname%5D=zipcontentsitemid&options%5B0%5D%5Bvalue%5D=ITEM_ID&options%5B1%5D%5Bname%5D=zipcontentsfilename&options%5B1%5D%5Bvalue%5D=myfile.zip&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=WS_TOKEN' --compressed | python -m "json.tool"

      1. After executing the curl request, go back to the browser (Private files page), avoid any reloading of the page, and you click the link "Files" that is within the file area editor and confirm that:
        • You now see a zip file whose name is myfile.zip
      2. Review the curl response and confirm that:
        • the field maxfilesize for the folder resource indicates the size of the larger file
      3. Download the file, unzip it and confirm that:
        • The zip file has inside all the files you added in the folder and resource
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create or use an existing course with one student (u1) enrolled Create inside the course, a file and folder resource including some files in both of them Create a Token in the mobile app service for the user u1 in the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Now, log-in as the user u1 in the Moodle site and go to your "Private files" Use the browser "View page source code" option to display the source code From the source code, copy the "itemid" numeric value you will see referenced in the code a couple of times. Do not close the "Private files" page, keep it open always because you will need to go back avoiding any reload. Open the system console an execute this new curl request, replacing WS_TOKEN with the token you just created, the course id and also the item id you just copied and the site url with yours. curl 'SITE_URL/webservice/rest/server.php?moodlewsrestformat=json&wsfunction=core_course_get_contents' --data 'courseid=COURSE_ID&options%5B0%5D%5Bname%5D=zipcontentsitemid&options%5B0%5D%5Bvalue%5D=ITEM_ID&options%5B1%5D%5Bname%5D=zipcontentsfilename&options%5B1%5D%5Bvalue%5D=myfile.zip&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_contents&wstoken=WS_TOKEN' --compressed | python -m "json.tool" After executing the curl request, go back to the browser (Private files page), avoid any reloading of the page, and you click the link "Files" that is within the file area editor and confirm that: You now see a zip file whose name is myfile.zip Review the curl response and confirm that: the field maxfilesize for the folder resource indicates the size of the larger file Download the file, unzip it and confirm that: The zip file has inside all the files you added in the folder and resource

      This new library and the wrapper class in the content exporter will help us to improve the way contents are served to the Moodle app.

      Right now, when a user requests to download a course for offline, the Moodle app uses the core_course_get_course_contents WS to retrieve the list of files it needs to download and it download them one by one using an interal file pool task, this is far from ideal and we've been exploring ways to improve it, by using the zip stream we will able to:

      • Reduce the amount of data the user has to download
      • Speed up the courses download in the app
      • Reduce the number of requests to the server

      In general, this change will improve the user experience and app performance

            jleyva Juan Leyva
            jleyva Juan Leyva
            Rodrigo Mady Rodrigo Mady
            Andrew Lyons Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 4 hours, 25 minutes
                2d 4h 25m

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