【发布时间】:2020-10-02 17:19:34
【问题描述】:
这是google sheet [ESH - B1.1 - 考试 2]
Google 脚本是:examMakerQA
我对脚本非常陌生。在工作表中,我希望将 True / False 添加到多项选择题 [Col P 到 Col Z] 的选项中。这样我就不必在 Google 表单中手动添加正确答案了。
//Make Multiple-Choice question
function makeMultipleCQ(d, form){
var mcItem = form.addMultipleChoiceItem();
mcItem.setTitle(d[1]);
if(d[2] !== "N"){mcItem.setPoints(d[2])};
if(d[4] === "Y"){mcItem.setRequired(true);}
//Filter blank cells
var options = d.splice(5,10);
var options = options.filter(function(x){return x !== ""});
var corrects = d.splice(15, 20); // data with true, false
var corrects = options.filter(function(x){return x !== ""});
//Loop through options and add to question
**var ch = options.map(function(option, op){
var tf = false;
if(op === d[3]){tf = true};
return mcItem.createChoice(option, tf)**
});
mcItem.setChoices(ch);
var correctFeedback = FormApp.createFeedback()
.setText(d[3])
.build();
mcItem.setFeedbackForCorrect(correctFeedback);
}
【问题讨论】:
标签: google-apps-script google-sheets google-forms