LoginSignup
1
4

More than 1 year has passed since last update.

GASでGoogleフォームを作成する

Posted at

GASでGoogleフォームを作成する

はじめに

GASでGoogleフォームを作成したことがあったのでそれのメモ。

ソースコード

フォーム作成

var form = FormApp.create('タイトル');
form.setDescription('説明');
// 回答進捗を表すバーを表示する
form.setProgressBar(true);  

チェックボックス

var checkBox = form.addCheckboxItem();
checkBox.setTitle('質問名');
checkBox.setHelpText('補足説明');
// チェックボックスの項目
var choices = ['項目1', '項目2', '項目3', '項目4', '項目5'];
checkBox.setChoiceValues(choices);
// その他
checkBox.showOtherOption(true); 
// 回答を必須にする場合
checkBox.setRequired(true);

プルダウン

var pullDown = form.addListItem();
pullDown.setTitle('質問名');
pullDown.setHelpText('補足説明');
var arr = ['AAA','BBB','CCC','DDD','EEE'];
pullDown.setChoiceValues(arr);

段落

var paragraph = form.addParagraphTextItem();
paragraph.setTitle('質問名');
paragraph.setHelpText('補足説明');

ラジオボタン

var multiple = form.addMultipleChoiceItem();
multiple.setTitle('あなたは好きですか?');
var choices = ['はい','いいえ'];
multiple.setChoiceValues(choices);
multiple.setRequired(true);

均等目盛(どっちに近いかを選択させるやつ)

var scale = form.addScaleItem();
scale.setTitle('このQiitaはためになりますか');
// 目盛の数
scale.setBounds(1, 5);
scale.setLabels('ためにならない', 'ためになる');

セクション分け

// このメソッドでセクションが分かれる
form.addPageBreakItem();

おわりに

上記以外の形式は使ったことがないのでリファレンス参照してください。

参考

Form 公式リファレンス

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4