Skip to content

Correct answer

CorrectAnswer

Bases: BaseFormItem

A single correct answer for a question. For multiple-valued (CHECKBOX) questions, several CorrectAnswers may be needed to represent a single correct response option.

Source code in pygsuite/forms/generated/correct_answer.py
class CorrectAnswer(BaseFormItem):
    """
    A single correct answer for a question. For multiple-valued (`CHECKBOX`) questions, several `CorrectAnswer`s may be needed to represent a single correct response option.
    """

    def __init__(  # noqa: C901
        self, value: Optional[str] = None, object_info: Optional[Dict] = None
    ):
        generated: Dict = {}

        if value is not None:

            generated["value"] = value
        object_info = object_info or generated
        super().__init__(object_info=object_info)

    @property
    def value(self) -> str:
        return self._info.get("value")

    @value.setter
    def value(self, value: str):
        if self._info.get("value", None) == value:
            return
        self._info["value"] = value