可讓作答者指明日期和時間的問題項目。您可以透過 Form
存取或建立項目。但在測驗中使用時,系統會為這些項目評分。
// Open a form by ID and add a new date-time item. var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz'); var item = form.addDateTimeItem(); item.setTitle('When do you want to meet?');
方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
createResponse(response) | ItemResponse | 為這個日期時間項目建立新的 ItemResponse 。 |
duplicate() | DateTimeItem | 建立這個項目的副本,並附加到表單末尾。 |
getGeneralFeedback() | QuizFeedback | 傳回作答者在回答可評分的問題時會看到的意見回饋。 |
getHelpText() | String | 取得項目的說明文字 (有時稱為 ImageItems 、PageBreakItems 和 SectionHeaderItems 等版面配置項目的說明文字)。 |
getId() | Integer | 取得項目的專屬 ID。 |
getIndex() | Integer | 取得表單中所有項目的索引。 |
getPoints() | Integer | 傳回可評分項目的分數值。 |
getTitle() | String | 取得項目的標題 (在 SectionHeaderItem 中則稱為標題文字)。 |
getType() | ItemType | 取得項目的類型,以 ItemType 表示。 |
includesYear() | Boolean | 決定日期項目是否包含年份選項。 |
isRequired() | Boolean | 決定作答者是否必須回答問題。 |
setGeneralFeedback(feedback) | DateTimeItem | 設定在作答者回覆的可評分問題沒有正確或不正確答案 (也就是需要手動評分的問題) 時,向作答者顯示意見回饋。 |
setHelpText(text) | DateTimeItem | 設定項目的說明文字 (有時稱為 ImageItems 、PageBreakItems 和 SectionHeaderItems 等版面配置項目的說明文字)。 |
setIncludesYear(enableYear) | DateTimeItem | 設定日期項目是否包含年份設定。 |
setPoints(points) | DateTimeItem | 設定可評分項目的價值分數。 |
setRequired(enabled) | DateTimeItem | 設定作答者是否必須回答問題。 |
setTitle(title) | DateTimeItem | 設定項目的標題 (在 SectionHeaderItem 中也稱為標題文字)。 |
內容詳盡的說明文件
createResponse(response)
為這個日期時間項目建立新的 ItemResponse
。Date
物件的秒數欄位會遭到忽略。根據預設,系統會使用年、月、日、小時和分鐘欄位。如果將 setIncludesYear(enabled)
設為 false
,系統就會忽略年份。
參數
名稱 | 類型 | 說明 |
---|---|---|
response | Date | Date 物件,代表月、日、時、分鐘或可能年 |
回攻員
ItemResponse
:項目回應
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
duplicate()
建立這個項目的副本,並附加到表單末尾。
回攻員
DateTimeItem
— 此 DateTimeItem
的重複項目,用於鏈結
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getGeneralFeedback()
傳回作答者在回答可評分的問題時會看到的意見回饋。
回攻員
QuizFeedback
:意見回饋 (如果有的話)。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getHelpText()
取得項目的說明文字 (有時稱為 ImageItems
、PageBreakItems
和 SectionHeaderItems
等版面配置項目的說明文字)。
回攻員
String
:商品的說明文字或說明文字
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getId()
取得項目的專屬 ID。
回攻員
Integer
:項目的 ID
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getIndex()
取得表單中所有項目的索引。
回攻員
Integer
:項目的索引
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getPoints()
傳回可評分項目的分數值。
回攻員
Integer
:問題可獲得的分數。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getTitle()
取得項目的標題 (在 SectionHeaderItem
中則稱為標題文字)。
回攻員
String
:項目的標題或標題文字
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
getType()
includesYear()
決定日期項目是否包含年份選項。
回攻員
Boolean
— true
如果日期包含年份設定,false
若不是
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
isRequired()
決定作答者是否必須回答問題。
回攻員
Boolean
:作答者是否須回答問題
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setGeneralFeedback(feedback)
設定在作答者回覆的可評分問題沒有正確或不正確答案 (也就是需要手動評分的問題) 時,向作答者顯示意見回饋。
參數
名稱 | 類型 | 說明 |
---|---|---|
feedback | QuizFeedback | 新的意見回饋 |
回攻員
DateTimeItem
— 此 DateTimeItem
,用於鏈結
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setHelpText(text)
設定項目的說明文字 (有時稱為 ImageItems
、PageBreakItems
和 SectionHeaderItems
等版面配置項目的說明文字)。
參數
名稱 | 類型 | 說明 |
---|---|---|
text | String | 新的說明文字 |
回攻員
DateTimeItem
— 此 DateTimeItem
,用於鏈結
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setIncludesYear(enableYear)
設定日期項目是否包含年份設定。新日期項目的預設值是 true
。
參數
名稱 | 類型 | 說明 |
---|---|---|
enableYear | Boolean | 如果日期包含年份設定,則為 true ;如果不是,則為 false |
回攻員
DateTimeItem
— 此 DateTimeItem
,用於鏈結
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setPoints(points)
設定可評分項目的價值分數。新項目的預設值是 0。
參數
名稱 | 類型 | 說明 |
---|---|---|
points | Integer | 問題項目的價值分數 |
回攻員
DateTimeItem
— 此 DateTimeItem
,用於鏈結
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setRequired(enabled)
設定作答者是否必須回答問題。
參數
名稱 | 類型 | 說明 |
---|---|---|
enabled | Boolean | 作答者是否必須回答 |
回攻員
DateTimeItem
:目前的項目 (用於鏈結)
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms
setTitle(title)
設定項目的標題 (在 SectionHeaderItem
中也稱為標題文字)。
參數
名稱 | 類型 | 說明 |
---|---|---|
title | String | 新的標題或標題文字 |
回攻員
DateTimeItem
— 此 DateTimeItem
,用於鏈結
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/forms.currentonly
-
https://www.googleapis.com/auth/forms