如何使用脚本从电子表格中设置Google表单中的正确答案文本 [英] How to set correct answer text in google forms from spreadsheet using script
本文介绍了如何使用脚本从电子表格中设置Google表单中的正确答案文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Google表单进行自动评分的简短回答测验.
I want to make auto-grading short-answer quiz using google forms.
数据在电子表格中.
- A栏有疑问.
- 列B有正确答案.
- C列有解释.
下面的代码可以进行测验,但请不要在每个问题中设置正确的答案.
The code below makes quiz, but don't set correct answer in each question.
"item.createResponse(an);"似乎不起作用.
"item.createResponse(an);" seems not working.
如何设置正确答案?
let form = FormApp.openById(formID);
form.setIsQuiz(true);
// get data from sheet
let ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('문제');
let range = ss.getDataRange();
let data = range.getValues()
data.forEach(function(el){
// data
let qu = el[0]; //question
let an = el[1].trim().toUpperCase(); //correct answer
let ex = el[2]; //explanation
// create each question
let item = form.addTextItem();
item.setPoints(1);
item.setTitle(qu);
// create correct answer
item.createResponse(an);
// create explanation
let exp = FormApp.createFeedback().setText(ex).build();
if(ex != '') {
item.setGeneralFeedback(exp);
}
})
推荐答案
It's not possible to set correct answers for Text items using the Apps Script. It's only possible from the user interface.
已在Google的问题跟踪器中进行了请求.您可以单击问题编号旁边的星号,以接收更新并为请求赋予更高的优先级.
It has been requested on Google's Issue Tracker. You can click on the star next to the issue number to receive updates and to give more priority to the request.
这篇关于如何使用脚本从电子表格中设置Google表单中的正确答案文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文