使用 Google Apps 脚本在 Google 表单中设置正确答案(已定义为测验)

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

我正在尝试使用 Google Apps 脚本在 Google 表单(已定义为测验)中设置正确答案

实际的Google表单可以使用

等代码定义
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')
    ]);

(摘自https://developers.google.com/apps-script/reference/forms/

有什么方法在代码中定义正确答案并为其分配分数吗?

我知道这可以手动完成...

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


目前没有设置正确答案的方法。请给问题加注星标 6143:通过 API

创建测验表格

复制

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.   ]);