In a script connected to a spreadsheet, I loop through the rows of the spreadsheet and add coursework via a call to Classroom.Courses.CourseWork.create(ClassSource, courseId)
I had tested quite a bit and today was trying to weekly assignments for the year to a course I had created. I got an error on the 10th add. I assumed that it was a problem with a timeout so I added a sleep
statement. Nothing worked so I tried starting with a new script.
If I just put in the code to access the spreadsheet,
var sheet = SpreadsheetApp.getActiveSheet();
var rangeSS = sheet.getDataRange()
var data = sheet.getDataRange().getValues();
no problem with authorization but then the call to Classroom
doesn't work.
So then I add in
"oauthScopes": [
"https://www.googleapis.com/auth/classroom.coursework.students.readonly",
"https://www.googleapis.com/auth/classroom.courses.readonly"
],
under View -> Show Manifest File
Strangely, at this point, I get the error:
You do not have permission to call getActiveSheet.
I have Sheets
enabled via Resources -> Advanced Google Services.
I've enabled Classroom
and Sheets
via Scripts Dashboard
I've tried this several times on both Opera and Chrome, sometimes also enabling Google Drive.
Nothing seems to work. Wondering if anyone else has seen this problem.
function myFunction() {
var weekday = new Array("Sunday", "Monday","Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" );
var sheet = SpreadsheetApp.getActiveSheet();
var rangeSS = sheet.getDataRange()
var data = sheet.getDataRange().getValues();
for (var i = 1; i < data.length; i++) {
// set up ClassSource from data in the spreadsheet row
Classroom.Courses.CourseWork.create(ClassSource, courseId)
...