Activity system #3

Merged
tscholten merged 23 commits from tiago/activities into master 2026-10-17 15:51:00 +00:00
6 changed files with 50 additions and 7 deletions
Showing only changes of commit 74a4c947a1 - Show all commits

View 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]

View 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.")

View File

@ -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")
]

View File

@ -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[

View 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

View File

@ -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 ?!