刚开始使用在谷歌Apps脚本的形式服务。 需要直接的形式,根据所给出的答案采取用户到指定的页面。 这里是我当前的代码
form.addMultipleChoiceItem()
.setTitle('What would you like to do?')
.setRequired(true)
.setChoiceValues(['Request a new reservation.','Change the date or number of tickets for an existing reservation.'])
现在,我已经找到了文档中的这一部分: 枚举PageNavicationType
但他们并不例如使用GO_TO_PAGE的。 另外,ChoiceValues的创作是靠不住的我。
任何人在那里工作了这一点?
相反.setChoiceValues的要使用.setChoices([arrayOfChoices]),并使用.createChoice(值,页面)创建的选择。
编辑:更新的代码来修复错误
function createAMCQuestion(){
var af = FormApp.getActiveForm();
var pRed = af.getItemById("1300443051").asPageBreakItem(); //use findPageIds to get the page id of a pre-created page
var pGreen = af.getItemById("902629766").asPageBreakItem();
var item = af.addMultipleChoiceItem().setTitle('Pic a color?'); // creates the Multiple Choice Question
af.moveItem(item.getIndex(), 1); // Makes the question show up as the second question in the form (starts at 0)
//create choices as an array
var choices = [];
choices.push(item.createChoice('Red', pRed));
choices.push(item.createChoice('Green', pGreen));
// assignes the choices for the question
item.setChoices(choices);
}
function findPageIds(){
var af = FormApp.getActiveForm();
var pages = af.getItems(FormApp.ItemType.PAGE_BREAK);
for (i in pages){
var pName = pages[i].getTitle();
var pId = pages[i].getId();
Logger.log(pName+":"+pId);
}
}