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

Add a new parameter to existing blocks WebServices to return blocks content

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. In a new or existing course add some blocks (via the course settings cog -> Turn editing on and then "Add block" via the left flat menu
      3. Ensure that at there is at least one HTML block where you included images in the content via the text editor.
      4. Create a Token in the mobile app service for a student in the course
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. You also need to replace the courseid with the id of the course you used.

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

      1. Now, check that in the response:
        • You see listed all the blocks displayed in the course
        • For each blocks, you see a "contents" field that contains the block title and main contents (title and content fields)
        • For the HTML block where you included images you also see a contents->files field with all the files you included via the text editor.
      2. Now, set the value of the returncontents parameter in the CURL request to 0 and execute again the CURL request.
        • Check that you don't see the contents field for any block anymore.
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings In a new or existing course add some blocks (via the course settings cog -> Turn editing on and then "Add block" via the left flat menu Ensure that at there is at least one HTML block where you included images in the content via the text editor. Create a Token in the mobile app service for a student in the course 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. You also need to replace the courseid with the id of the course you used. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseid=2&returncontents=1&wsfunction=core_block_get_course_blocks&wstoken=3af67232a7596ceb658df4db329e5ad6' | python -m "json.tool" Now, check that in the response: You see listed all the blocks displayed in the course For each blocks, you see a "contents" field that contains the block title and main contents (title and content fields) For the HTML block where you included images you also see a contents->files field with all the files you included via the text editor. Now, set the value of the returncontents parameter in the CURL request to 0 and execute again the CURL request. Check that you don't see the contents field for any block anymore.
    • Affected Branches:
      MOODLE_35_STABLE, MOODLE_36_STABLE
    • Fixed Branches:
      MOODLE_36_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-63694-master

      Description

      Being able to display blocks on the mobile app has been a top requested feature for years.

      We need a way to display blocks content, for most of the blocks we already have WebServices to retrieve the content, but for others, like HTML block we can't just create a WS not linked directly to the existing blocks one mostly because how the context/permissions are calculated.

      See this spec for the complete rationale.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  3/Dec/18

                  Time Tracking

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