1

I am aware that there are multiple questions essentially asking the same thing, but part of the problem I've identified is a lack of detail in the questions, so I'm going to try here, since I think I've exhausted all possibilities.

In the newer Google Classroom, there is a Classwork Tab/Page. This is new, and replaced an older "About" page. In this page, as a regular web user, you can create various materials, including one simply called "Material." This is done by clicking the create button and choosing "Material". enter image description here

These materials contain any combination of title, description, and attached files/links.

However, when using the API, while I can access any OTHER type of Classwork via: Classroom.Courses.CourseWork, no attempts to find these items (or create them via the API) has been successful. I've successfully created Assignments (a variant of CourseWork using:


Classroom.Courses.CourseWork.create({
    "creatorUserId":'me',
    "state":'draft',
    "courseId":cid,
    "title":'test item',
    "workType":"ASSIGNMENT",
    "materials": [],

  }, 'myClassCode');

}

The enum for workType according to the API only contains: enter image description here

I've tried omitting the workType (receive error saying I need to include it), using various guesses like MATERIAL, NONE, ABOUT, and null (all receive errors for invalid types).

I can query the list of CourseWork and find all of my entries that are questions or assignments but have found no access to the other items, which are current and active in the Classwork page for the class.

It's possible that this simply isn't accessible via the API, but I'd like to confirm. Any advice would be appreciated.

I am running as SuperUser and everything else seems to be working fine.

IglooWhite
  • 119
  • 9
  • It seems they have already included the functionality to create materials. Check the following link: https://developers.google.com/classroom/reference/rest/v1/courses.courseWorkMaterials/create – pacoalface Jan 12 '21 at 10:05

2 Answers2

2

You are right, at the moment it is not possible to create course materials through Google Classroom API.

Indeed, there is a feature request for it already:

https://issuetracker.google.com/issues/127591179

I suggest you to give it a star to increase visibility and get updates on the implementation status of the feature.

ziganotschka
  • 25,866
  • 2
  • 16
  • 33
  • 3
    Thank you - I added a star and will dig further in there in the future. What's interesting is the API states that the CourseMaterialSet is read-only, but I also can't read anything from the course if it's not an assignment or question. Thank you! – IglooWhite Aug 19 '19 at 14:04
0

Here is code that I have been using

/------------------------------Create Coursework Material-----------------------------------
function createCourseworkMaterial (id, cTitle, cDescription, topicId) {
  var courseArgs = { 
    "title": cTitle,
    "description": cDescription,
    "state" : "DRAFT",
    "topicId": topicId
  };
  try{
    
    Classroom.Courses.CourseWorkMaterials.create(courseArgs,id);

  }catch(e){
    
       console.error('Classroom.Courses.CourseWorkMaterial.create() yielded an error: ' + e);
  }
  
}
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Amar
  • 1
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Jeremy Caney May 08 '22 at 00:34