feat: add the house manager questionnaire per travel and compact the questionnaire layout

This commit is contained in:
fromme committed 2026-11-11 11:16:37 +01:00
1 parent d760ed3cdf
commit bfef08b519
50 files changed
+2763 -180

No files matched your search

@@ -16,8 +16,8 @@ use Symfony\Component\Routing\Requirement\Requirement;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* One submitted questionnaire: what the disposition knew when it was submitted, then the answers,
* rendered with the definition version they were given under.
* One submitted questionnaire: what the disposition or travel knew when it was submitted, then the
* answers, rendered with the definition version they were given under.
*/
class DetailController extends AbstractController
{
@@ -43,8 +43,8 @@ class DetailController extends AbstractController
}
// the other responses of the same placement, e.g. the bus feedback beside the teamer feedback,
// or the other leg's
$siblings = array_filter(
// or the other leg's; a travel's questionnaire has none
$siblings = null === $response->getDisposition() ? [] : array_filter(
array_merge(...array_values($this->responseRepository->findByDisposition($response->getDisposition()))),
static fn (QuestionnaireResponse $sibling): bool => $sibling !== $response && $sibling->isSubmitted(),
);
@@ -0,0 +1,76 @@
<?php
namespace App\Controller\Administrative\Questionnaire;
use App\Config\QuestionnaireCatalog;
use App\Controller\Traits\ReturnUrlTrait;
use App\Entity\Assignment;
use App\Form\QuestionnaireType;
use App\Repository\DispositionRepository;
use App\Service\Questionnaire\DestinationContext;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* The house manager's questionnaire as a house manager gets it for the travel of this assignment,
* with the travel's teamers - before or after the trip. Opened from an assignment, since that is
* where the office tries out the teamer questionnaires too. Nothing is saved: "Absenden" shows
* the answers as they would be stored, "Entwurf speichern" just keeps them in the form.
*/
class HouseManagerTestController extends AbstractController
{
use ReturnUrlTrait;
public function __construct(
private readonly QuestionnaireCatalog $catalog,
private readonly DispositionRepository $dispositionRepository,
) {
}
#[Route('/administrative/questionnaire/test-house-manager/{uuid}', name: 'app_administrative_questionnaire_test_house_manager')]
#[IsGranted('ROLE_ADMINISTRATIVE')]
public function index(
#[MapEntity(mapping: ['uuid' => 'uuid'])]
Assignment $assignment,
Request $request,
): Response {
$destination = $assignment->getDestination();
$definition = $this->catalog->get(QuestionnaireCatalog::HOUSE_MANAGER_FEEDBACK);
$dispositions = $this->dispositionRepository->findForHouseManagerQuestionnaire($destination);
$form = $this->createForm(QuestionnaireType::class, [
$definition->key => DestinationContext::initialAnswers($destination),
], [
'definitions' => [$definition],
'travel' => DestinationContext::travel($destination, $dispositions),
]);
$form->handleRequest($request);
$submitted = null;
$draft = false;
if ($form->isSubmitted() && $form->isValid()) {
if (QuestionnaireType::isFinal($form)) {
$submitted = $definition->withoutHiddenAnswers($form->getData()[$definition->key]);
} else {
$draft = true;
}
}
return $this->render('administrative/questionnaire/test_house_manager.html.twig', [
'assignment' => $assignment,
'destination' => $destination,
'dispositions' => $dispositions,
'definition' => $definition,
'context' => DestinationContext::build($destination, $dispositions),
'form' => $form,
'submitted' => $submitted,
'draft' => $draft,
'returnUrl' => $this->getReturnUrl($request, 'app_administrative_assignment_index'),
]);
}
}
@@ -13,9 +13,10 @@ use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
/**
* The submitted responses to one questionnaire, teamer or bus feedback. Only administrative users
* read them: they rate the house manager among others, so house managers are deliberately not
* let in.
* The submitted responses to one questionnaire: teamer, bus or house manager feedback. Only
* administrative users read them here: the teamer ones rate the house manager among others, so
* house managers are deliberately not let in. A house manager reads their own travel's
* questionnaire in the HouseManager area.
*/
class IndexController extends AbstractController
{