Class RatingItem

評分項目

可讓作答者評分的問題項目。您可以透過 Form 存取或建立項目。在測驗中使用時,這些項目會經過評分。

// Open a form by ID
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');

// Get an existing rating item and access its properties.
const existingRatingItem = form.getItems(FormApp.ItemType.RATING)[0].asRatingItem();
const ratingScaleLevel = existingRatingItem.getRatingScaleLevel();
const ratingIcon = existingRatingItem.getRatingIcon();

// Create a new rating item.
const ratingItem = form.addRatingItem();

// Update the rating item's properties via chaining.
ratingItem.setRatingScaleLevel(7).setRatingIcon(FormApp.RatingIconType.HEART);

方法

方法傳回類型簡短說明
createResponse(response)ItemResponse為這個評分項目建立新的 ItemResponse
duplicate()RatingItem建立這個項目的副本,並附加到表單結尾。
getGeneralFeedback()QuizFeedback傳回受訪者回答可評分問題時看到的意見回饋。
getHelpText()String取得項目的說明文字 (有時稱為版面配置項目的說明文字,例如 ImageItemsPageBreakItemsSectionHeaderItems)。
getId()Integer取得項目的專屬 ID。
getIndex()Integer取得表單中所有項目中的項目索引。
getPoints()Integer傳回可評分項目的點數值。
getRatingIcon()RatingIconType取得為評分選擇的圖示。
getRatingScaleLevel()Integer取得評等的等級。
getTitle()String取得項目的標題 (如果是 SectionHeaderItem,有時稱為標題文字)。
getType()ItemType取得項目的類型,以 ItemType 表示。
isRequired()Boolean決定受訪者是否必須回答問題。
setGeneralFeedback(feedback)RatingItem設定作答者回答沒有正確或錯誤答案的評分問題時,系統顯示的意見回饋 (即需要手動評分的問題)。
setHelpText(text)RatingItem設定項目的說明文字 (有時稱為版面配置項目的說明文字,例如 ImageItemsPageBreakItemsSectionHeaderItems)。
setPoints(points)RatingItem設定可評分項目的分數。
setRatingIcon(ratingIcon)RatingItem設定分級圖示。
setRatingScaleLevel(ratingScaleLevel)RatingItem設定評分的最高等級。
setRequired(enabled)RatingItem設定受訪者是否必須回答問題。
setTitle(title)RatingItem設定項目的標題 (如果是 SectionHeaderItem,有時也稱為標題文字)。

內容詳盡的說明文件

createResponse(response)

為這個評分項目建立新的 ItemResponse

如果提供的 response 小於 1 或大於 getRatingScaleLevel() 傳回的值,就會擲回指令碼例外狀況。

// Open a form by ID
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');

// Get an existing rating item and create a response for it.
const item = form.getItems(FormApp.ItemType.RATING)[0].asRatingItem();
const response =item.createResponse(5);

參數

名稱類型說明
responseInteger這項評分項目的值答案。

回攻員

ItemResponse:項目回應。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

duplicate()

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

回攻員

RatingItem:這個 RatingItem 的副本,用於鏈結

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • 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()

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

回攻員

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

getRatingIcon()

取得為評分選擇的圖示。

// Open a form by ID
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');

// Get an existing rating item and get its rating icon.
const item = form.getItems(FormApp.ItemType.RATING)[0].asRatingItem();
const ratingIcon = item.getRatingIcon();

回攻員

RatingIconType - 評分圖示類型。

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

getRatingScaleLevel()

取得評等的等級。

// Open a form by ID
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');

// Get an existing rating item and get its rating scale level.
const item = form.getItems(FormApp.ItemType.RATING)[0].asRatingItem();
const ratingScaleLevel = item.getRatingScaleLevel();

回攻員

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()

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

回攻員

ItemType:項目的類型

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

  • 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)

設定作答者回答沒有正確或錯誤答案的評分問題時,系統顯示的意見回饋 (即需要手動評分的問題)。

參數

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

回攻員

RatingItem - this RatingItem,用於鏈結

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

setHelpText(text)

設定項目的說明文字 (有時稱為版面配置項目的說明文字,例如 ImageItemsPageBreakItemsSectionHeaderItems)。

參數

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

回攻員

RatingItem - this RatingItem,用於鏈結

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

setPoints(points)

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

參數

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

回攻員

RatingItem - this RatingItem,用於鏈結

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

setRatingIcon(ratingIcon)

設定評分圖示。

如果評分圖示類型無效,則會擲回指令碼例外狀況。

// Open a form by ID
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');

// Get an existing rating item and set its rating icon.
const item = form.getItems(FormApp.ItemType.RATING)[0].asRatingItem();
item.setRatingIcon(FormApp.RatingIconType.THUMB_UP);

參數

名稱類型說明
ratingIconRatingIconType評等圖示類型。

回攻員

RatingItem — This RatingItem, for chaining.

擲回

Error - 如果評分圖示類型無效

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

setRatingScaleLevel(ratingScaleLevel)

設定評分的最高等級。評分最高等級必須介於 310 之間 (含首尾)。新評分預設為 3 評分等級。

如果指定值超出允許範圍,系統會擲回指令碼例外狀況。

// Open a form by ID
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');

// Get an existing rating item and set its rating scale level.
const item = form.getItems(FormApp.ItemType.RATING)[0].asRatingItem();
item.setRatingScaleLevel(7);

參數

名稱類型說明
ratingScaleLevelInteger評分等級。

回攻員

RatingItem — This RatingItem, for chaining.

擲回

Error:如果評分等級無效

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

setRequired(enabled)

設定受訪者是否必須回答問題。

參數

名稱類型說明
enabledBoolean受訪者是否必須回答問題

回攻員

RatingItem - 目前項目 (用於鏈結)

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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

setTitle(title)

設定項目的標題 (如果是 SectionHeaderItem,有時也稱為標題文字)。

參數

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

回攻員

RatingItem - this RatingItem,用於鏈結

授權

使用這個方法的指令碼需要一或多個下列範圍的授權:

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