Using Google Apps Script To List Assignments Through Google Classroom Api Using Course.coursework.list
Inexperienced at this - please forgive any wrong choices of words... I'm trying to use Google Apps Script to get a list of assignments set within different classrooms. I believe I
Solution 1:
This line: var info = Classroom.Courses.CourseWork.list(listArgs);
Should be: Classroom.Courses.CourseWork.list(courseId, optionalArgs)
Or this: Classroom.Courses.CourseWork.list(courseId)
The point is that courseId is required.
You can try it on the API Explorer Here.
So the code should look something like this:
function listCourses() {
var optionalArgs = {pageSize: 100};
var listArgs = { pageSize: 10 };
var response = Classroom.Courses.list(optionalArgs);
var courses = response.courses;
if (courses && courses.length > 0) {
for (i = 0; i < courses.length; i++) {
var course = courses[i];
Logger.log('%s (%s)', course.name, course.id);
var info = Classroom.Courses.CourseWork.list(course.id, listArgs)
var works = info.works;
if (works && work.length > 0) {
for (i = 0; i < works.length; i++) {
var work = works[i];
Logger.log('%s (%s)', work.title, work.creationTime);
}
}
}
}
}
But check it out carefully because this is the first time I've ever enabled the Classroom API.
Post a Comment for "Using Google Apps Script To List Assignments Through Google Classroom Api Using Course.coursework.list"