3

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");
}
Jason Jurotich
  • 441
  • 4
  • 24
  • You can try to add the form as `driveFile` – Kos Dec 27 '17 at 18:31
  • 1
    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 Dec 27 '17 at 19:30
  • 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. https://developers.google.com/classroom/faq – Jason Jurotich Dec 26 '19 at 17:08
  • We can do it manually. I am here because, I am trying to copy assignments, and it gets stuck on forms. The assignment already exists in the source course. – ctrl-alt-delor Apr 18 '22 at 19:32

1 Answers1

0

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

Jason Allshorn
  • 1,625
  • 1
  • 18
  • 27
  • The problem is that if you do this you can't use the "Enable grade importing" button on the assignment. – Jason Jurotich Dec 27 '17 at 20:35
  • I updated it. You are right about the enable grade importing. But currently there is no way to get the google form scores into the classroom. How about using the classroom's built in question functions? – Jason Allshorn Dec 27 '17 at 20:52
  • Sadly, I need auto-grading, which Google Forms provides. What I don't get is that, if this cannot be done, why offer the "form" option under "material"? Either way, I am now trying to find another way of getting the grades, and using your suggestion above, which I had already known would work, but didn't fully resolve my problem. This discussion will be helpful to other professors. Thanks. – Jason Jurotich Dec 27 '17 at 21:44
  • In the classroom blog under September 2017 it mentions that a teacher can do the exact thing you are aiming for. The API can't be too far behind. https://support.google.com/edu/classroom/answer/6149237?hl=en – Jason Allshorn Dec 27 '17 at 21:57
  • We can do it manually. I am here because, I am trying to copy assignments, and it gets stuck on forms. The assignment already exists in the source course. – ctrl-alt-delor Apr 18 '22 at 19:32
  • The Google Forms API just came out, so I am simply just going to "skip over" the Classroom-Form problem and just grab the grades from Forms using the Forms API and then "past" them into Classroom with the Classroom API. Google has yet to fix the problem mentioned above so I don't see any other way to do it for now. https://developers.google.com/forms/api/reference/rest – Jason Jurotich Apr 18 '22 at 22:02