CheckboxItem、ListItem、MultipleChoiceItem など、選択肢をサポートする Item のタイプに関連付けられた単一の選択肢。
// 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()
回答者がこの選択肢を選択して現在のページを完了した場合に、GO_TO_PAGE の宛先として設定された PageBreakItem を取得します。このメソッドは、MultipleChoiceItems に関連付けられた選択肢にのみ適用されます。他の選択肢の場合は null を返します。
戻る
PageBreakItem - この選択肢の GO_TO_PAGE の宛先。ない場合は null
承認
このメソッドを使用するスクリプトには、次の 1 つ以上の スコープでの承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
getValue()
選択肢の値を取得します。回答者にはフォームの表示時にラベルとして表示されます。
戻る
String - 選択肢の値
承認
このメソッドを使用するスクリプトには、次の 1 つ以上の スコープでの承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms
isCorrectAnswer()
選択肢が質問の正解かどうかを取得します。このメソッドは、クイズの一部である質問にのみ適用されます。クイズ以外のフォームの場合は false を返します。
戻る
Boolean - 選択肢が正解かどうか。
承認
このメソッドを使用するスクリプトには、次の 1 つ以上の スコープでの承認が必要です。
-
https://www.googleapis.com/auth/forms.currentonly -
https://www.googleapis.com/auth/forms