Skip to content

Instantly share code, notes, and snippets.

@rheajt
Created January 31, 2018 10:18
Show Gist options
  • Save rheajt/040de65bd996068f966429f142720be2 to your computer and use it in GitHub Desktop.
Save rheajt/040de65bd996068f966429f142720be2 to your computer and use it in GitHub Desktop.
function getClassroomRosters() {
var courses = Classroom.Courses.list().courses;
var email = Session.getActiveUser().getEmail();
for(var i = 0; i < courses.length; i++) {
var courseState = courses[i].courseState;
var teacher = Classroom.Courses.Teachers.get(courses[i].id, email);
var isTeacher = teacher.userId === courses[i].ownerId;
if (courseState == "ACTIVE" && isTeacher) {
var courseName = courses[i].name;
var students = Classroom.Courses.Students.list(courses[i].id).students || [];
var course = new Course(courseName, students);
course.createRoster();
var tabNames = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("class view").getRange(1+i, 2).setValue(courseName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment