Google apps script 使用应用程序脚本生成带有随机数的测验

Google apps script 使用应用程序脚本生成带有随机数的测验,google-apps-script,google-forms,google-form-quiz,Google Apps Script,Google Forms,Google Form Quiz,我已经编写了一些创建谷歌表单的应用程序脚本代码。表格上的问题包含随机数,例如: function question_1 () { var a = getRandomInt(1,10); var b = getRandomInt(1,10); var question_string = "What is " + a + " + " + b + '?'; var ans = a + b; return [question_string, ans];

我已经编写了一些创建谷歌表单的应用程序脚本代码。表格上的问题包含随机数,例如:

function question_1 () {
     var a = getRandomInt(1,10);
     var b = getRandomInt(1,10);

     var question_string = "What is " + a + " + " + b + '?';
     var ans = a + b;
     return [question_string, ans];
 }

function create_quiz () {
     var form = FormApp.create("Quiz");

     var item = form.addMultipleChoiceItem();
     q1 = question_1()

     var question = q1[0]
     var answer = q1[1]

     item.setTitle(question)
     item.setChoices([
          item.createChoice(answer), 
          item.createChoice(answer+1),
          item.createChoice(answer-1)
     ]);
}
我想设置表单,以便正确回答问题,例如,添加以下内容

   item.setResponse(answer)
这样,在学生完成测验后,测验可以自动评分

有人能建议我需要进行什么API调用(以及在哪里)来实现这一点吗

更新:2017年4月,谷歌宣布现在可以通过编程方式创建谷歌表单测验



目前,来自Google Apps脚本的表单服务不包括处理测验响应的类/方法。您可以在

上查找所有可用的类和方法,使用表单提交触发器,检查值,并在触发器函数中进行验证。