我创建了一个附加组件,用于在表单中将问题和选择作为多选项导入。
问题、答案和正确答案完全导入,并在编辑视图中按预期显示,但在预览表单/测验时,某些问题缺少选项。
有什么想法吗?
function createMCQ(k) {
var form = FormApp.getActiveForm();
form.setIsQuiz(true)
.setShuffleQuestions(true)
.setAllowResponseEdits(false)
.setLimitOneResponsePerUser(false)
.setCollectEmail(true)
.setShowLinkToRespondAgain(false);
for (var i = 0, len = k.length; i < len; i++) {
var item = form.addMultipleChoiceItem();
item.setTitle(k[i].question)
.setPoints('1')
.setRequired(true)
.setChoices([
item.createChoice(String(k[i].a), Boolean(k[i].answer =='A')),
item.createChoice(String(k[i].b), Boolean(k[i].answer =='B')),
item.createChoice(String(k[i].c), Boolean(k[i].answer =='C')),
item.createChoice(String(k[i].d), Boolean(k[i].answer =='D')),
]);
}
}它是从对象导入的,如下所示;
"questions": [
{
"course": "GCSE AQA Biology",
"question": "State the equation that links magnification, image size and actual size.",
"a": "Actual Size = Image Size / Magnification",
"b": "Actual Size = Magnification / Image Size",
"c": "Actual Size = Resolution / Magnification",
"d": "Resolution = Image Size / Magnification",
"topic": "Cells",
"answer": "A",
"id": 2
},
{
"course": "GCSE AQA Biology",
"question": "Which type of microscope has higher magnification and resolving power?",
"a": "Light Microscopes",
"b": "Magnifying Glass",
"c": "Super Microscope",
"d": "Electron microscopes",
"topic": "Cells",
"answer": "D",
"id": 3
}
]项目完全导入,编辑时如图所示:

但是,在预览表单时,其中一些选项会丢失:

这是非常随机的,即不是孤立于某些问题。
任何建议都将不胜感激!
发布于 2021-01-11 02:10:28
我想我已经修好了(?)这个;
在添加多项选择项时,我首先添加了选项,然后再添加任何其他属性:
k.map(e => {
var item = form.addMultipleChoiceItem();
item.setTitle(e.question)
.setChoices([
item.createChoice(String(e.a), Boolean(e.answer =='A')),
item.createChoice(String(e.b), Boolean(e.answer =='B')),
item.createChoice(String(e.c), Boolean(e.answer =='C')),
item.createChoice(String(e.d), Boolean(e.answer =='D')),
])
.setPoints('1')
.setRequired(true);
})使用map而不是for与tho无关。
我做了一些测试,看起来答案选择不再消失了。祈祷吧!可能是Google的bug?
https://stackoverflow.com/questions/65656292
复制相似问题