41 lines
825 B
Python
41 lines
825 B
Python
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class QuestionOptionBase(BaseModel):
|
|
question_id: int
|
|
text: str
|
|
is_correct: bool = False
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class QuestionOptionCreate(QuestionOptionBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class QuestionOptionUpdate(BaseModel):
|
|
text: Optional[str] = None
|
|
is_correct: Optional[bool] = None
|
|
|
|
|
|
class QuestionOptionInDBBase(QuestionOptionBase):
|
|
id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class QuestionOption(QuestionOptionInDBBase):
|
|
pass
|
|
|
|
|
|
# For students taking an exam - hide the is_correct field
|
|
class QuestionOptionForExam(BaseModel):
|
|
id: int
|
|
text: str
|
|
|
|
class Config:
|
|
from_attributes = True |