refactor: split the questionnaire into teamer and bus feedback
This commit is contained in:
1 parent
2f4f9800dd
commit
a0170f5952
35 files changed
+1114
-554
No files matched your search
@@ -2,8 +2,6 @@
|
||||
|
||||
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.
|
||||
@@ -22,26 +20,6 @@ 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
|
||||
*/
|
||||
|
||||
@@ -2,19 +2,15 @@
|
||||
|
||||
namespace App\Model\Questionnaire;
|
||||
|
||||
use App\Enum\QuestionnaireFlag;
|
||||
|
||||
readonly class Section
|
||||
{
|
||||
/**
|
||||
* @param list<Question> $questions
|
||||
* @param QuestionnaireFlag|null $onlyFor part of the questionnaire only when the subject has this flag
|
||||
* @param list<Question> $questions
|
||||
*/
|
||||
public function __construct(
|
||||
public string $key,
|
||||
public ?string $title,
|
||||
public array $questions,
|
||||
public ?QuestionnaireFlag $onlyFor = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user