
- 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
35 lines
1.9 KiB
Python
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 |