Class DurationItem

時間長度

讓作答者指定長度的問題項目。項目可以從 Form 存取或建立。在測驗中使用時,系統會對這些項目評分。

// Open a form by ID and add a new duration item.
var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
var item = form.addDurationItem();
item.setTitle('How long can you hold your breath?');

方法

方法傳回類型簡短說明
createResponse(hours, minutes, seconds)ItemResponse為這個日期項目建立新的 ItemResponse
duplicate()DurationItem建立這個項目的副本,然後附加到表單結尾。
getGeneralFeedback()QuizFeedback傳回作答者在可評分成績時看到的回應。
getHelpText()String取得商品的說明文字 (有時為版面配置項目的說明文字,例如 ImageItemsPageBreakItemsSectionHeaderItems)。
getId()Integer取得商品的專屬 ID。
getIndex()Integer取得表單中所有商品的索引。
getPoints()Integer傳回可評分項目的分數值。
getTitle()String取得商品標題 (有時為 SectionHeaderItem 標頭)。
getType()ItemType取得項目類型,以 ItemType 表示。
isRequired()Boolean判斷作答者是否需要回答問題。
setGeneralFeedback(feedback)DurationItem讓作答者在沒有正確答案或正確答案 (例如需要手動評分的問題) 的情況下,針對作答者顯示意見回饋。
setHelpText(text)DurationItem設定項目的說明文字 (有時是指 ImageItemsPageBreakItemsSectionHeaderItems 等版面配置項目的說明文字)。
setPoints(points)DurationItem設定可評分項目的數值。
setRequired(enabled)DurationItem設定作答者是否需要回答問題。
setTitle(title)DurationItem設定項目標題 (有時在 SectionHeaderItem 中稱為標題文字)。

內容詳盡的說明文件

createResponse(hours, minutes, seconds)

為這個日期項目建立新的 ItemResponse。引數 hoursminutesseconds 最佳表示為 072 的整數,0 則為 minutes59seconds 適用於 minutes。超過這些邊界的值會被裁剪:例如,24, 60, 90 被解讀為 24:59:59。

參數

名稱類型說明
hoursInteger小時,以 072 的整數表示
minutesInteger分鐘數,以 059 之間的整數表示
secondsInteger秒,以 059 之間的整數表示

Return 鍵

ItemResponse:項目回應

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

duplicate()

建立這個項目的副本,然後附加到表單結尾。

Return 鍵

DurationItem:與這個 DurationItem 重複,用於鏈結

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getGeneralFeedback()

傳回作答者在可評分成績時看到的回應。

Return 鍵

QuizFeedback:意見回饋 (如果有的話)。

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getHelpText()

取得商品的說明文字 (有時為版面配置項目的說明文字,例如 ImageItemsPageBreakItemsSectionHeaderItems)。

Return 鍵

String:項目的說明文字或說明文字

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getId()

取得商品的專屬 ID。

Return 鍵

Integer:該項目的 ID

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getIndex()

取得表單中所有商品的索引。

Return 鍵

Integer:項目的索引

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getPoints()

傳回可評分項目的分數值。

Return 鍵

Integer:每個問題的相關價值。

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getTitle()

取得商品標題 (有時為 SectionHeaderItem 標頭)。

Return 鍵

String:項目的標題或標題文字

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

getType()

取得項目類型,以 ItemType 表示。

Return 鍵

ItemType:項目類型

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

isRequired()

判斷作答者是否需要回答問題。

Return 鍵

Boolean — 作答者必須回答問題

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setGeneralFeedback(feedback)

讓作答者在沒有正確答案或正確答案 (例如需要手動評分的問題) 的情況下,針對作答者顯示意見回饋。

參數

名稱類型說明
feedbackQuizFeedback新的意見回饋

Return 鍵

DurationItem — 這個 DurationItem 用於鏈結

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setHelpText(text)

設定項目的說明文字 (有時是指 ImageItemsPageBreakItemsSectionHeaderItems 等版面配置項目的說明文字)。

參數

名稱類型說明
textString新的說明文字

Return 鍵

DurationItem — 這個 DurationItem 用於鏈結

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setPoints(points)

設定可評分項目的數值。新項目的預設值為 0。

參數

名稱類型說明
pointsInteger問題項目的分數

Return 鍵

DurationItem — 這個 DurationItem 用於鏈結

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setRequired(enabled)

設定作答者是否需要回答問題。

參數

名稱類型說明
enabledBoolean作答者是否需要回答問題

Return 鍵

DurationItem:目前的項目 (用於鏈結)

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms

setTitle(title)

設定項目標題 (有時在 SectionHeaderItem 中稱為標題文字)。

參數

名稱類型說明
titleString新的標題或標題文字

Return 鍵

DurationItem — 這個 DurationItem 用於鏈結

授權

如果指令碼使用這個方法,就必須符合下列一或多個範圍的授權:

  • https://www.googleapis.com/auth/forms.currentonly
  • https://www.googleapis.com/auth/forms