Skip to content Skip to sidebar Skip to footer

Creating Classroom Using App Script

I'm trying to create Google classrooms from a spreadsheet using App Script. I can create the classes successfully, but it's not adding the course materials (1 Doc) to the about pag

Solution 1:

According to the documentation you have to specify the DriveFile object with JSON.

"driveFile" : {
   "id":            theDocIdString,
   "title":         theDocTitleString,
   "alternateLink": urlToFileString,
   "thumbnailUrl":  imgThumbnailString 
   }

You can of course pull all of this data from a sheet or use variables to loop through resources.

Solution 2:

Here is the code I tried to successfully create a course, but I also do not get the course materials to attach to the ABOUT tab of the Google Classroom created.

function createCourse() {
  var resource = {
    name: "XYZ course",
    room: "The Great Hall",
    ownerId: "me",
    courseMaterialSets: [{
      title: "course materials",
      materials: [
      {

        driveFile: {
          id: "insert id of google drive file" 

        }


      }
      ],
  }],
  }
  var newCourse = Classroom.Courses.create(resource);


}

I also tried creating the course and then accepting the course in Google Classroom and the trying to add the classroom set. This also was not successful.

function addClassSet() {
  var id = "course id obtained with sample script in documentation";
  var resource = {
    name: "XYZ course",
    room: "The Great Hall",
    courseMaterialSets: [{
      title: "course materials",
      materials: [
      {

        driveFile: {
          id: "drive file id"//drive file was not added

        }


      }
      ],
  }],
    description: "This is a trial course", //this worked
  }
  Classroom.Courses.update(resource, id);
}

Is it because the documentation states that the courseMaterialsSets is Read only???

Post a Comment for "Creating Classroom Using App Script"