Google script to add Google Form to a Google Classroom assignment

google-apps-script google-classroom

266 观看


124 作者的声誉

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 ( 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: [{
      formUrl: "URL",
      title: "exam",
workType: "ASSIGNMENT"          
  Classroom.Courses.CourseWork.create(ClassSource, "ID");
作者: Jason Jurotich 的来源 发布者: 2017 年 12 月 27 日

回应 (1)


1194 作者的声誉

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){

Student view.

enter image description here

作者: Jason Allshorn 发布者: 27.12.2017 08:22