From 71a27d3707e676b0bfc00253f0c64b3748cbbf26 Mon Sep 17 00:00:00 2001 From: Anleg Date: Thu, 28 Sep 2023 11:07:21 +0200 Subject: [PATCH] fix(models): RangeQuizAnswer is not a List --- classquiz/db/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classquiz/db/models.py b/classquiz/db/models.py index 1a0709a..2a9902f 100644 --- a/classquiz/db/models.py +++ b/classquiz/db/models.py @@ -141,7 +141,7 @@ class QuizQuestion(BaseModel): def answers_not_none_if_abcd_type(cls, v, values): if values["type"] == QuizQuestionType.ABCD and not isinstance(v[0], ABCDQuizAnswer): raise ValueError("Answers can't be none if type is ABCD") - if values["type"] == QuizQuestionType.RANGE and not isinstance(v[0], RangeQuizAnswer): + if values["type"] == QuizQuestionType.RANGE and not isinstance(v, RangeQuizAnswer): raise ValueError("Answer must be from type RangeQuizAnswer if type is RANGE") if values["type"] == QuizQuestionType.VOTING and not isinstance(v[0], VotingQuizAnswer): raise ValueError("Answer must be from type VotingQuizAnswer if type is VOTING") @@ -149,7 +149,7 @@ class QuizQuestion(BaseModel): raise ValueError("Answer must be from type TextQuizAnswer if type is TEXT") if values["type"] == QuizQuestionType.ORDER and not isinstance(v[0], VotingQuizAnswer): raise ValueError("Answer must be from type VotingQuizAnswer if type is ORDER") - if values["type"] == QuizQuestionType.SLIDE and not isinstance(v[0], str): + if values["type"] == QuizQuestionType.SLIDE and not isinstance(v, str): raise ValueError("Answer must be from type SlideElement if type is SLIDE") if values["type"] == QuizQuestionType.CHECK and not isinstance(v[0], ABCDQuizAnswer): raise ValueError("Answers can't be none if type is CHECK")