Google Classroom to Google Calendar (via a Sheet)

Update – There is a much better version of this developed by Charlie Love – I suggest you use his version available here: http://charlielove.org/?p=9956 

The one missing link in Google Classroom seems to be its ability to show the deadlines of set work in your Google Calendar. The Google Apps Script below does just that, adding assignment deadlines to your calendar and along the way creating a Google Sheet of all your assignments too. It does this by picking up the incoming e-mails sent out when new assignments are set, reading them and adding them to the sheet and calendar.

There are two versions of the script here –  with slight differences in how the e-mails are handled in GMail.

Version 1 – In this version you need to set a filter to star all assignments from Google Classroom that arrive in your inbox. Once the script runs the star is removed. This is the most accurate way of running the script as it is removed from each GMail message in turn – no matter how many assignments you have. However when doing this you cannot use the star feature in GMail for anything else (because if you do the script will try to read it and then remove the star).

Version 2 – In this version you need to set a filter to add a label to incoming assignments called “Classroom”. Once the script runs it will add the assignment to the calendar and then remove the label. The problem with this method is that if more than one assignment has arrived it will only add the first one to the calendar and then remove the label from all the e-mails. This problem is caused because Google Scripts do not have an option to remove a label from a single message (like they do for stars). You can overcome this to some extent by setting the script to automatically run very often (perhaps every 5 minutes).

How to set up

1. You need to filter your e-mails in GMail. Go to Setting (the cog on the top right) and then settings.

2. Once the settings menu opens, go to Filters and add create a new filter. This filter needs to pick up any e-mails with the Subject “New Assignment*” and either star it or apply a label depending on which version of the script you are using.

filters

 

3. Now you have the filter set up you can add the script – which is done in Google Drive. Go to New and Script. If you cannot see the Script option you may need to go to Connect More Apps and add the Script Option.

download

 

4. Now copy the correct version of the script below into the script area.

Version 1 –

Version 2 –

5. Now save the script and run it – on the first occasion you run the script it will ask for permission to use your mail, drive and calendar. You will get an error message if there are no e-mails for it to find (either starred or in the folder).

6. You probably want to trigger the script to run automatically in the background – go to Resources and All Your Triggers to set the script to run – you can run it as often as needed – make sure you turn notifications off – otherwise you will get a notification every time the script fails, which is every time there are no e-mails for it to find.

download (1)

 

 

The outcome of the script is that your assignments will be shown as all day events in Google Calendar on the day they are due. You will also have a Spreadsheet called “Classroom Assignments” in Google Drive which stores the details of all of your assignments.

If your a teacher – you could use this to set up a homework calendar. 

There is nothing original here and I made this using lots of other posts on the web about Google Scripts and how to use Regular Expressions – feel free to have a play and adapt the script to your own use. It should be possible to do other things with the data, such as pushing it to twitter or to a text message. If you do something great post about it in the comments below…

 

2 thoughts on “Google Classroom to Google Calendar (via a Sheet)