"""Pydantic input schemas aligned with https://tryme.tpk.pw/openapi.json.""" from __future__ import annotations from typing import Literal from pydantic import BaseModel, Field class QuestionOptionSchema(BaseModel): """Multiple-choice option for a quiz question.""" id: str = Field( ..., min_length=1, max_length=32, description="Option identifier (e.g. 'a', 'b', 'opt1').", ) text: str = Field( ..., min_length=1, max_length=300, description="Display text of the answer option.", ) class QuestionIn(BaseModel): """Input schema for creating or updating a quiz question.""" question_type: Literal["multiple_choice", "write_in"] = Field( ..., description="Type of question: 'multiple_choice' or 'write_in'.", ) prompt: str = Field( ..., min_length=1, max_length=1000, description="Question prompt displayed to quiz players.", ) options: list[QuestionOptionSchema] = Field( default_factory=list, description="List of selectable options (used when question_type is 'multiple_choice').", ) correct_answer: str = Field( ..., min_length=1, max_length=500, description="Option ID (for multiple_choice) or canonical answer text (for write_in).", ) accepted_answers: list[str] = Field( default_factory=list, description="Additional accepted write-in answers.", )