✨ Added new Question-Type: TextAnswers!
This commit is contained in:
@@ -115,21 +115,19 @@ class QuizQuestionType(str, Enum):
|
||||
RANGE = "RANGE"
|
||||
VOTING = "VOTING"
|
||||
SLIDE = "SLIDE"
|
||||
|
||||
|
||||
class SlideElementTypes(str, Enum):
|
||||
TEXT = "TEXT"
|
||||
HEADLINE = "HEADLINE"
|
||||
IMAGE = "IMAGE"
|
||||
RECTANGLE = "RECTANGLE"
|
||||
CIRCLE = "CIRCLE"
|
||||
|
||||
|
||||
class TextQuizAnswer(BaseModel):
|
||||
answer: str
|
||||
case_sensitive: bool
|
||||
|
||||
|
||||
class QuizQuestion(BaseModel):
|
||||
question: str
|
||||
time: str # in Secs
|
||||
type: None | QuizQuestionType = QuizQuestionType.ABCD
|
||||
answers: list[ABCDQuizAnswer] | RangeQuizAnswer | list[VotingQuizAnswer] | str
|
||||
answers: list[ABCDQuizAnswer] | RangeQuizAnswer | list[TextQuizAnswer] | list[VotingQuizAnswer] | str
|
||||
image: str | None = None
|
||||
|
||||
@validator("answers")
|
||||
@@ -140,6 +138,8 @@ class QuizQuestion(BaseModel):
|
||||
raise ValueError("Answer must be from type RangeQuizAnswer if type is RANGE")
|
||||
if values["type"] == QuizQuestionType.VOTING and type(v[0]) != VotingQuizAnswer:
|
||||
raise ValueError("Answer must be from type VotingQuizAnswer if type is VOTING")
|
||||
if values["type"] == QuizQuestionType.TEXT and type(v[0]) != TextQuizAnswer:
|
||||
raise ValueError("Answer must be from type TextQuizAnswer if type is TEXT")
|
||||
if values["type"] == QuizQuestionType.SLIDE and type(v[0]) != str:
|
||||
raise ValueError("Answer must be from type SlideElement if type is SLIDE")
|
||||
return v
|
||||
|
||||
Reference in New Issue
Block a user