gformlib.models

Data models used throughout gformlib.

This module provides:

  • QuestionType – enumeration of supported question types.

  • QuestionConfig – configuration for a single question.

  • FormConfig – configuration for an entire form.

  • FormInfo – metadata returned after a form is created.

class gformlib.models.QuestionType(value)[source]

Bases: str, Enum

Supported question types for Google Forms.

Each member corresponds to a question variant in the Google Forms API.

Example:

from gformlib.models import QuestionType
qt = QuestionType.MULTIPLE_CHOICE
SHORT_ANSWER = 'short_answer'

Single-line free-text input (TextQuestion with paragraph=False).

PARAGRAPH = 'paragraph'

Multi-line free-text input (TextQuestion with paragraph=True).

MULTIPLE_CHOICE = 'multiple_choice'

Radio-button selection – respondent picks exactly one option.

CHECKBOXES = 'checkboxes'

Checkbox selection – respondent may pick multiple options.

DROPDOWN = 'dropdown'

Dropdown menu – respondent picks exactly one option.

SCALE = 'scale'

Linear scale – respondent picks a number between low and high.

DATE = 'date'

Date picker, optionally including time and/or year.

TIME = 'time'

Time-of-day picker or duration input.

FILE_UPLOAD = 'file_upload'

File upload widget (requires Google Drive integration).

class gformlib.models.QuestionConfig(title, question_type, required=False, description=None, options=None, shuffle_options=False, low=1, high=5, low_label=None, high_label=None, include_time=False, include_year=True, is_duration=False)[source]

Bases: object

Configuration for a single Google Form question.

Example:

from gformlib.models import QuestionConfig, QuestionType

q = QuestionConfig(
    title="Rate our service",
    question_type=QuestionType.SCALE,
    required=True,
    low=1,
    high=10,
    low_label="Poor",
    high_label="Excellent",
)
Parameters:
title: str

The question text displayed to respondents.

question_type: QuestionType

The type of question.

required: bool = False

Whether a response is required.

description: str | None = None

Optional help text shown below the question.

options: List[str] | None = None

Answer options (required for choice-type questions).

shuffle_options: bool = False

Randomise the order of answer options.

low: int = 1

Minimum value for scale questions.

high: int = 5

Maximum value for scale questions.

low_label: str | None = None

Descriptive label for the low end of the scale.

high_label: str | None = None

Descriptive label for the high end of the scale.

include_time: bool = False

Include time picker in date questions.

include_year: bool = True

Include year in date questions.

is_duration: bool = False

Treat time question as duration instead of time-of-day.

class gformlib.models.FormConfig(title, questions=<factory>, document_title=None, description=None)[source]

Bases: object

Configuration for a complete Google Form.

Example:

from gformlib.models import FormConfig, QuestionConfig, QuestionType

config = FormConfig(
    title="Customer Survey",
    description="Help us improve our service.",
    questions=[
        QuestionConfig(
            title="Your name",
            question_type=QuestionType.SHORT_ANSWER,
            required=True,
        ),
    ],
)
Parameters:
title: str

The displayed title of the form.

questions: List[QuestionConfig]

Ordered list of questions.

document_title: str | None = None

Google Docs document title (defaults to title).

description: str | None = None

Optional introductory description for the form.

class gformlib.models.UpdateFormConfig(title=None, description=None, add_questions=<factory>)[source]

Bases: object

Configuration for updating an existing Google Form.

All fields are optional. Only the fields that are set will be changed in the live form; fields left as None are left untouched.

Example:

from gformlib.models import UpdateFormConfig, QuestionConfig, QuestionType

update = UpdateFormConfig(
    title="Revised Survey",
    description="Updated description.",
    add_questions=[
        QuestionConfig(
            title="New question",
            question_type=QuestionType.SHORT_ANSWER,
            required=True,
        ),
    ],
)
Parameters:
title: str | None = None

New title for the form. None leaves the title unchanged.

description: str | None = None

New description for the form. None leaves it unchanged.

add_questions: List[QuestionConfig]

Questions to append after the existing items in the form.

class gformlib.models.FormInfo(form_id, title, document_title, responder_uri, linked_sheet_id=None, revision_id=None, raw=None)[source]

Bases: object

Metadata about a Google Form that has been created via the API.

Instances of this class are returned by create_form().

Example:

info = client.create_form(config)
print(info.responder_uri)  # share this link
Parameters:
  • form_id (str)

  • title (str)

  • document_title (str)

  • responder_uri (str)

  • linked_sheet_id (str | None)

  • revision_id (str | None)

  • raw (Dict[str, Any] | None)

form_id: str

Unique identifier of the form.

title: str

Displayed title of the form.

document_title: str

Title of the backing Google Docs document.

responder_uri: str

URL that respondents use to fill in the form.

linked_sheet_id: str | None = None

ID of the linked Google Sheet (if response collection is enabled).

revision_id: str | None = None

Revision ID returned by the API.

raw: Dict[str, Any] | None = None

Raw API response dict.