Forms Service

Forms

This service allows scripts to create, access, and modify Google Forms.

// Create a new form, then add a checkbox question, a multiple choice question,
// a page break, then a date question and a grid of questions.
var form = FormApp.create('New Form');
var item = form.addCheckboxItem();
item.setTitle('What condiments would you like on your hot dog?');
item.setChoices([
        item.createChoice('Ketchup'),
        item.createChoice('Mustard'),
        item.createChoice('Relish')
    ]);
form.addMultipleChoiceItem()
    .setTitle('Do you prefer cats or dogs?')
    .setChoiceValues(['Cats','Dogs'])
    .showOtherOption(true);
form.addPageBreakItem()
    .setTitle('Getting to know you');
form.addDateItem()
    .setTitle('When were you born?');
form.addGridItem()
    .setTitle('Rate your interests')
    .setRows(['Cars', 'Computers', 'Celebrities'])
    .setColumns(['Boring', 'So-so', 'Interesting']);
Logger.log('Published URL: ' + form.getPublishedUrl());
Logger.log('Editor URL: ' + form.getEditUrl());

Classes

NameBrief description
AlignmentAn enum representing the supported types of image alignment.
CheckboxGridItemA question item, presented as a grid of columns and rows, that allows the respondent to select multiple choices per row from a sequence of checkboxes.
CheckboxGridValidationA DataValidation for a CheckboxGridItem.
CheckboxGridValidationBuilderA DataValidationBuilder for a CheckboxGridValidation.
CheckboxItemA question item that allows the respondent to select one or more checkboxes, as well as an optional "other" field.
CheckboxValidationA DataValidation for a CheckboxItem.
CheckboxValidationBuilderA DataValidationBuilder for a CheckboxValidation.
ChoiceA single choice associated with a type of Item that supports choices, like CheckboxItem, ListItem, or MultipleChoiceItem.
DateItemA question item that allows the respondent to indicate a date.
DateTimeItemA question item that allows the respondent to indicate a date and time.
DestinationTypeAn enum representing the supported types of form-response destinations.
DurationItemA question item that allows the respondent to indicate a length of time.
FeedbackTypeAn enum representing the supported types of feedback.
FormA form that contains overall properties and items.
FormAppAllows a script to open an existing Form or create a new one.
FormResponseA response to the form as a whole.
GridItemA question item, presented as a grid of columns and rows, that allows the respondent to select one choice per row from a sequence of radio buttons.
GridValidationA DataValidation for a GridItem.
GridValidationBuilderA DataValidationBuilder for a GridValidation.
ImageItemA layout item that displays an image.
ItemA generic form item that contains properties common to all items, such as title and help text.
ItemResponseA response to one question item within a form.
ItemTypeAn enum representing the supported types of form items.
ListItemA question item that allows the respondent to select one choice from a drop-down list.
MultipleChoiceItemA question item that allows the respondent to select one choice from a list of radio buttons or an optional "other" field.
PageBreakItemA layout item that marks the start of a page.
PageNavigationTypeAn enum representing the supported types of page navigation.
ParagraphTextItemA question item that allows the respondent to enter a block of text.
ParagraphTextValidationA DataValidation for a ParagraphTextItem.
ParagraphTextValidationBuilderA DataValidationBuilder for a ParagraphTextValidation.
QuizFeedbackThe bean implementation of a Feedback, which contains properties common to all feedback, such as display text or links.
QuizFeedbackBuilderThe base FeedbackBuilder that contains setters for properties common to all feedback, such as display text.
ScaleItemA question item that allows the respondent to choose one option from a numbered sequence of radio buttons.
SectionHeaderItemA layout item that visually indicates the start of a section.
TextItemA question item that allows the respondent to enter a single line of text.
TextValidationA DataValidation for a TextItem.
TextValidationBuilderA DataValidationBuilder for a TextValidation.
TimeItemA question item that allows the respondent to indicate a time of day.
VideoItemA layout item that displays a video.

Alignment

Properties

PropertyTypeDescription
LEFTEnumAlign the image to the left side of the form.
CENTEREnumAlign the image to the center of the form.
RIGHTEnumAlign the image to the right side of the form.

CheckboxGridItem

Methods

MethodReturn typeBrief description
clearValidation()CheckboxGridItemRemoves any data validation for this grid item.
createResponse(responses)ItemResponseCreates a new ItemResponse for this checkbox grid item.
duplicate()CheckboxGridItemCreates a copy of this item and appends it to the end of the form.
getColumns()String[]Gets the values for every column in the grid.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getRows()String[]Gets the values for every row in the grid.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
isRequired()BooleanDetermines whether the respondent must answer the question.
setColumns(columns)CheckboxGridItemSets the columns of the grid based on an array of values.
setHelpText(text)CheckboxGridItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setRequired(enabled)CheckboxGridItemSets whether the respondent must answer the question.
setRows(rows)CheckboxGridItemSets the rows of the grid based on an array of values.
setTitle(title)CheckboxGridItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
setValidation(validation)CheckboxGridItemSets the data validation for this checkbox grid item.

CheckboxGridValidation

CheckboxGridValidationBuilder

Methods

MethodReturn typeBrief description
requireLimitOneResponsePerColumn()CheckboxGridValidationBuilderRequires limit of one response per column for a grid item.

CheckboxItem

Methods

MethodReturn typeBrief description
clearValidation()CheckboxItemRemoves any data validation for this checkbox item.
createChoice(value)ChoiceCreates a new choice.
createChoice(value, isCorrect)ChoiceCreates a new choice.
createResponse(responses)ItemResponseCreates a new ItemResponse for this checkbox item.
duplicate()CheckboxItemCreates a copy of this item and appends it to the end of the form.
getChoices()Choice[]Gets all choices for an item.
getFeedbackForCorrect()QuizFeedbackReturns the feedback that is shown to respondents when they respond correctly to a question.
getFeedbackForIncorrect()QuizFeedbackReturns the feedback that is shown to respondents when they respond incorrectly to a question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
hasOtherOption()BooleanDetermines whether the item has an "other" option.
isRequired()BooleanDetermines whether the respondent must answer the question.
setChoiceValues(values)CheckboxItemSets the choices for an item from an array of strings.
setChoices(choices)CheckboxItemSets an array of choices for an item.
setFeedbackForCorrect(feedback)CheckboxItemSets the feedback to be shown to respondents when they respond correctly to a question.
setFeedbackForIncorrect(feedback)CheckboxItemSets the feedback to be shown to respondents when they respond incorrectly to a question.
setHelpText(text)CheckboxItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setPoints(points)CheckboxItemSets the number of points a gradeable item is worth.
setRequired(enabled)CheckboxItemSets whether the respondent must answer the question.
setTitle(title)CheckboxItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
setValidation(validation)CheckboxItemSets the data validation for this checkbox item.
showOtherOption(enabled)CheckboxItemSets whether the item has an "other" option.

CheckboxValidation

CheckboxValidationBuilder

Methods

MethodReturn typeBrief description
requireSelectAtLeast(number)CheckboxValidationBuilderRequire at least this many choices to be selected.
requireSelectAtMost(number)CheckboxValidationBuilderRequire at most this many choices to be selected.
requireSelectExactly(number)CheckboxValidationBuilderRequire exactly this many choices to be selected.

Choice

Methods

MethodReturn typeBrief description
getGotoPage()PageBreakItemGets the PageBreakItem set as a GO_TO_PAGE destination if the responder selects this choice and completes the current page.
getPageNavigationType()PageNavigationTypeGets the PageNavigationType that occurs if the responder selects this choice and completes the current page.
getValue()StringGets the choice's value, which respondents see as a label when viewing the form.
isCorrectAnswer()BooleanGets whether the choice is a correct answer for the question.

DateItem

Methods

MethodReturn typeBrief description
createResponse(response)ItemResponseCreates a new ItemResponse for this date item.
duplicate()DateItemCreates a copy of this item and appends it to the end of the form.
getGeneralFeedback()QuizFeedbackReturns the feedback that is shown to respondents when they respond to a gradeable question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
includesYear()BooleanDetermines whether the date item includes a year option.
isRequired()BooleanDetermines whether the respondent must answer the question.
setGeneralFeedback(feedback)DateItemSets the feedback to be shown to respondents when they respond to a gradeable question that doesn't have a correct or incorrect answer (ie questions that require manual grading).
setHelpText(text)DateItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setIncludesYear(enableYear)DateItemSets whether the date item includes a year setting.
setPoints(points)DateItemSets the number of points a gradeable item is worth.
setRequired(enabled)DateItemSets whether the respondent must answer the question.
setTitle(title)DateItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

DateTimeItem

Methods

MethodReturn typeBrief description
createResponse(response)ItemResponseCreates a new ItemResponse for this date-time item.
duplicate()DateTimeItemCreates a copy of this item and appends it to the end of the form.
getGeneralFeedback()QuizFeedbackReturns the feedback that is shown to respondents when they respond to a gradeable question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
includesYear()BooleanDetermines whether the date item includes a year option.
isRequired()BooleanDetermines whether the respondent must answer the question.
setGeneralFeedback(feedback)DateTimeItemSets the feedback to be shown to respondents when they respond to a gradeable question that doesn't have a correct or incorrect answer (ie questions that require manual grading).
setHelpText(text)DateTimeItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setIncludesYear(enableYear)DateTimeItemSets whether the date item includes a year setting.
setPoints(points)DateTimeItemSets the number of points a gradeable item is worth.
setRequired(enabled)DateTimeItemSets whether the respondent must answer the question.
setTitle(title)DateTimeItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

DestinationType

Properties

PropertyTypeDescription
SPREADSHEETEnumA Google Sheets spreadsheet as a destination for form responses.

DurationItem

Methods

MethodReturn typeBrief description
createResponse(hours, minutes, seconds)ItemResponseCreates a new ItemResponse for this date item.
duplicate()DurationItemCreates a copy of this item and appends it to the end of the form.
getGeneralFeedback()QuizFeedbackReturns the feedback that is shown to respondents when they respond to a gradeable question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
isRequired()BooleanDetermines whether the respondent must answer the question.
setGeneralFeedback(feedback)DurationItemSets the feedback to be shown to respondents when they respond to a gradeable question that doesn't have a correct or incorrect answer (ie questions that require manual grading).
setHelpText(text)DurationItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setPoints(points)DurationItemSets the number of points a gradeable item is worth.
setRequired(enabled)DurationItemSets whether the respondent must answer the question.
setTitle(title)DurationItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

FeedbackType

Properties

PropertyTypeDescription
CORRECTEnumFeedback that is automatically displayed to respondents for a question answered correctly.
INCORRECTEnumFeedback that is automatically displayed to respondents for a question answered incorrectly.
GENERALEnumFeedback that is automatically displayed to respondents when they submit their response.

Form

Methods

MethodReturn typeBrief description
addCheckboxGridItem()CheckboxGridItemAppends a new question item, presented as a grid of columns and rows, that allows the respondent to select multiple choices per row from a sequence of checkboxes.
addCheckboxItem()CheckboxItemAppends a new question item that allows the respondent to select one or more checkboxes, as well as an optional "other" field.
addDateItem()DateItemAppends a new question item that allows the respondent to indicate a date.
addDateTimeItem()DateTimeItemAppends a new question item that allows the respondent to indicate a date and time.
addDurationItem()DurationItemAppends a new question item that allows the respondent to indicate a length of time.
addEditor(emailAddress)FormAdds the given user to the list of editors for the Form.
addEditor(user)FormAdds the given user to the list of editors for the Form.
addEditors(emailAddresses)FormAdds the given array of users to the list of editors for the Form.
addGridItem()GridItemAppends a new question item, presented as a grid of columns and rows, that allows the respondent to select one choice per row from a sequence of radio buttons.
addImageItem()ImageItemAppends a new layout item that displays an image.
addListItem()ListItemAppends a new question item that allows the respondent to select one choice from a dropdown list.
addMultipleChoiceItem()MultipleChoiceItemAdds a new question item that allows the respondent to select one choice from a list of radio buttons or an optional "other" field.
addPageBreakItem()PageBreakItemAdds a new layout item that marks the start of a page.
addParagraphTextItem()ParagraphTextItemAdds a new question item that allows the respondent to enter a block of text.
addScaleItem()ScaleItemAppends a new question item that allows the respondent to choose one option from a numbered sequence of radio buttons.
addSectionHeaderItem()SectionHeaderItemAppends a new layout item that visually indicates the start of a section.
addTextItem()TextItemAppends a new question item that allows the respondent to enter a single line of text.
addTimeItem()TimeItemAppends a new question item that allows the respondent to indicate a time of day.
addVideoItem()VideoItemAppends a new layout item that displays a video.
canEditResponse()BooleanDetermines whether the form displays a link to edit a response after submitting it.
collectsEmail()BooleanDetermines whether the form collects respondents' email addresses.
createResponse()FormResponseCreates a new response to the form.
deleteAllResponses()FormDeletes all submitted responses from the form's response store.
deleteItem(index)voidDeletes the item at a given index among all the items in the form.
deleteItem(item)voidDeletes the given item.
deleteResponse(responseId)FormDeletes a single response from the form's response store.
getConfirmationMessage()StringGets the form's confirmation message.
getCustomClosedFormMessage()StringGets the custom message that is displayed if the form is not accepting responses, or an empty string if no custom message is set.
getDescription()StringGets the form's description.
getDestinationId()StringGets the ID of the form's response destination.
getDestinationType()DestinationTypeGets the type of the form's response destination.
getEditUrl()StringGets the URL that can be used to access the form's edit mode.
getEditors()User[]Gets the list of editors for this Form.
getId()StringGets the ID of the form.
getItemById(id)ItemGets the item with a given ID.
getItems()Item[]Gets an array of all items in the form.
getItems(itemType)Item[]Gets an array of all items of a given type.
getPublishedUrl()StringGets the URL that can be used to respond to the form.
getResponse(responseId)FormResponseGets a single form response based on its response ID.
getResponses()FormResponse[]Gets an array of all of the form's responses.
getResponses(timestamp)FormResponse[]Gets an array of all of the form's responses after a given date and time.
getShuffleQuestions()BooleanDetermines whether the order of the questions on each page of the form is randomized.
getSummaryUrl()StringGets the URL that can be used to view a summary of the form's responses.
getTitle()StringGets the form's title.
hasLimitOneResponsePerUser()BooleanDetermines whether the form allows only one response per respondent.
hasProgressBar()BooleanDetermines whether the form displays a progress bar.
hasRespondAgainLink()BooleanDetermines whether the form displays a link to submit another response after a respondent completes the form.
isAcceptingResponses()BooleanDetermines whether the form is currently accepting responses.
isPublishingSummary()BooleanDetermines whether the form displays a link to view a summary of responses after a respondent completes the form.
isQuiz()BooleanDetermines whether the form is a quiz.
moveItem(from, to)ItemMoves an item at a given index among all the items in the form to another given index.
moveItem(item, toIndex)ItemMoves a given item to a given index among all the items in the form.
removeDestination()FormUnlinks the form from its current response destination.
removeEditor(emailAddress)FormRemoves the given user from the list of editors for the Form.
removeEditor(user)FormRemoves the given user from the list of editors for the Form.
requiresLogin()BooleanDetermines whether the form requires respondents to log in to an account in the same domain or a subdomain before responding.
setAcceptingResponses(enabled)FormSets whether the form is currently accepting responses.
setAllowResponseEdits(enabled)FormSets whether the form displays a link to edit a response after submitting it.
setCollectEmail(collect)FormSets whether the form collects respondents' email addresses.
setConfirmationMessage(message)FormSets the form's confirmation message.
setCustomClosedFormMessage(message)FormSets the message to display if the form is not accepting responses.
setDescription(description)FormSets the form's description.
setDestination(type, id)FormSets the destination where form responses are saved.
setIsQuiz(enabled)FormSets whether the form is a quiz.
setLimitOneResponsePerUser(enabled)FormSets whether the form allows only one response per respondent.
setProgressBar(enabled)FormSets whether the form has a progress bar.
setPublishingSummary(enabled)FormSets whether the form displays a link to view a summary of responses after a respondent submits the form.
setRequireLogin(requireLogin)FormSets whether the form requires respondents to log in to an account in the same domain or a subdomain before responding.
setShowLinkToRespondAgain(enabled)FormSets whether the form displays a link to submit another response after a respondent completes the form.
setShuffleQuestions(shuffle)FormSets whether the order of the questions on each page of the form is randomized.
setTitle(title)FormSets the form's title.
shortenFormUrl(url)StringConverts a long URL for a form to a short URL.
submitGrades(responses)FormSubmits grades for the given FormResponses.

FormApp

Properties

PropertyTypeDescription
AlignmentAlignmentAn enumeration of types of image alignment.
DestinationTypeDestinationTypeAn enumeration of types of destinations that can store form responses.
FeedbackTypeFeedbackTypeAn enumeration of types of form Feedbacks.
ItemTypeItemTypeAn enumeration of types of form Items.
PageNavigationTypePageNavigationTypeAn enumeration of possible behaviors for navigating pages.

Methods

MethodReturn typeBrief description
create(title)FormCreates and returns a new Form.
createCheckboxGridValidation()CheckboxGridValidationBuilderReturns an instance of a CheckboxGridValidationBuilder which can be used to set validation on a CheckboxGridItem.
createCheckboxValidation()CheckboxValidationBuilderReturns an instance of a CheckboxValidationBuilder which can be used to set validation on a CheckboxItem.
createFeedback()QuizFeedbackBuilderReturns an instance of a QuizFeedbackBuilder which can be used to set feedback on a gradeable Item.
createGridValidation()GridValidationBuilderReturns an instance of a GridValidationBuilder which can be used to set validation on a GridItem.
createParagraphTextValidation()ParagraphTextValidationBuilderReturns an instance of a ParagraphTextValidationBuilder which can be used to set validation on a ParagraphTextItem.
createTextValidation()TextValidationBuilderReturns an instance of a TextValidationBuilder which can be used to set validation on a TextItem.
getActiveForm()FormReturns the form to which the script is container-bound.
getUi()UiReturns an instance of the form editor's user-interface environment that allows the script to add features like menus, dialogs, and sidebars.
openById(id)FormReturns the Form with the specified ID.
openByUrl(url)FormReturns the Form with the specified URL.

FormResponse

Methods

MethodReturn typeBrief description
getEditResponseUrl()StringGenerates a URL that can be used to edit a response that has already been submitted.
getGradableItemResponses()ItemResponse[]Gets all item responses contained in a form response, in the same order that the items appear in the form.
getGradableResponseForItem(item)ItemResponseGets the item response contained in a form response for a given item.
getId()StringGets the ID of the form response.
getItemResponses()ItemResponse[]Gets all item responses contained in a form response, in the same order that the items appear in the form.
getRespondentEmail()StringGets the email address of the person who submitted a response, if the Form.setCollectEmail(collect) setting is enabled.
getResponseForItem(item)ItemResponseGets the item response contained in this form response for a given item.
getTimestamp()DateGets the timestamp for a form response submission.
submit()FormResponseSubmits the response.
toPrefilledUrl()StringGenerates a URL for the form in which the answers are pre-filled based on the answers in this form response.
withItemGrade(gradedResponse)FormResponseAdds the given item response's grades to a form response.
withItemResponse(response)FormResponseAdds the given item response to a form response.

GridItem

Methods

MethodReturn typeBrief description
clearValidation()GridItemRemoves any data validation for this grid item.
createResponse(responses)ItemResponseCreates a new ItemResponse for this grid item.
duplicate()GridItemCreates a copy of this item and appends it to the end of the form.
getColumns()String[]Gets the values for every column in the grid.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getRows()String[]Gets the values for every row in the grid.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
isRequired()BooleanDetermines whether the respondent must answer the question.
setColumns(columns)GridItemSets the columns of the grid based on an array of values.
setHelpText(text)GridItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setRequired(enabled)GridItemSets whether the respondent must answer the question.
setRows(rows)GridItemSets the rows of the grid based on an array of values.
setTitle(title)GridItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
setValidation(validation)GridItemSets the data validation for this grid item.

GridValidation

GridValidationBuilder

Methods

MethodReturn typeBrief description
requireLimitOneResponsePerColumn()GridValidationBuilderRequires limit of one response per column for a grid item.

ImageItem

Methods

MethodReturn typeBrief description
duplicate()ImageItemCreates a copy of this item and appends it to the end of the form.
getAlignment()AlignmentGets the image's horizontal alignment.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getImage()BlobGets the image that is currently assigned to the item.
getIndex()IntegerGets the index of the item among all the items in the form.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
getWidth()IntegerGets the image's width in pixels.
setAlignment(alignment)ImageItemSets the image's horizontal alignment.
setHelpText(text)ImageItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setImage(image)ImageItemSets the image itself.
setTitle(title)ImageItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
setWidth(width)ImageItemSets the image's width in pixels.

Item

Methods

MethodReturn typeBrief description
asCheckboxGridItem()CheckboxGridItemReturns the item as a checkbox grid item.
asCheckboxItem()CheckboxItemReturns the item as a checkbox item.
asDateItem()DateItemReturns the item as a date item.
asDateTimeItem()DateTimeItemReturns the item as a date-time item.
asDurationItem()DurationItemReturns the item as a duration item.
asGridItem()GridItemReturns the item as a grid item.
asImageItem()ImageItemReturns the item as an image item.
asListItem()ListItemReturns the item as a list item.
asMultipleChoiceItem()MultipleChoiceItemReturns the item as a multiple-choice item.
asPageBreakItem()PageBreakItemReturns the item as a page-break item.
asParagraphTextItem()ParagraphTextItemReturns the item as a paragraph-text item.
asScaleItem()ScaleItemReturns the item as a scale item.
asSectionHeaderItem()SectionHeaderItemReturns the item as a section-header item.
asTextItem()TextItemReturns the item as a text item.
asTimeItem()TimeItemReturns the item as a time item.
asVideoItem()VideoItemReturns the item as a video item.
duplicate()ItemCreates a copy of this item and appends it to the end of the form.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
setHelpText(text)ItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setTitle(title)ItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

ItemResponse

Methods

MethodReturn typeBrief description
getFeedback()ObjectGets the feedback that was given for the respondent's submitted answer.
getItem()ItemGets the question item that this response answers.
getResponse()ObjectGets the answer that the respondent submitted.
getScore()ObjectGets the score for the respondent's submitted answer.
setFeedback(feedback)ItemResponseSets the feedback that should be displayed for the respondent's submitted answer.
setScore(score)ItemResponseSets the score for the respondent's submitted answer.

ItemType

Properties

PropertyTypeDescription
CHECKBOXEnumA question item that allows the respondent to select one or more checkboxes, as well as an optional "other" field.
CHECKBOX_GRIDEnumA question item, presented as a grid of columns and rows, that allows the respondent to select multiple choices per row from a sequence of checkboxes.
DATEEnumA question item that allows the respondent to indicate a date.
DATETIMEEnumA question item that allows the respondent to indicate a date and time.
DURATIONEnumA question item that allows the respondent to indicate a length of time.
GRIDEnumA question item, presented as a grid of columns and rows, that allows the respondent to select one choice per row from a sequence of radio buttons.
IMAGEEnumA layout item that displays an image.
LISTEnumA question item that allows the respondent to select one choice from a drop-down list.
MULTIPLE_CHOICEEnumA question item that allows the respondent to select one choice from a list of radio buttons or an optional "other" field.
PAGE_BREAKEnumA layout item that marks the start of a page.
PARAGRAPH_TEXTEnumA question item that allows the respondent to enter a block of text.
SCALEEnumA question item that allows the respondent to choose one option from a numbered sequence of radio buttons.
SECTION_HEADEREnumA layout item that visually indicates the start of a section.
TEXTEnumA question item that allows the respondent to enter a single line of text.
TIMEEnumA question item that allows the respondent to indicate a time of day.
VIDEOEnumA layout item that displays a YouTube video.
FILE_UPLOADEnumA question item that lets the respondent upload a file.

ListItem

Methods

MethodReturn typeBrief description
createChoice(value)ChoiceCreates a new choice.
createChoice(value, isCorrect)ChoiceCreates a new choice.
createChoice(value, navigationItem)ChoiceCreates a new choice with a page-navigation option that jumps to a given page-break item.
createChoice(value, navigationType)ChoiceCreates a new choice with a page-navigation option.
createResponse(response)ItemResponseCreates a new ItemResponse for this list item.
duplicate()ListItemCreates a copy of this item and appends it to the end of the form.
getChoices()Choice[]Gets all choices for an item.
getFeedbackForCorrect()QuizFeedbackReturns the feedback that is shown to respondents when they respond correctly to a question.
getFeedbackForIncorrect()QuizFeedbackReturns the feedback that is shown to respondents when they respond incorrectly to a question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
isRequired()BooleanDetermines whether the respondent must answer the question.
setChoiceValues(values)ListItemSets the choices for an item from an array of strings.
setChoices(choices)ListItemSets an array of choices for an item.
setFeedbackForCorrect(feedback)ListItemSets the feedback to be shown to respondents when they respond correctly to a question.
setFeedbackForIncorrect(feedback)ListItemSets the feedback to be shown to respondents when they respond incorrectly to a question.
setHelpText(text)ListItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setPoints(points)ListItemSets the number of points a gradeable item is worth.
setRequired(enabled)ListItemSets whether the respondent must answer the question.
setTitle(title)ListItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

MultipleChoiceItem

Methods

MethodReturn typeBrief description
createChoice(value)ChoiceCreates a new choice.
createChoice(value, isCorrect)ChoiceCreates a new choice.
createChoice(value, navigationItem)ChoiceCreates a new choice with a page-navigation option that jumps to a given page-break item.
createChoice(value, navigationType)ChoiceCreates a new choice with a page-navigation option.
createResponse(response)ItemResponseCreates a new ItemResponse for this multiple-choice item.
duplicate()MultipleChoiceItemCreates a copy of this item and appends it to the end of the form.
getChoices()Choice[]Gets all choices for an item.
getFeedbackForCorrect()QuizFeedbackReturns the feedback that is shown to respondents when they respond correctly to a question.
getFeedbackForIncorrect()QuizFeedbackReturns the feedback that is shown to respondents when they respond incorrectly to a question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
hasOtherOption()BooleanDetermines whether the item has an "other" option.
isRequired()BooleanDetermines whether the respondent must answer the question.
setChoiceValues(values)MultipleChoiceItemSets the choices for an item from an array of strings.
setChoices(choices)MultipleChoiceItemSets an array of choices for an item.
setFeedbackForCorrect(feedback)MultipleChoiceItemSets the feedback to be shown to respondents when they respond correctly to a question.
setFeedbackForIncorrect(feedback)MultipleChoiceItemSets the feedback to be shown to respondents when they respond incorrectly to a question.
setHelpText(text)MultipleChoiceItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setPoints(points)MultipleChoiceItemSets the number of points a gradeable item is worth.
setRequired(enabled)MultipleChoiceItemSets whether the respondent must answer the question.
setTitle(title)MultipleChoiceItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
showOtherOption(enabled)MultipleChoiceItemSets whether the item has an "other" option.

PageBreakItem

Methods

MethodReturn typeBrief description
duplicate()PageBreakItemCreates a copy of this item and appends it to the end of the form.
getGoToPage()PageBreakItemGets the PageBreakItem that the form will jump to after completing the page before this page break (that is, upon reaching this page break by normal linear progression through the form).
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPageNavigationType()PageNavigationTypeGets the type of page navigation that occurs after completing the page before this page break (that is, upon reaching this page break by normal linear progression through the form).
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
setGoToPage(goToPageItem)PageBreakItemSets the page to jump to after completing the page before this page break (that is, upon reaching this page break by normal linear progression through the form).
setGoToPage(navigationType)PageBreakItemSets the type of page navigation that occurs after completing the page before this page break (that is, upon reaching this page break by normal linear progression through the form).
setHelpText(text)PageBreakItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setTitle(title)PageBreakItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

Properties

PropertyTypeDescription
CONTINUEEnumContinue to the next page of the form after completing the current page.
GO_TO_PAGEEnumJump to a specified page of the form after completing the current page.
RESTARTEnumRestart the form from the beginning, without clearing answers entered so far, after completing the current page.
SUBMITEnumSubmit the form response after completing the current page.

ParagraphTextItem

Methods

MethodReturn typeBrief description
clearValidation()ParagraphTextItemRemoves any data validation for this paragraph text item.
createResponse(response)ItemResponseCreates a new ItemResponse for this paragraph text item.
duplicate()ParagraphTextItemCreates a copy of this item and appends it to the end of the form.
getGeneralFeedback()QuizFeedbackReturns the feedback that is shown to respondents when they respond to a gradeable question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
isRequired()BooleanDetermines whether the respondent must answer the question.
setGeneralFeedback(feedback)ParagraphTextItemSets the feedback to be shown to respondents when they respond to a gradeable question that doesn't have a correct or incorrect answer (ie questions that require manual grading).
setHelpText(text)ParagraphTextItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setPoints(points)ParagraphTextItemSets the number of points a gradeable item is worth.
setRequired(enabled)ParagraphTextItemSets whether the respondent must answer the question.
setTitle(title)ParagraphTextItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
setValidation(validation)ParagraphTextItemSets the data validation for this paragraph text item.

ParagraphTextValidation

ParagraphTextValidationBuilder

Methods

MethodReturn typeBrief description
requireTextContainsPattern(pattern)ParagraphTextValidationBuilderRequires response to contain pattern.
requireTextDoesNotContainPattern(pattern)ParagraphTextValidationBuilderRequires response to not contain pattern.
requireTextDoesNotMatchPattern(pattern)ParagraphTextValidationBuilderRequires response to not match pattern.
requireTextLengthGreaterThanOrEqualTo(number)ParagraphTextValidationBuilderRequires response length to be greater than or equal to value.
requireTextLengthLessThanOrEqualTo(number)ParagraphTextValidationBuilderRequires response length to be less than value.
requireTextMatchesPattern(pattern)ParagraphTextValidationBuilderRequires response to match pattern.

QuizFeedback

Methods

MethodReturn typeBrief description
getLinkUrls()String[]Gets a list of the URLs associated with the Feedback.
getText()StringGets the Feedback's display text.

QuizFeedbackBuilder

Methods

MethodReturn typeBrief description
addLink(url)QuizFeedbackBuilderAdds a link to the feedback's supplemental material.
addLink(url, displayText)QuizFeedbackBuilderAdds a link to the feedback's supplemental material.
build()QuizFeedbackBuilds a Feedback of the corresponding type for this builder.
copy()QuizFeedbackBuilderReturns a copy of this builder.
setText(text)QuizFeedbackBuilderSets the feedback text.

ScaleItem

Methods

MethodReturn typeBrief description
createResponse(response)ItemResponseCreates a new ItemResponse for this scale item.
duplicate()ScaleItemCreates a copy of this item and appends it to the end of the form.
getGeneralFeedback()QuizFeedbackReturns the feedback that is shown to respondents when they respond to a gradeable question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getLeftLabel()StringGets the label for the scale's lower bound, if any.
getLowerBound()IntegerGets the scale's lower bound.
getPoints()IntegerReturns the point value of a gradeable item.
getRightLabel()StringGets the label for the scale's upper bound, if any.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
getUpperBound()IntegerGets the scale's upper bound.
isRequired()BooleanDetermines whether the respondent must answer the question.
setBounds(lower, upper)ScaleItemSets the scale's lower and upper bounds.
setGeneralFeedback(feedback)ScaleItemSets the feedback to be shown to respondents when they respond to a gradeable question that doesn't have a correct or incorrect answer (ie questions that require manual grading).
setHelpText(text)ScaleItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setLabels(lower, upper)ScaleItemSets labels for the scale's lower and upper bounds.
setPoints(points)ScaleItemSets the number of points a gradeable item is worth.
setRequired(enabled)ScaleItemSets whether the respondent must answer the question.
setTitle(title)ScaleItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

SectionHeaderItem

Methods

MethodReturn typeBrief description
duplicate()SectionHeaderItemCreates a copy of this item and appends it to the end of the form.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
setHelpText(text)SectionHeaderItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setTitle(title)SectionHeaderItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

TextItem

Methods

MethodReturn typeBrief description
clearValidation()TextItemRemoves any data validation for this text item.
createResponse(response)ItemResponseCreates a new ItemResponse for this text item.
duplicate()TextItemCreates a copy of this item and appends it to the end of the form.
getGeneralFeedback()QuizFeedbackReturns the feedback that is shown to respondents when they respond to a gradeable question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
isRequired()BooleanDetermines whether the respondent must answer the question.
setGeneralFeedback(feedback)TextItemSets the feedback to be shown to respondents when they respond to a gradeable question that doesn't have a correct or incorrect answer (ie questions that require manual grading).
setHelpText(text)TextItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setPoints(points)TextItemSets the number of points a gradeable item is worth.
setRequired(enabled)TextItemSets whether the respondent must answer the question.
setTitle(title)TextItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
setValidation(validation)TextItemSets the data validation for this text item.

TextValidation

TextValidationBuilder

Methods

MethodReturn typeBrief description
requireNumber()TextValidationBuilderRequires text item to be a number.
requireNumberBetween(start, end)TextValidationBuilderRequires text item to be a number between start and end, inclusive.
requireNumberEqualTo(number)TextValidationBuilderRequires text item to be a number equal to value specified.
requireNumberGreaterThan(number)TextValidationBuilderRequires text item to be a number greater than the value specified.
requireNumberGreaterThanOrEqualTo(number)TextValidationBuilderRequires text item to be a number greater than or equal to the value specified.
requireNumberLessThan(number)TextValidationBuilderRequires text item to be a number less than the value specified.
requireNumberLessThanOrEqualTo(number)TextValidationBuilderRequires text item to be a number less than or equal to the value specified.
requireNumberNotBetween(start, end)TextValidationBuilderRequires text item to be a number not between start and end, inclusive.
requireNumberNotEqualTo(number)TextValidationBuilderRequires text item to be a number not equal to the value specified.
requireTextContainsPattern(pattern)TextValidationBuilderRequires response to contain pattern.
requireTextDoesNotContainPattern(pattern)TextValidationBuilderRequires response to not contain pattern.
requireTextDoesNotMatchPattern(pattern)TextValidationBuilderRequires response to not match pattern.
requireTextIsEmail()TextValidationBuilderRequires text item to be an email address.
requireTextIsUrl()TextValidationBuilderRequires text item to be a URL.
requireTextLengthGreaterThanOrEqualTo(number)TextValidationBuilderRequires response length to be greater than or equal to value.
requireTextLengthLessThanOrEqualTo(number)TextValidationBuilderRequires response length to be less than value.
requireTextMatchesPattern(pattern)TextValidationBuilderRequires response to match pattern.
requireWholeNumber()TextValidationBuilderRequires text item to be a whole number.

TimeItem

Methods

MethodReturn typeBrief description
createResponse(hour, minute)ItemResponseCreates a new ItemResponse for this time item.
duplicate()TimeItemCreates a copy of this item and appends it to the end of the form.
getGeneralFeedback()QuizFeedbackReturns the feedback that is shown to respondents when they respond to a gradeable question.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getPoints()IntegerReturns the point value of a gradeable item.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
isRequired()BooleanDetermines whether the respondent must answer the question.
setGeneralFeedback(feedback)TimeItemSets the feedback to be shown to respondents when they respond to a gradeable question that doesn't have a correct or incorrect answer (ie questions that require manual grading).
setHelpText(text)TimeItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setPoints(points)TimeItemSets the number of points a gradeable item is worth.
setRequired(enabled)TimeItemSets whether the respondent must answer the question.
setTitle(title)TimeItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).

VideoItem

Methods

MethodReturn typeBrief description
duplicate()VideoItemCreates a copy of this item and appends it to the end of the form.
getAlignment()AlignmentGets the video's horizontal alignment.
getHelpText()StringGets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
getId()IntegerGets the item's unique identifier.
getIndex()IntegerGets the index of the item among all the items in the form.
getTitle()StringGets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
getType()ItemTypeGets the item's type, represented as an ItemType.
getWidth()IntegerGets the video's width in pixels.
setAlignment(alignment)VideoItemSets the video's horizontal alignment.
setHelpText(text)VideoItemSets the item's help text (sometimes called description text for layout items like ImageItems, PageBreakItems, and SectionHeaderItems).
setTitle(title)VideoItemSets the item's title (sometimes called header text, in the case of a SectionHeaderItem).
setVideoUrl(youtubeUrl)VideoItemSets the video itself from a given YouTube URL or YouTube video ID.
setWidth(width)VideoItemSets the video's width in pixels.