gordon613
gordon613

Reputation: 2952

Using Google Apps Script to set the correct answer in a Google Forms (that has been defined as a quiz)

I am trying to use Google Apps Script to set the correct answer in a Google Forms (that has been defined as a quiz)

The actual Google Form can be defined using code such as

var form = FormApp.create('New Form');
var item = form.addCheckboxItem();
item.setTitle('What condiments would you like on your hot dog?');
item.setChoices([
        item.createChoice('Ketchup'),
        item.createChoice('Mustard'),
        item.createChoice('Relish')
    ]);

(Taken from https://developers.google.com/apps-script/reference/forms/)

Is there any way in code to define what actually the right answer is and to assign it points?

I know this can be done manually...

Upvotes: 3

Views: 3389

Answers (2)

Duong Dung
Duong Dung

Reputation: 1

Copy

6.// Make a 10 point question and set up the question
7.    const item = form.addCheckboxItem();
8.    item.setTitle("What flavors are in neapolitan ice cream?");
9.    item.setPoints(10);
11.// chocolate, vanilla, & strawberry are the correct answers
12.   item.setChoices([
13.     item.createChoice("chocolate", true),
14.     item.createChoice("vanilla", true),
15.     item.createChoice("rum raisin", false),
16.     item.createChoice("strawberry", true),
17.     item.createChoice("mint", false)
18.   ]);

Upvotes: -1

Wicket
Wicket

Reputation: 38422

UPDATE: On April 2017 Google announced that now it's possible to create Google Forms quizzes programmatically.


At this time there isn't a method to set the correct answer. Please star the issue 6143: Create Quiz Form via API

Upvotes: 3

Related Questions