Activity system #3
9
src/fiber_package/signup/answer/answer_checkmarks.py
Normal file
9
src/fiber_package/signup/answer/answer_checkmarks.py
Normal file
@ -0,0 +1,9 @@
|
||||
from typing import Literal
|
||||
|
||||
from .answer_base import AnswerBase
|
||||
from fiber_package.signup.enums import FormElementCategory
|
||||
|
||||
class AnswerOpenQuestions(AnswerBase):
|
||||
category: Literal[FormElementCategory.checkmarks]
|
||||
|
||||
answer_list: list[bool]
|
||||
28
src/fiber_package/signup/element/form_checkmarks.py
Normal file
28
src/fiber_package/signup/element/form_checkmarks.py
Normal file
@ -0,0 +1,28 @@
|
||||
from typing import Literal
|
||||
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 AnswerCheckmarks
|
||||
|
||||
class CheckmarkQuestion(BaseModel):
|
||||
question_en: str
|
||||
question_nl: str
|
||||
|
||||
class FormCheckmarks(FormBaseQuestion):
|
||||
category: Literal[FormElementCategory.checkmarks]
|
||||
|
||||
questions: list[CheckmarkQuestion]
|
||||
|
||||
def validate_answer(self, answer: AnswerCheckmarks) -> 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.")
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ from typing import Annotated
|
||||
from pydantic import Field
|
||||
|
||||
from .form_open_questions import FormOpenQuestions
|
||||
from .form_checkmarks import FormCheckmarks
|
||||
from .form_text import FormText
|
||||
from .form_title import FormTitle
|
||||
|
||||
@ -12,7 +13,7 @@ FormTextUnion = Annotated[
|
||||
]
|
||||
|
||||
FormQuestionUnion = Annotated[
|
||||
FormOpenQuestions,
|
||||
FormOpenQuestions | FormCheckmarks,
|
||||
Field(discriminator="category")
|
||||
]
|
||||
|
||||
|
||||
@ -8,9 +8,11 @@ class FormElementCategory(StrEnum):
|
||||
text_piece = "text_piece"
|
||||
title_text = "title_text"
|
||||
open_questions = "open_questions"
|
||||
checkmarks = "checkmarks"
|
||||
|
||||
FormQuestionCategory = Literal[
|
||||
FormElementCategory.open_questions
|
||||
FormElementCategory.open_questions,
|
||||
FormElementCategory.checkmarks
|
||||
]
|
||||
|
||||
FormTextCategory = Literal[
|
||||
|
||||
8
src/fiber_package/signup/howto-add-new-question.txt
Normal file
8
src/fiber_package/signup/howto-add-new-question.txt
Normal file
@ -0,0 +1,8 @@
|
||||
In order to add a new question type you need to:
|
||||
|
||||
1) Make a new tag in enums.py
|
||||
2) add it to the list of question tags
|
||||
3) Create the FormXXX in element
|
||||
4) Create the AnswerXXX in answer
|
||||
5) Add it to the question union type in answer.types
|
||||
6) Add it to fiber-django
|
||||
@ -34,11 +34,6 @@ List of question types:
|
||||
* feedback --> feedabck (str)
|
||||
* team --> teamname (str)
|
||||
|
||||
Maybe a bug?
|
||||
If nnvbijdrage is set but nnv is not part of activity,
|
||||
then everybody pays the LOW price as if NNV pays ??!!
|
||||
Not a bug! You cannot set NNV if NNV is not part of sjabloon!
|
||||
... its handled by custom js....
|
||||
|
||||
|
||||
omg it is TERRIBLE. In Silk every sjabloon has its OWN template ?!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user