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]
-
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 (
TextQuestionwithparagraph=False).
- PARAGRAPH = 'paragraph'
Multi-line free-text input (
TextQuestionwithparagraph=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
lowandhigh.
- 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:
objectConfiguration 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:
- question_type: QuestionType
The type of question.
- class gformlib.models.FormConfig(title, questions=<factory>, document_title=None, description=None)[source]
Bases:
objectConfiguration 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)
questions (List[QuestionConfig])
document_title (str | None)
description (str | None)
- questions: List[QuestionConfig]
Ordered list of questions.
- class gformlib.models.UpdateFormConfig(title=None, description=None, add_questions=<factory>)[source]
Bases:
objectConfiguration 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
Noneare 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)
description (str | None)
add_questions (List[QuestionConfig])
- 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:
objectMetadata 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: