Export multiple database records to iCal or gCal

212 Views Asked by At

I'm building a simple scheduling application for a client. It allows teachers to create a calendar of assignments for their students. I'd like to offer the ability for a student to add ALL assignments to their calendar at one time. Say there were 20 assignments over a 4 week period. This functionality would allow the student to download a single file, or follow a certain feed, to add all 20 assignments to their calendar at one time.

In my head this would be a single iCal file, but I'm not sure if iCal works that way. Alternately, each course /course/basket-weaving-101_51/ would have an RSS feed /course/basket-weaving-101_51/cal/ that could be followed.

Does anyone have experience with this, or could offer guidance?

2

There are 2 best solutions below

2
On

Yes, one feed program that accepts parameters via the url could be used to offer a subscribeable calendar feed at whatever level of detail you wish. I say subscribeable as that, at a student level ... /student_id_or_name?feed=ics would offer the students the most convenient solution. They could subscribe once and then all the courses assignments that they are signed up for all courses over time could automatically appear as their calendar app refreshes the feed.

A single assignment could also offer a feed of the one 'event'. But that should probably be imported into their main calendar, rather than subscribing!

Note subscribing is different to importing - your help instructions need to make that clear as it is up to the user what they do with the feed.

Import(or add to calendar) is a once-off and will not update with new events/assignments.

Subscribing as a separate calendar I find much preferable as most calendar apps will let one check and uncheck the calendars as you need them. I have mykids timetables subscribed (and public holidays etc) but that's a very busy view, so often I just untick them for a cleaner view.

3
On

You need to get familiar with the treatment of ical by the different calendar clients (outlook, webmail) before you can decide how best to target them. In general, they have two modes for treating ical: "accept an invitation" and "subscribe to an internet calendar".

The big advantage of "Accept an invitation" is that your events go into the user's calendar, and generate reminders and so on as if the user had created the event. The disadvantage is that you need to send your invitations one "event" at a time by email, and, particularly in Outlook, they may need to be viewed as mail before they appear in the calendar. If you're sending out 20 or more assignments, this may feel like spam to the recipient.

"Subscribe to an internet calendar" is a little misleading in that an ical feed is not a feed. You put the "whole calendar" on a website, and the client poles the website. Outlook and webmail clients are generally happy to display these calendars, but "importing" the events into the user's own calendar is a bit clunky. Gmail and webmail display the info on the same grid by default. Outlook displays a new grid for each calendar.

Modifications are a bit more complex for the subscription scenario. You will likely want to regenerate the whole calendar for affected students, whereas in the invitation scenario you just send one mail with the changed event.

Even so, if you have a database with courses, students and enrolments, you could do a nice little app that generates an ical per student, names it with their student number, and whacks it in a calendars folder. The student subscribes once to http://myuniversity.com/calendars/12345.ical, and each semester all their assignments are automatically in their web calendar.

Be careful with the subscription link. If tens of thousands of students subscribe to (pole) a dynamically generated calendar, you are going to have a lot of needless processing, and quite likely a performance headache. You want to be generating static files, then let your webserver negotiate with the client whether they need to be resent.