37 lines
868 B
Python
37 lines
868 B
Python
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# Shared properties
|
|
class StudentAnswerBase(BaseModel):
|
|
exam_result_id: int
|
|
question_id: int
|
|
selected_option_id: Optional[int] = None
|
|
text_answer: Optional[str] = None
|
|
|
|
|
|
# Properties to receive via API on creation
|
|
class StudentAnswerCreate(StudentAnswerBase):
|
|
pass
|
|
|
|
|
|
# Properties to receive via API on update
|
|
class StudentAnswerUpdate(BaseModel):
|
|
selected_option_id: Optional[int] = None
|
|
text_answer: Optional[str] = None
|
|
is_correct: Optional[bool] = None
|
|
points_earned: Optional[float] = None
|
|
|
|
|
|
class StudentAnswerInDBBase(StudentAnswerBase):
|
|
id: int
|
|
is_correct: Optional[bool] = None
|
|
points_earned: float = 0.0
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
# Additional properties to return via API
|
|
class StudentAnswer(StudentAnswerInDBBase):
|
|
pass |