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

New Web Service core_block_get_dashboard_blocks

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.6
    • 3.5.2
    • Blocks, Web Services
    • MOODLE_35_STABLE
    • MOODLE_36_STABLE
    • MDL-63465-master
    • Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a Token in the mobile app service for any user in the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Open the console an execute this request, replacing wstoken with the token you just created and the site url with yours.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_block_get_dashboard_blocks&wstoken=WSTOKEN' | python -m "json.tool"

      4. Copy the curl command output into a text file
      5. As the user you created the token for, access your local Moodle installation via the browser (not the app) and go to your "Dashboard" (first option in the flat left menu)
      6. Now, compare the blocks you see in your dashboard with the blocks returned by the CURL request, all the wider blocks at the center of the page should have the "region" field set to content. For the blocks at the right, the "region" field is set to side-pre. The "name" field indicates the shortname of the block (so you can identify it). The order of the blocks returned by the curl request must match the order displayed in the web site.
      7. Now hide one of the blocks in your dashboard in Moodle
      8. Execute the CURL request again and check that the field "visible" for the block is set to "false"

      TESTING ADMIN CAN SEE ANY USER BLOCKS

      1. Now, log-in as admin again to your Moodle site and create a token for the admin user of the site (follow again instructions of point 2 from previous section)
      2. Open the console an execute this request, replacing wstoken with the token you just created and the site url with yours. The userid field must be set to the user you created the token for in the step 2 (not the admin account).

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'userid=X&wsfunction=core_block_get_dashboard_blocks&wstoken=WSTOKEN' | python -m "json.tool"

      3. Check that the curl response is exactly the same that the one you originally saved in the text file.

      TESTING STICKY BLOCKS

      1. Now, as admin again, go to the "Site Home" and "Turn editing on" via the cog
      2. Add an HTML Block ensuring than "Where this block appears" -> "Page contexts" is set to "Display throughout the site" and Default region is set to "Right"
      3. Now, execute again the last CURL request and check that you receive the "html" block you just created
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for any user in the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this request, replacing wstoken with the token you just created and the site url with yours. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_block_get_dashboard_blocks&wstoken=WSTOKEN' | python -m "json.tool" Copy the curl command output into a text file As the user you created the token for, access your local Moodle installation via the browser (not the app) and go to your "Dashboard" (first option in the flat left menu) Now, compare the blocks you see in your dashboard with the blocks returned by the CURL request, all the wider blocks at the center of the page should have the "region" field set to content. For the blocks at the right, the "region" field is set to side-pre. The "name" field indicates the shortname of the block (so you can identify it). The order of the blocks returned by the curl request must match the order displayed in the web site. Now hide one of the blocks in your dashboard in Moodle Execute the CURL request again and check that the field "visible" for the block is set to "false" TESTING ADMIN CAN SEE ANY USER BLOCKS Now, log-in as admin again to your Moodle site and create a token for the admin user of the site (follow again instructions of point 2 from previous section) Open the console an execute this request, replacing wstoken with the token you just created and the site url with yours. The userid field must be set to the user you created the token for in the step 2 (not the admin account). curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'userid=X&wsfunction=core_block_get_dashboard_blocks&wstoken=WSTOKEN' | python -m "json.tool" Check that the curl response is exactly the same that the one you originally saved in the text file. TESTING STICKY BLOCKS Now, as admin again, go to the "Site Home" and "Turn editing on" via the cog Add an HTML Block ensuring than "Where this block appears" -> "Page contexts" is set to "Display throughout the site" and Default region is set to "Right" Now, execute again the last CURL request and check that you receive the "html" block you just created

      New WS to retrieve the blocks displayed in the user dashboard, this is necessary to be able to display the correct blocks (in the correct order) for mobile users.

        1. 1.PNG
          1.PNG
          219 kB
        2. 2.PNG
          2.PNG
          230 kB

            jleyva Juan Leyva
            jleyva Juan Leyva
            Albert Gasset Albert Gasset
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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