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

Create new Web Service for retrieving the user calendar via iCal

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.9, 3.10
    • 3.10
    • Calendar
    • MOODLE_310_STABLE, MOODLE_39_STABLE
    • MOODLE_310_STABLE
    • MDL-68845-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. Access to the web site using the user you created the token for
      4. Create a calendar event for tomorrow (via the site Calendar in the main menu)
      5. In the Calendar main view, go to Export calendar
      6. Select "All events" and "This week"
      7. Click in Get calendar URl
      8. Copy the indicated calendar URL
      9. Open the calendar URL in a different browser (where you don't have a Moodle session active) and confirm that:
        • You can download a file in iCal format, if you open it with a text editor you can see the calendar event you created listed there
      10. Now, in the calendar Export screen again click in the Export button and confirrm that
        • The iCal file downloads and it has the same content than the one you opened in a different browser in the previous step
      11. Open the console an execute this new curl 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_calendar_get_calendar_export_token&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed

      12. Confirm that:
        • In the curl request response you see a token field with a value that is not empty
        • If you compare the sha1 has with the authtoken parameter from the calendar URL generated in the web (previous step), they match
      13. Now, access to the Moodle site as a site administrator
      14. Go to Administration> Appearance>Calendar
      15. Unselect the "Enable calendar export" setting and save values
      16. Execute the same CURL request from above and confirm that
        • You see as response a moodle exception ""Calendar export is disabled in this site"
      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 Access to the web site using the user you created the token for Create a calendar event for tomorrow (via the site Calendar in the main menu) In the Calendar main view, go to Export calendar Select "All events" and "This week" Click in Get calendar URl Copy the indicated calendar URL Open the calendar URL in a different browser (where you don't have a Moodle session active) and confirm that: You can download a file in iCal format, if you open it with a text editor you can see the calendar event you created listed there Now, in the calendar Export screen again click in the Export button and confirrm that The iCal file downloads and it has the same content than the one you opened in a different browser in the previous step Open the console an execute this new curl 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_calendar_get_calendar_export_token&wstoken=3af67232a7596ceb658df4db329e5ad6' --compressed Confirm that: In the curl request response you see a token field with a value that is not empty If you compare the sha1 has with the authtoken parameter from the calendar URL generated in the web (previous step), they match Now, access to the Moodle site as a site administrator Go to Administration> Appearance>Calendar Unselect the "Enable calendar export" setting and save values Execute the same CURL request from above and confirm that You see as response a moodle exception ""Calendar export is disabled in this site"

    Description

      This can be used to synchronise the user calendar with external systems, for example, adding a button in the Moodle app "Synchronise calendar"

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              jleyva Juan Leyva
              Dani Palou Dani Palou
              Jake Dallimore Jake Dallimore
              Anna Carissa Sadia Anna Carissa Sadia
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Nov/20

                Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 hours, 35 minutes
                  3h 35m