Exporting Moodle calendar data to Google calendar
The Moodle calendar is used as a personal calendar tool by students and also contains event information from curriculum modules such as assignment and tutorial dates. This data is also exposed via the module websites (Moodle courses). All this calendar information can be downloaded in iCalendar format or as a feed and imported into supporting calendar applications such as Outlook.
One aspect of the DOULS project is to improve the integration between our institutional VLE (Moodle) and Google Apps for education (which is available to all students as part of our email provision). A development task in the project is to update the calendar export process so that students can get the data from the VLE into their Google calendar much more easily.
Once in the Google calendar the events should synchronise with data on the VLE so if any events are changed, for example a tutorial start time, then the Google calendar should reflect this change. There are a number of advantages to using the Google calendar over the Moodle calendar alone as you can then: use the Google calendar gadget to view the information on your homepage (which links in to the other part of the project), get text alerts for upcoming events, sync the calendar with an Android phone.
This task is now almost complete; there still needs to be some design input so it can integrate with the new VLE design that is currently being developed and it is going to be usability tested by students in the next few weeks to ensure it is easy to use. As with all of the outputs from this project, the code for this development will be made available to the Moodle community once it is stable and ready for release.
This development consists of a Moodle local-plugin that contains a new export interface as well as the logic to generate the calendar data. The advantage of using a local-plugin is that the display and logic can be customised for our needs without having to change any Moodle core code; yet we can still make use of some of the existing code libraries and can even have our custom export process take place instead of the standard one by using a theme renderer override.
The new calendar export process includes the means to directly add the VLE calendar feed the user selected to their Google calendar (a one-click process). It supports standard Google accounts or can be directed to a Google domain where single-sign-in is utilised (such as at the OU).
Some of the key points learnt from the development of this feature were:
- It was our intial intention to use and API to manage calendar subscriptions but the Google calendar API can’t be used to subscribe to an external calendar feed (Open Issue).
- However, you can subscribe someone to a calendar feed by using an ‘add to Google’ button as detailed at: http://www.google.com/intl/en/googlecalendar/event_publisher_guide.html#public. The URL required takes the form http://www.google.com/calendar/render?cid=your_calendar_url - you can replace the standard Google address with a Google Apps domain address if required.
- If the calendar file/feed has a name defined then this will be displayed in the Google calendar list. Use the iCalendar property “X-WR-CALNAME” to do this e.g. X-WR-CALNAME:VLE calendar.
- The Moodle calendar can contain events that have a different context e.g. course, site, user. Course events are added to a calendar ‘category’ with the short name of the course; other events are not defined with a category. If a calendar has a mix of items where some have a category defined and some don’t then the Google calendar will often not import all. To overcome this in our calendar feed all items are defined with a category (either the course name or ‘personal’ or ‘site’).

Hi Jason
I find myself needing this exact functionality as well. If you are not done or need some help on completing development this I would be very happy to help out. If you already are done, is this something that is available for download on the internet (I looked at Moodle.org but was not able to locate it, maybe I did not look thoroughly enough)?
Regards
Kenneth Thorman
You can check out the final code at:
https://github.com/JISC-DOULS/moodle-local_calexport