與支援選項的 Item 類型相關聯的單一選項,例如 CheckboxItem、ListItem 或 MultipleChoiceItem。
// Create a new form and add a multiple-choice item. const form = FormApp.create('Form Name'); const 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. const choices = item.getChoices(); for (let i = 0; i < choices.length; i++) { Logger.log( 'If the respondent chooses "%s", the form will %s.', choices[i].getValue(), choices[i].getPageNavigationType(), ); }
方法
| 方法 | 傳回類型 | 簡短說明 |
|---|---|---|
get | Page | 如果回覆者選取這個選項並完成目前頁面,系統會將 Page 設為GO_TO_PAGE目的地。 |
get | Page | 取得回應者選取這個選項並完成目前頁面時發生的 Page。 |
get | String | 取得選項的值,作答者查看表單時會看到這個值做為標籤。 |
is | 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