Suppose you want to make loads of groups and calendars and populate them with users and don't want to spend any money on any tools to do it. Well you can use GAM and a couple of scripts to do this. In a school you might want a Google Group and Calendar for each teaching group. You can achieve this using paid for tools such as Hapara's TeacherDashboard and tools that sync your MIS to AD and then to Google Apps - but these cost money and in the second case assume you actually have active directory.
So this is how to do it without any of those tools and zero cost.
So this is how to do it without any of those tools and zero cost.
Creating Groups
You will need a csv file with a list of group names first - classes names perhaps. Save the csv file to your GAM directory. Run the following command:
gam csv groups.csv gam create group ~groups
groups.csv = your csv file, the 'groups' in ~groups = the name of the column of groups in the csv file.
Populate with group owners
You might want teachers to be group owners. So to add them to the groups you will need a csv file with the email address of the teacher next to the classes they teach - so two columns. Each teacher could have multiple rows if they teach many classes. Run the following command:
gam csv teachers.csv gam update group ~group add owner user ~teacher
Again the ~group/teacher refer to the column heading on the csv file.
Populate with members
Students you might want to add as members. So you need a csv file with the email address of all the students next to the classes they take (the group email address - groupname@domainname). Run the following command:
gam csv students.csv gam update group ~group add member user ~students
Thats it for groups. Note, for the students where there are likely to be 1000's of lines, it can take a while to run!
Create Calendars
There is not a GAM command to create regular calendars, so you need to use a script. To make calendars, add the following script to a Google Sheet:
Create all those calendars:
function createcalendars() {
var sheet = SpreadsheetApp.getActiveSheet();
var data = sheet.getDataRange().getValues();
for (var i = 0; i < data.length; i++) {
Logger.log(data[i][0]);
}
for (var i = 0; i < data.length; i++) {
var calendar = CalendarApp.createCalendar(data[i][0]);
Logger.log('Created the calendar "%s", with the ID "%s".',
calendar.getName(), calendar.getId());
}
}
This will read a list of calendar names from the Google Sheet and create them (good idea to do this on one central calendar owner user!) . So use the same name as you used for the group. You can use GAM to populate the calendars, but you first need the calendar email address. You can add this script to another sheet to list all the calendars.
function listCals() {
var calendars = CalendarApp.getAllOwnedCalendars();
data = []
for (var i = 0; i < calendars.length; i++) {
data.push([ calendars[i].getId(), calendars[i].getName()])
}
var destinationRange = SpreadsheetApp.getActiveSheet().getRange(1, 1, data.length, data[0].length);
destinationRange.setValues(data);
};
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "List Owned Calendars",
functionName : "listCals"
},];
sheet.addMenu("Calendar", entries);
}
Populate Calendars
You will need a csv file with a list of your calendar owners (teachers) and the calendars they own (you will need to match calendar email address to the group). Run the following command:
gam csv teachcal.csv gam calendar ~calendar add editor ~teacher
for students -
gam csv studentcal.csv gam calendar ~calendar add read ~student
Where ~ goes before the name of the heading of the appropriate column in the CSV file.
Automating the process
You could put all of these GAM commands into a windows batch file (*.bat) and run it as a scheduled task overnight once a week to update groups as long as you can update the csv files.
Comments
Post a Comment