
- Set up project structure with FastAPI and SQLite - Create models for users, questions, and quizzes - Implement Alembic migrations with seed data - Add user authentication with JWT - Implement question management endpoints - Implement quiz creation and management - Add quiz-taking and scoring functionality - Set up API documentation and health check endpoint - Update README with comprehensive documentation
115 lines
2.3 KiB
Python
115 lines
2.3 KiB
Python
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.schemas.bible_book import BibleBook
|
|
|
|
|
|
class QuestionDifficultyBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
class QuestionDifficultyCreate(QuestionDifficultyBase):
|
|
pass
|
|
|
|
|
|
class QuestionDifficultyUpdate(QuestionDifficultyBase):
|
|
name: Optional[str] = None
|
|
|
|
|
|
class QuestionDifficultyInDBBase(QuestionDifficultyBase):
|
|
id: int
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class QuestionDifficulty(QuestionDifficultyInDBBase):
|
|
pass
|
|
|
|
|
|
class QuestionCategoryBase(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
|
|
|
|
class QuestionCategoryCreate(QuestionCategoryBase):
|
|
pass
|
|
|
|
|
|
class QuestionCategoryUpdate(QuestionCategoryBase):
|
|
name: Optional[str] = None
|
|
|
|
|
|
class QuestionCategoryInDBBase(QuestionCategoryBase):
|
|
id: int
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class QuestionCategory(QuestionCategoryInDBBase):
|
|
pass
|
|
|
|
|
|
class QuestionOptionBase(BaseModel):
|
|
text: str
|
|
is_correct: bool = False
|
|
explanation: Optional[str] = None
|
|
|
|
|
|
class QuestionOptionCreate(QuestionOptionBase):
|
|
pass
|
|
|
|
|
|
class QuestionOptionUpdate(QuestionOptionBase):
|
|
text: Optional[str] = None
|
|
is_correct: Optional[bool] = None
|
|
|
|
|
|
class QuestionOptionInDBBase(QuestionOptionBase):
|
|
id: int
|
|
question_id: int
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class QuestionOption(QuestionOptionInDBBase):
|
|
pass
|
|
|
|
|
|
class QuestionBase(BaseModel):
|
|
text: str
|
|
bible_reference: Optional[str] = None
|
|
explanation: Optional[str] = None
|
|
bible_book_id: Optional[int] = None
|
|
difficulty_id: Optional[int] = None
|
|
category_id: Optional[int] = None
|
|
|
|
|
|
class QuestionCreate(QuestionBase):
|
|
options: List[QuestionOptionCreate] = Field(..., min_items=2)
|
|
|
|
|
|
class QuestionUpdate(QuestionBase):
|
|
text: Optional[str] = None
|
|
options: Optional[List[QuestionOptionUpdate]] = None
|
|
|
|
|
|
class QuestionInDBBase(QuestionBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
orm_mode = True
|
|
|
|
|
|
class Question(QuestionInDBBase):
|
|
bible_book: Optional[BibleBook] = None
|
|
difficulty: Optional[QuestionDifficulty] = None
|
|
category: Optional[QuestionCategory] = None
|
|
options: List[QuestionOption] = [] |