2025年5月8日木曜日

Google Formsで時刻の質問を作りたい


今回は「時刻」の質問について書いていきます


フォームの編集画面

質問の種類で「時刻」を選択します



入力項目に値を入力します




フォームの回答画面

時刻の入力欄が表示されます





Apps Script で作成する場合

以下の Code.gs で formName, description, title, helpText の値を書き換えて

createTimeQuestion() を実行すると

編集用のURLがログに出力されます



Code.gs
function createTimeQuestion() {
const formName = 'Motivation Survey';
const description = 'Please answer the following question.';
const title = 'What time do you usually start your self-motivated activity?';
const helpText = 'Please enter the time';

const form = FormApp.create(formName);
form.setDescription(description);
form.addTimeItem()
.setTitle(title)
.setHelpText(helpText)
.setRequired(false);
form.setPublished(false);
Logger.log('Form Edit URL: ' + form.getEditUrl());
}


Reference

addTimeItem()