When I use Classroom API to publish an assignment with student copies. I get API call to classroom.courses.courseWork failed with error: Internal error encountered
.
This occurs when I post a Draft successfully, then attempt to use the API to publish the assignment, or when I try to publish a new assignment directly.
Changing the assignment to "view only" solves the publishing problem in both cases but then you do not get student copies and you can not change it back after publishing and student copies are almost always required.
I can manually publish in google classroom after posting a draft with no problems. I assume it is connected to the reason you can not make student copies after posting assignment.
I have probed before publishing and the student folder id is available but has not been created yet.
var assignment = {
title: "Test File",
materials: [
{
driveFile:{
driveFile: {
id: "11klBA-80IQPaJHrpSyJHqVsK7BUWWAtoLFdwG0uJGfo",
title: "Sample Document"
},
shareMode: "STUDENT_COPY"
}
}
],
state: "PUBLISH",
workType: "ASSIGNMENT"
};
var id = Classroom.Courses.CourseWork.create(assignment, 24551294261)
Logger.log(id);
or
Classroom.Courses.CourseWork.patch( {"state": "PUBLISHED"},24551294261,46981225150,{updateMask:'state'});
API call to classroom.courses.courseWork.patch failed with error
is returned with either program code. The code works fine if Student_COPY is changed to view. I believe it is a bug, the API does not have some publishing protocol that manually hitting publish does. So it fails. My guess would be the creation of the google folder to store the documents.
I teach 8 classes publishing each assignment manually takes a long time and if I make errors students may miss an assignment.
Hoping for a workaround or a bug fix. I am using the API to post in part to save time grading and in part to keep all 8 classes the same. I can Updating due dates or instructions without accidentally leaving anyone out. I need the API to post the assignment so it has access to the assignment for changes.