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

New Web Service core_course_check_updates

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Major Major
    • 3.2
    • 3.1.2
    • Web Services
    • MOODLE_31_STABLE
    • MOODLE_32_STABLE
    • MDL-56307-master
    • Hide
      1. Calculate your current timestamp before starting to do anything, you will need it later: http://www.epochconverter.com/
      2. In a course, as teacher do some modifications to some existing modules you can: change the settings of any module, add a new forum post, add a new glossary entry, wiki page add a new chapter to the book module etc... (please note that there are some modules not supported, like the database one)
      3. You an also enable the comments and rating feature in a glossary of forum and add new ratings or comments
      4. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      5. Create a Token in the mobile app service for the teacher user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, courseid add the timestamp and the cmids of the modules you modified and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=X&tocheck[0][contextlevel]=module&tocheck[0][id]=100&tocheck[0][since]=1476274596
          &tocheck[1][contextlevel]=module&tocheck[1][id]=101&tocheck[1][since]=1476274596
          &wsfunction=core_course_check_updates&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      7. Check that the WS returns correctly the different areas of the module that were updated, in some cases you will receive itemids (like a new glossary entry id, or forum discussion post id) and in some cases when there are not itemids you will receive the last time when the module was updated.
      8. Check that if you pass a contextlevel block you get a warning
      9. Check that if you try to retrieve updates for a module not supported (feedback for example) you get a warning
      10. Check that if you try to retrieve updates for a module not visible for the user (like a hidden one) you get a warning
      11. Trying to get a module for a different course you will get a warning too.
      Show
      Calculate your current timestamp before starting to do anything, you will need it later: http://www.epochconverter.com/ In a course, as teacher do some modifications to some existing modules you can: change the settings of any module, add a new forum post, add a new glossary entry, wiki page add a new chapter to the book module etc... (please note that there are some modules not supported, like the database one) You an also enable the comments and rating feature in a glossary of forum and add new ratings or comments As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token in the mobile app service for the teacher user: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the wstoken, courseid add the timestamp and the cmids of the modules you modified and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=X&tocheck [0] [contextlevel] =module&tocheck [0] [id] =100&tocheck [0] [since] =1476274596 &tocheck [1] [contextlevel] =module&tocheck [1] [id] =101&tocheck [1] [since] =1476274596 &wsfunction=core_course_check_updates&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Check that the WS returns correctly the different areas of the module that were updated, in some cases you will receive itemids (like a new glossary entry id, or forum discussion post id) and in some cases when there are not itemids you will receive the last time when the module was updated. Check that if you pass a contextlevel block you get a warning Check that if you try to retrieve updates for a module not supported (feedback for example) you get a warning Check that if you try to retrieve updates for a module not visible for the user (like a hidden one) you get a warning Trying to get a module for a different course you will get a warning too.

      Check if a module has been updated since the given timestamp.

      Parameters:

      • array of cmid and timestamp

      Returns:

      • array of the type of elements that were updated: configuration, files, posts (for forum), pages (for wiki), entries (for glossary), etc..
        This won't return the element ids of additional information, just a boolean indicating if something was updated since the given time.

      Why do we need this information:
      The mobile app allows to download both resources and activities for offline access/usage.

      Right now, for calculating if a resource or activity needs update (so we can show a button to allow the user to update the downloaded module) we must perform several "heavy" web services requests. This is because we need to retrieve the module information and associated files and data to compare with the local information stored and see if something was updated.

      For example:

      • For a quiz we must retrieve the quiz attempts to see if there is a new attempt.
      • For forums, we must download discussions/posts.
      • For assignment, we need to download the recent submissions to check if there is any change.

      For a normal course we could end up doing lots of requests to display the modules needing update.

      This is the reason we'd need a simple Web Service able to return some basic information about the modules status since a given date.

      This Web Service will receive a list of cmids and timestamps and we'll ask every module type to calculate if there has been any update affecting the user since the given time.

      Please, note that we must specify a different timestamp for each module, because maybe the user updated manually some modules of the course but not all of them.

      These changes can help us also to "mark/display" in the app the modules with updates since the last visit of the user. So basically with these changes we will be able to:

      • Check if the already downloaded modules (if any) needs to be updated.
      • Every time the user open a course, check for updates to display using badges (red filled circles with a number inside)

      Implementation

      This WS will do multiple request for retrieve all the required information for all the modules, but this will have a lower performance impact that the current requests we are doing (right now to calculate the status we perform multiple request) so this will be a performance improvement for both sites using 3.2 and the app.

      Another implementation approach could have been implement an event observer in a plugin and store the update information in a new database table.
      Or not an event observer and using direct calls (a new subsystem) or whatever available in lib/ so any component or plugin could report updates.

      I think that this is the simplest way, and right now it will reduce the amount of request that the app needs to do.

            jleyva Juan Leyva
            jleyva Juan Leyva
            Russell Smith Russell Smith
            David Monllaó David Monllaó
            Ankit Agarwal Ankit Agarwal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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