與支援選項的 Item
類型相關聯的單一選項,例如 CheckboxItem
、ListItem
或 MultipleChoiceItem
。
// Create a new form and add a multiple-choice item. var form = FormApp.create('Form Name'); var item = form.addMultipleChoiceItem(); item.setTitle('Do you prefer cats or dogs?') .setChoices([ item.createChoice('Cats', FormApp.PageNavigationType.CONTINUE), item.createChoice('Dogs', FormApp.PageNavigationType.RESTART) ]); // Add another page because navigation has no effect on the last page. form.addPageBreakItem().setTitle('You chose well!'); // Log the navigation types that each choice results in. var choices = item.getChoices(); for (var i = 0; i < choices.length; i++) { Logger.log('If the respondent chooses "%s", the form will %s.', choices[i].getValue(), choices[i].getPageNavigationType()); }
方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
getGotoPage() | PageBreakItem | 如果作答者選擇此選項並完成目前的頁面,就會取得 PageBreakItem 設為 GO_TO_PAGE 目的地。 |
getPageNavigationType() | PageNavigationType | 在作答者選取這個選項並完成目前頁面時,取得 PageNavigationType 。 |
getValue() | String | 取得選項的值,作答者會在檢視表單時顯示為標籤。 |
isCorrectAnswer() | Boolean | 指定該選項是否為正確答案。 |
內容詳盡的說明文件
getGotoPage()
如果作答者選擇此選項並完成目前的頁面,就會取得 PageBreakItem
設為 GO_TO_PAGE
目的地。這個方法僅適用於與 MultipleChoiceItems
相關聯的選項;如果是其他選項,則會傳回 null
。
回攻員
PageBreakItem
:這個選項的 GO_TO_PAGE
目的地;如果沒有,則傳回 null
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getValue()
取得選項的值,作答者會在檢視表單時顯示為標籤。
回攻員
String
:選項的值
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
isCorrectAnswer()
指定該選項是否為正確答案。這個方法僅適用於測驗中的問題;如果是非測驗表單,則會傳回 false。
回攻員
Boolean
:該選項是否為正確答案。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms