Automated Action 6f0470e475 Implement Bible Quiz App API with FastAPI and SQLite
- Setup project structure with FastAPI app
- Create SQLAlchemy models for categories, questions, quizzes, and results
- Implement API endpoints for all CRUD operations
- Set up Alembic migrations for database schema management
- Add comprehensive documentation in README.md
2025-06-05 10:31:02 +00:00

40 lines
1.5 KiB
Python

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