from typing import List, Optional, Union
from pydantic import BaseModel
from datetime import datetime


class QuestionResult(BaseModel):
    index: int
    question: str
    type: str
    target_answer: Union[str | bool | int]
    user_answer: Optional[Union[str | bool | int]]
    is_correct: Optional[bool]
    time_spent: Optional[float]
    options: Optional[List[str]]


class QuizHistoryResponse(BaseModel):
    answer_id: str
    quiz_id: str
    title: str
    description: str
    author_id: str
    answered_at: str
    total_correct: int
    total_score: int
    total_solve_time: float
    question_listings: List[QuestionResult]
