Sunday, 9 August 2015

GClassroom Share Button in GSites

Google recently released the Classroom API. Part of the API allows for the embedding of a share to classroom button for any 3rd party site. Google has published the code needed to make the buttons appear in web pages on the API pages linked above.

I use Google Sites with my students and have embedded resources, forms, docs etc. that I link to from Classroom so I wanted to embed one of these Share buttons. Adding script to GSites pages is a little tricky but with a little bit of Apps Script it can work!

In the image above, I have added the share button beside the page title; this is done by creating and inserting an Apps Script that has been published as a web app.

I used the HTML Service and the templated Scriptlets to build the HTML I wanted to embed and used the scriptlet to acquire the javascript form Google:

I want to be able to copy a page with the script already in it and have it automagically pull the correct URL from the Site without hard coding the URL each time. The scriptlet code above allows this by using SitesApp.getActivePage().getUrl();

Publish the project as a Web App and insert it into your page:

When pressed, the button opens a window to Classroom and lets you select the class you want to post an announcement or assignment to. Nice :)

No comments:

Post a Comment