tech-pm-4vuyq1/schemas/biblequiz.py

75 lines
2.7 KiB
Python

from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
from uuid import UUID
# Base schema for BibleQuiz
class BibleQuizBase(BaseModel):
name: str = Field(..., description="Name of the Bible quiz")
description: Optional[str] = Field(None, description="Description of the Bible quiz")
is_active: bool = Field(True, description="Whether the Bible quiz is active or not")
# Schema for creating a new BibleQuiz
class BibleQuizCreate(BibleQuizBase):
pass
# Schema for updating an existing BibleQuiz
class BibleQuizUpdate(BibleQuizBase):
name: Optional[str] = Field(None, description="Name of the Bible quiz")
description: Optional[str] = Field(None, description="Description of the Bible quiz")
is_active: Optional[bool] = Field(None, description="Whether the Bible quiz is active or not")
# Schema for representing a BibleQuiz in responses
class BibleQuizSchema(BibleQuizBase):
id: UUID
created_at: datetime
updated_at: datetime
class Config:
orm_mode = True
# Base schema for BibleQuizQuestion
class BibleQuizQuestionBase(BaseModel):
question_text: str = Field(..., description="Text of the Bible quiz question")
# Schema for creating a new BibleQuizQuestion
class BibleQuizQuestionCreate(BibleQuizQuestionBase):
quiz_id: UUID = Field(..., description="ID of the associated Bible quiz")
# Schema for updating an existing BibleQuizQuestion
class BibleQuizQuestionUpdate(BibleQuizQuestionBase):
question_text: Optional[str] = Field(None, description="Text of the Bible quiz question")
# Schema for representing a BibleQuizQuestion in responses
class BibleQuizQuestionSchema(BibleQuizQuestionBase):
id: UUID
quiz_id: UUID
created_at: datetime
updated_at: datetime
class Config:
orm_mode = True
# Base schema for BibleQuizAnswer
class BibleQuizAnswerBase(BaseModel):
answer_text: str = Field(..., description="Text of the Bible quiz answer")
is_correct: bool = Field(False, description="Whether the answer is correct or not")
# Schema for creating a new BibleQuizAnswer
class BibleQuizAnswerCreate(BibleQuizAnswerBase):
question_id: UUID = Field(..., description="ID of the associated Bible quiz question")
# Schema for updating an existing BibleQuizAnswer
class BibleQuizAnswerUpdate(BibleQuizAnswerBase):
answer_text: Optional[str] = Field(None, description="Text of the Bible quiz answer")
is_correct: Optional[bool] = Field(None, description="Whether the answer is correct or not")
# Schema for representing a BibleQuizAnswer in responses
class BibleQuizAnswerSchema(BibleQuizAnswerBase):
id: UUID
question_id: UUID
created_at: datetime
updated_at: datetime
class Config:
orm_mode = True