【发布时间】:2021-01-26 09:07:57
【问题描述】:
我正在尝试掌握以编程方式创建 Google 表单,但无法将选项分配给多项选择项。我可以创建项目 (testQuestion) 并为其命名,但我的 createChoice() 语句不添加选项。
这是我的代码,基于https://developers.google.com/apps-script/reference/forms/page-navigation-type
function testCreateChoices() {
/* modification of
testPageNavigation()
to see how to import choices from a range on sheet
*/
// Create a form
var form = FormApp.create('createChoice Test');
// add a multiple-choice item
var testQuestion = form.addMultipleChoiceItem();
testQuestion.setTitle('Anything here?');
var whatsis = testQuestion.createChoice('bozzle');
var firstChoice = testQuestion.createChoice('this');
testQuestion.createChoice("that");
testQuestion.createChoice("the other");
testQuestion.createChoice("Ouch!");
//add a new multiple-choice item and a pagebreak item
var item = form.addMultipleChoiceItem();
var pageBreak = form.addPageBreakItem();
// Set some choices with go-to-page logic.
var rightChoice = item.createChoice('Vanilla', FormApp.PageNavigationType.SUBMIT);
var wrongChoice = item.createChoice('Chocolate', FormApp.PageNavigationType.RESTART);
// For GO_TO_PAGE, just pass in the page break item. For CONTINUE (normally the default), pass in
// CONTINUE explicitly because page navigation cannot be mixed with non-navigation choices.
var iffyChoice = item.createChoice('Peanut', pageBreak);
var otherChoice = item.createChoice('Strawberry', FormApp.PageNavigatio[enter image description here][1]nType.CONTINUE);
item.setChoices([rightChoice, wrongChoice, iffyChoice, otherChoice]);
}
这是我得到的,没有显示“bozzle”等选项,以及我想要但无法创建的图像。
非常感谢您的帮助!
Here's a screenshot, with no labels/choices under "Anything here?"
【问题讨论】:
-
您无法添加选项到底是什么意思?如果我运行您共享的代码,我就能成功地看到这些选项。您是否介意分享所需结果的屏幕截图?
-
我已经编辑了问题,添加了截图。当您运行 c 代码时,您是否在“Anything here”下看到了预期的选择?我从帖子中重新复制了代码,但该问题下仍然没有标签。
标签: google-apps-script google-forms