"""
quizlib essay question type
"""

from dataclasses import dataclass, field

from quizlib.types import QuestionType
from quizlib.utils import DEFAULT_ESSAY_LINES


@dataclass
class Essay:
    """Essay (free-text) question.

    Attributes:
        name: Question identifier/title.
        defgrade: Points for this question.
        text: Question text in Markdown format.
        lines: Number of lines for the response box.
        graderinfo: Information for the grader (not shown to students).
    """

    name: str
    defgrade: int | float
    text: str
    lines: int = DEFAULT_ESSAY_LINES
    graderinfo: str = ""
    typ: QuestionType = field(default=QuestionType.ESSAY, init=False)


# Backwards-compatible alias
ES = Essay
