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

New Web Service tool_mobile_get_content

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Create a Token for one user (not admin) in the platform:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
          Next, you can do a CURL REST call simulating a WS client with the user.
      3. Install in Moodle the following activity plugin (in the mod/ directory): https://github.com/jleyva/moodle-mod_certificate/archive/MOBILE-2363.zip
      4. Create a new course in the site (or use an existing one) for adding a "Certificate" activity in any section of the course (Go to a course, Enable editing in the Cog top-right, and then go to a section an click on Add activity or resource)
      5. Enrol the user you created the token for as student in the course
      6. Annotate somewhere the course id (where you created the Certificate activity), and the activity course module id (the mod/certificate/view.php?id=cmid) and the id of the user you created the token for.
      7. Now, open a terminal an execute the following curl request replacing COURSEID, USERID and CMID with the course, user and course module ids.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=tool_mobile_get_content&wstoken=12a2a65aeea2a177055e233f9e303218&component=mod_certificate&method=mobile_course_view&args[0][name]=courseid&args[0][value]=COURSEID&args[1][name]=cmid&args[1][value]=CMID&args[2][name]=userid&args[2][value]=USERID' | python -m "json.tool"

      8. Now, check that in the WS response you see a templates->html field populated with some HTML code
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for one user (not admin) in the platform: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. Install in Moodle the following activity plugin (in the mod/ directory): https://github.com/jleyva/moodle-mod_certificate/archive/MOBILE-2363.zip Create a new course in the site (or use an existing one) for adding a "Certificate" activity in any section of the course (Go to a course, Enable editing in the Cog top-right, and then go to a section an click on Add activity or resource) Enrol the user you created the token for as student in the course Annotate somewhere the course id (where you created the Certificate activity), and the activity course module id (the mod/certificate/view.php?id=cmid) and the id of the user you created the token for. Now, open a terminal an execute the following curl request replacing COURSEID, USERID and CMID with the course, user and course module ids. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=tool_mobile_get_content&wstoken=12a2a65aeea2a177055e233f9e303218&component=mod_certificate&method=mobile_course_view&args [0] [name] =courseid&args [0] [value] =COURSEID&args [1] [name] =cmid&args [1] [value] =CMID&args [2] [name] =userid&args [2] [value] =USERID' | python -m "json.tool" Now, check that in the WS response you see a templates->html field populated with some HTML code
    • Affected Branches:
      MOODLE_34_STABLE, MOODLE_35_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-61449-master

      Description

      In order to support "site add-ons" we'd need a new WS to return pieces of content that will displayed in the app, see MDL-60774 for more information and the specification is here: https://docs.google.com/document/d/1VnmhyJFhbnsfDJwjHYQy9yOzkbNsfsXD5kuSns9V3K4/edit#

      Initially, we were planning to use the existing core_get_fragment function but it is not suitable because:

      • It forces the render of the header before the callback is called (so any further context validation is not possible).
      • It returns javascript mixed with the header libraries
      • Does not allow to return structured data.
      • It is not part of the mobile service (so the local_mobile plugin we'll be needed)
      • Does not use auto-loading (callbacks go to lib.php)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  17/May/18

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 37 minutes
                  37m