from typing import List, Literal, Optional
from pydantic import BaseModel


class TopicResponse(BaseModel):
    id: str
    name: str
    icon: str

    class Config:
        from_attributes = True


class QuizResponse(BaseModel):
    id: str
    name: str
    topic_id: str
    question_count: int = 0

    class Config:
        from_attributes = True


class QuestionResponse(BaseModel):
    id: int
    content: str
    options: List[str]
    difficulty: str
    sub_topic: str

    class Config:
        from_attributes = True


class QuestionWithAnswerResponse(QuestionResponse):
    answer: int


class QuizStartResponse(BaseModel):
    quiz_id: str
    quiz_name: str
    mode: Literal["practice", "test", "study"]
    topic_id: Optional[str] = None
    topic_name: Optional[str] = None
    topic_icon: Optional[str] = None
    total_available: int
    questions: List[QuestionWithAnswerResponse]
