2
votes

I am trying to add a Google Form to a Google Classroom assignment, but it seems that it is not possible.

First, it tells me here (https://developers.google.com/classroom/reference/rest/v1/Material) that "When creating attachments, setting the form field is not supported.", but then right under this it give a "form" object option. Then, when I run the code below it gives me this error: "materials: Unsupported material type: FORM".

Take note: you CAN add the form by "link": BUT if you do this you CANNOT use the "Enable grade importing" button on the assignment, which is what I need.

Is there any way to add a Google Form to a Google Classroom assignment?

function createAssignment () {
var ClassSource =  {
title: "Test File",
state: "DRAFT",
scheduledTime: "2017-12-28T11:00:00Z", 
dueDate: {
    year: 2017,
    month: 12,
    day: 30,  
    },
dueTime: {
  hours: 11, 
  minutes: 0,
  seconds: 0,
  },
maxPoints: 10,

materials: [{
    form:{
      formUrl: "URL",
      title: "exam",
    },  
  }],    
workType: "ASSIGNMENT"          
};
  Classroom.Courses.CourseWork.create(ClassSource, "ID");
}
1
You can try to add the form as driveFileKos
if I do that, and leave formUrl, it gives me this error: Invalid JSON payload received. Unknown name "form_url" at 'course_work.materials[0].drive_file': Cannot find . Then, if I put formUrl to "id", it gives me this error: Invalid JSON payload received. Unknown name "id" at 'course_work.materials[0].drive_file': Cannot find field. If I try and add driveFile twice, it gives me this: @AttachmentNotVisible The item referenced by an attachment was not found or not visible to the user. If there is a way to add it by driveFile, there has to be a specific way to do it.Jason Jurotich
FYI: 2019 and they still have not activated this yet. What types of items can my application attach to assignment or submissions? The API supports attaching Drive files, YouTube videos, and links. Attaching native Google Forms is not yet supported. developers.google.com/classroom/faqJason Jurotich

1 Answers

0
votes

Google forms cannot yet be attached to classroom as an assignment. How about inputting the form as just as a link? This code will put the link onto the page, as a sudo assignment then students can indicate to the teacher that they have completed the quiz.

function createAssignment () {
courseWork = {  
  'title': 'Ant colonies',  
  'description': 'Read the article about ant colonies and complete the quiz.',  
  'materials': [  
     {'link': { 'url': 'FORM_URL' }},  
],  
  'workType': 'ASSIGNMENT',  
  'state': 'PUBLISHED',  
}  
  try {
    Classroom.Courses.CourseWork.create(courseWork, "ID");
  } catch (e){
  Logger.log(e)
  }
}

Student view.

enter image description here