from pydantic import BaseModel, Field from typing import Optional, List from datetime import datetime from app.schemas.question import QuestionResponse class QuizBase(BaseModel): title: str = Field(..., min_length=1, max_length=100, description="Title of the quiz") description: Optional[str] = Field(None, description="Description of the quiz") category_id: int = Field(..., description="ID of the category this quiz belongs to") difficulty: Optional[str] = Field(None, max_length=20, description="Difficulty level (easy, medium, hard)") class QuizCreate(QuizBase): question_ids: List[int] = Field(..., description="IDs of questions to include in the quiz") class QuizUpdate(BaseModel): title: Optional[str] = Field(None, min_length=1, max_length=100, description="Title of the quiz") description: Optional[str] = Field(None, description="Description of the quiz") category_id: Optional[int] = Field(None, description="ID of the category this quiz belongs to") difficulty: Optional[str] = Field(None, max_length=20, description="Difficulty level (easy, medium, hard)") question_ids: Optional[List[int]] = Field(None, description="IDs of questions to include in the quiz") class QuizResponse(QuizBase): id: int created_at: datetime updated_at: Optional[datetime] = None class Config: from_attributes = True class QuizWithQuestionsResponse(QuizResponse): questions: List[QuestionResponse] class Config: from_attributes = True