Google forms: Assign questions to Page Break and go to page

雨燕双飞 提交于 2020-01-25 18:45:15

问题


With regard to this post, when more questions are added, to the same or different page, only the last question is correctly displayed. The other questions just show the structure (e.g. multiple choices, lists). The following code shows the problem:

function createForm() {
var title = 'Multipage Form Test';
var description = 'Stackoverflow question 17083500';

var form = FormApp.create('Questionnaire')
  .setDescription('Questionnaire')
  .setConfirmationMessage('Thanks for responding!');

var page1 = form.addPageBreakItem()
  .setTitle('First page');
var item = form.addMultipleChoiceItem();
var item = form.addListItem();
var item = form.addMultipleChoiceItem();
var page2 = form.addPageBreakItem()
  .setTitle('Second page');
var item = form.addMultipleChoiceItem();
var page3 = form.addPageBreakItem()
  .setTitle('Third page');

item.setTitle('Question')
  .setChoices([
     item.createChoice('Yes'),
     item.createChoice('No')
   ]);

item.setTitle('Question')
  .setChoices([
     item.createChoice('Yes',page2),
     item.createChoice('No',page3)
   ]);

item.setTitle('Question')
  .setChoices([
     item.createChoice('Yes'),
     item.createChoice('No')
   ]);

item.setTitle('Question')
  .setChoices([
     item.createChoice('Yes'),
     item.createChoice('No')
   ]);

Logger.log(form.getEditUrl());
Logger.log(form.getPublishedUrl());
}

How is it possible to assign and display the questions to pages correctly?

Thanks a lot for your answer, sofia p.


回答1:


Just needed to set the item choices immediately after adding each new item to the current page. All the choices were set / reassigned on just 1 item, after creating page 3.

var item = form.addMultipleChoiceItem();
item.setTitle('Question')
  .setChoices([
     item.createChoice('Yes'),
     item.createChoice('No')
   ]);

var item = form.addListItem();
item.setTitle('Question')
  .setChoices([
     item.createChoice('Yes',page2),
     item.createChoice('No',page3)
   ]);

var item = form.addMultipleChoiceItem();
item.setTitle('Question')
  .setChoices([
     item.createChoice('Yes'),
     item.createChoice('No')
   ]);


来源:https://stackoverflow.com/questions/21827488/google-forms-assign-questions-to-page-break-and-go-to-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!