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

35 lines
1.9 KiB
Python

from pydantic import BaseModel, Field
from typing import Optional
class QuestionBase(BaseModel):
text: str = Field(..., min_length=1, description="Question text")
answer: str = Field(..., min_length=1, max_length=255, description="Correct answer")
option1: Optional[str] = Field(None, max_length=255, description="First option for multiple choice")
option2: Optional[str] = Field(None, max_length=255, description="Second option for multiple choice")
option3: Optional[str] = Field(None, max_length=255, description="Third option for multiple choice")
difficulty: Optional[str] = Field(None, max_length=20, description="Difficulty level (easy, medium, hard)")
reference: Optional[str] = Field(None, max_length=100, description="Bible reference (e.g., 'John 3:16')")
category_id: int = Field(..., description="ID of the category this question belongs to")
class QuestionCreate(QuestionBase):
pass
class QuestionUpdate(BaseModel):
text: Optional[str] = Field(None, min_length=1, description="Question text")
answer: Optional[str] = Field(None, min_length=1, max_length=255, description="Correct answer")
option1: Optional[str] = Field(None, max_length=255, description="First option for multiple choice")
option2: Optional[str] = Field(None, max_length=255, description="Second option for multiple choice")
option3: Optional[str] = Field(None, max_length=255, description="Third option for multiple choice")
difficulty: Optional[str] = Field(None, max_length=20, description="Difficulty level (easy, medium, hard)")
reference: Optional[str] = Field(None, max_length=100, description="Bible reference (e.g., 'John 3:16')")
category_id: Optional[int] = Field(None, description="ID of the category this question belongs to")
class QuestionResponse(QuestionBase):
id: int
class Config:
from_attributes = True