與支援選項的 Item 類型 (例如 Checkbox、List 或 Multiple) 相關聯的單一選項。
// 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 | 如果答覆者選取這個選項並完成目前的頁面,就會取得設為 GO_TO_PAGE 目的地的 Page。 |
get | Page | 取得作答者選取這個選項並完成目前網頁時,所發生的 Page。 |
get | String | 取得選項的值,作答者在查看表單時會看到該值做為標籤。 |
is | Boolean | 取得選項是否為問題的正確答案。 |
內容詳盡的說明文件
get Goto Page()
如果答覆者選取這個選項並完成目前的頁面,系統會取得 Page 並設為 GO_TO_PAGE 目的地。此方法僅適用於與 Multiple 相關聯的選項;對於其他選項,則會傳回 null。
回攻員
Page:這個選項的 GO_TO_PAGE 目的地,如果沒有則為 null
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
get Value()
取得選項的值,作答者在查看表單時會看到該值做為標籤。
回攻員
String - 選擇的值
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
is Correct Answer()
取得選擇是否為問題的正確答案。這個方法只適用於測驗中的題目;如果是測驗以外的表單,則會傳回 false。
回攻員
Boolean:選擇的選項是否為正確答案。
授權
使用這個方法的腳本需要具備下列一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms