rename + added validation of answer to question
This commit is contained in:
parent
d855b862ca
commit
0fd92120d9
@ -6,4 +6,4 @@ from fiber_package.signup.enums import FormElementCategory
|
||||
class AnswerOpenQuestions(AnswerBase):
|
||||
category: Literal[FormElementCategory.open_questions]
|
||||
|
||||
answers: list[str]
|
||||
answer_list: list[str]
|
||||
|
||||
@ -2,3 +2,7 @@ from .form_element import FormElement
|
||||
|
||||
class FormBaseQuestion(FormElement):
|
||||
required: bool
|
||||
|
||||
title: str | None = None
|
||||
pretext: str | None = None
|
||||
posttext: str | None = None
|
||||
@ -4,6 +4,8 @@ from pydantic import BaseModel
|
||||
from .form_base_question import FormBaseQuestion
|
||||
from fiber_package.signup.enums import FormElementCategory
|
||||
|
||||
from fiber_package.signup.answer.answer_open_questions import AnswerOpenQuestions
|
||||
|
||||
class OpenQuestion(BaseModel):
|
||||
question_en: str
|
||||
question_nl: str
|
||||
@ -19,9 +21,14 @@ class FormOpenQuestions(FormBaseQuestion):
|
||||
|
||||
questions: list[OpenQuestion]
|
||||
|
||||
title: str | None = None
|
||||
pretext: str | None = None
|
||||
posttext: str | None = None
|
||||
def validate_answer(self, answer: AnswerOpenQuestions) -> None:
|
||||
if answer.question_name != self.name:
|
||||
raise ValueError("Answer question name does not match.")
|
||||
|
||||
answer_list = answer.answer_list
|
||||
if len(answer_list) != len(self.questions):
|
||||
raise ValueError("Length of answer question list does not match.")
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user