fix: offer the questionnaire after every placement, the bus part to escorts

This commit is contained in:
fromme committed 2026-10-27 17:12:24 +01:00
1 parent 9fedc5b5d3
commit 2f4f9800dd
30 files changed
+311 -77

No files matched your search

+22
View File
@@ -2,6 +2,8 @@
namespace App\Model\Questionnaire;
use App\Enum\QuestionnaireFlag;
/**
* One version of a questionnaire as read from config/questionnaires/. Responses store its key and
* version, and their answers are keyed by Question::$key.
@@ -20,6 +22,26 @@ readonly class Definition
) {
}
/**
* The questionnaire as one subject gets it: without the sections marked `only_for` a flag the
* subject does not have. Key and version stay, so answers to it are answers to this definition.
*
* @param list<QuestionnaireFlag> $flags
*/
public function forFlags(array $flags): static
{
return new static(
$this->key,
$this->version,
$this->title,
$this->description,
array_values(array_filter(
$this->sections,
static fn (Section $section): bool => null === $section->onlyFor || in_array($section->onlyFor, $flags, true),
)),
);
}
/**
* @return array<string, Question> in the order they are asked, keyed by question key
*/
+5 -1
View File
@@ -2,15 +2,19 @@
namespace App\Model\Questionnaire;
use App\Enum\QuestionnaireFlag;
readonly class Section
{
/**
* @param list<Question> $questions
* @param list<Question> $questions
* @param QuestionnaireFlag|null $onlyFor part of the questionnaire only when the subject has this flag
*/
public function __construct(
public string $key,
public ?string $title,
public array $questions,
public ?QuestionnaireFlag $onlyFor = null,
) {
}
}