Class ParagraphTextItem

段落文本

一种允许答题者输入一段文字的问题项。可以从 Form 访问或创建项。在测验中使用时,这些项目会进行评分。

// Open a form by ID and add a new paragraph text item.
const form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
const item = form.addParagraphTextItem();
item.setTitle('What is your address?');

方法

方法返回类型简介
clearValidation()ParagraphTextItem移除相应段落文本项的所有数据验证。
createResponse(response)ItemResponse为此段落文本项创建新的 ItemResponse
duplicate()ParagraphTextItem创建此题目的副本并将其附加到表单末尾。
getGeneralFeedback()QuizFeedback返回向答题者显示的反馈,前提是答题者回答的是可评分的问题。
getHelpText()String获取商品的帮助文本(有时称为布局项(如 ImageItemsPageBreakItemsSectionHeaderItems)的说明文本)。
getId()Integer获取商品的唯一标识符。
getIndex()Integer获取表单中相应商品在所有商品中的索引。
getPoints()Integer返回可评分项目的分数。
getTitle()String获取商品的标题(如果是 SectionHeaderItem,则有时称为标题文字)。
getType()ItemType获取以 ItemType 表示的商品类型。
isRequired()Boolean确定答题者是否必须回答相应问题。
setGeneralFeedback(feedback)ParagraphTextItem设置在回复者回答没有正确或错误答案的可评分问题(即需要人工评分的问题)时向其显示的反馈。
setHelpText(text)ParagraphTextItem设置商品的帮助文本(有时称为布局项(如 ImageItemsPageBreakItemsSectionHeaderItems)的说明文本)。
setPoints(points)ParagraphTextItem设置可评分项目的分值。
setRequired(enabled)ParagraphTextItem设置答题者是否必须回答相应问题。
setTitle(title)ParagraphTextItem设置商品的标题(如果是 SectionHeaderItem,有时称为标题文字)。
setValidation(validation)ParagraphTextItem为此段落文本项设置数据验证。

详细文档

clearValidation()

移除相应段落文本项的所有数据验证。

返回

ParagraphTextItem - 此 ParagraphTextItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

createResponse(response)

为此段落文本项创建新的 ItemResponse

参数

名称类型说明
responseString商品提出的问题的答案

返回

ItemResponse - 商品响应

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

duplicate()

创建此题目的副本并将其附加到表单末尾。

返回

ParagraphTextItem - 此 ParagraphTextItem 的副本,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

获取商品的唯一标识符。

返回

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

获取以 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新反馈

返回

ParagraphTextItem - 此 ParagraphTextItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

setHelpText(text)

设置商品的帮助文本(有时称为布局项(如 ImageItemsPageBreakItemsSectionHeaderItems)的说明文本)。

参数

名称类型说明
textString新帮助文本

返回

ParagraphTextItem - 此 ParagraphTextItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

setPoints(points)

设置可评分项目的分值。新商品的默认值为 0。

参数

名称类型说明
pointsInteger问题项的分值

返回

ParagraphTextItem - 此 ParagraphTextItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

setRequired(enabled)

设置答题者是否必须回答相应问题。

参数

名称类型说明
enabledBoolean受访者是否必须回答相应问题

返回

ParagraphTextItem - 当前项(用于链式调用)

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

setTitle(title)

设置商品的标题(如果是 SectionHeaderItem,有时称为标题文字)。

参数

名称类型说明
titleString新标题或标题文字

返回

ParagraphTextItem - 此 ParagraphTextItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

setValidation(validation)

为此段落文本项设置数据验证。传入 null 或未调用任何 require 函数的 ParagraphTextValidation 实例会移除任何先前的验证。

参数

名称类型说明
validationParagraphTextValidation要应用于相应项的 ParagraphTextValidation。

返回

ParagraphTextItem - 此 ParagraphTextItem,用于链式调用

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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