Files
myep-team/tests/Config/QuestionnaireCompletenessTest.php
T

184 lines
9.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace App\Tests\Config;
use App\Config\QuestionnaireCatalog;
use App\Entity\Application;
use App\Entity\Assignment;
use App\Entity\Destination;
use App\Entity\Disposition;
use App\Entity\Teamer;
use App\Service\Questionnaire\DestinationContext;
use App\Service\Questionnaire\DispositionContext;
use PHPUnit\Framework\TestCase;
/**
* Every question of the two Google forms the questionnaires replace ("RL-Feedback 25-26" and
* "Bus-Feedback 25-26") is either asked or answered from the placement - none may get lost when
* a definition is edited.
*
* The lists below are the Google forms' questions in their order, with what each became:
* "question:<key>" is asked, "context:<field>" is taken from the disposition and snapshotted into
* the response (DispositionContext::build()), "legs" is the per-bus-leg choice of rides the
* teamer escorted (App\Form\QuestionnaireType), which became a response per leg. Google's "Bitte ankreuzen:" checkbox list was split
* into five single-choice questions, so it maps to five.
*/
class QuestionnaireCompletenessTest extends TestCase
{
private const array TEAMER_FEEDBACK = [
'Name' => ['context:teamerName'],
'Jobprofil' => ['context:jobProfileName'],
'Haus' => ['context:hotel'],
'Einsatzzeitraum (Anreisetag)' => ['context:dateFrom'],
'Wie gut hast du dich vorab vom Büro gebrieft gefühlt?' => ['question:office_briefing_rating'],
'Wenn 1 - 3 Sterne Bewertung, warum?' => ['question:office_briefing_low_reason'],
'War das Wochenteam-Seminar hilfreich für dich? Warst du bzw. wurdest du gut vorbereitet?' => ['question:team_week_seminar'],
'Wie gut lief die Reiseorganisation vor Ort?' => ['question:onsite_organisation_rating'],
'Gab es organisatorische Probleme?' => ['question:had_organisational_problems'],
'Wenn ja, welche?' => ['question:organisational_problems'],
'Wie lief die Kommunikation & Zusammenarbeit mit den E&P Teamer:innen vor Ort während der Reise?' => ['question:teamer_collaboration_rating'],
'Welche Unterstützung hättest du dir zusätzlich gewünscht?' => ['question:support_wished'],
'Wie ist deine Hausleitung mit Problemen vor Ort umgegangen?' => ['question:house_manager_problem_handling'],
'Gab es Momente, in denen du dich überfordert gefühlt hast?' => ['question:felt_overwhelmed'],
'Wenn ja, wodurch?' => ['question:overwhelmed_reason'],
'Was hättest du dir anders oder besser gewünscht?' => ['question:wished_differently'],
'Würdest du wieder als Reiseleitung für E&P arbeiten?' => ['question:would_work_again'],
'Wenn nein, warum nicht?' => ['question:would_not_work_again_reason'],
'Du hast nun schon vieles beantwortet, aber nirgendwo konntest du folgende Aspekte loswerden:' => ['question:anything_else'],
];
private const array BUS_FEEDBACK = [
'(Datum, ohne Titel)' => ['context:escortPickupDate', 'context:dateTo'],
'Hin- oder Rückfahrt' => ['legs'],
'Reiseziel:' => ['context:destinationProduct'],
'Bus-Unternehmen:' => ['question:bus_company'],
'Name des Busunternehmens:' => ['question:bus_company_other'],
'Busfahrer-Namen:' => ['question:driver_names'],
'Reiseleitung:' => ['context:teamerName'],
'1. Abfahrtsort' => ['context:escortPickup', 'context:hotel'],
'Bus pünktlich am 1. Abfahrtsort?' => ['question:on_time_at_first_pickup'],
'Wieviel Verspätung hatte der Bus am 1. Abfahrtsort?' => ['question:delay_at_first_pickup'],
'Gesamteindruck des Busses' => ['question:overall_impression'],
'Alter des Fahrzeugs' => ['question:vehicle_age'],
'Sitzkomfort im Bus' => ['question:seating_comfort'],
'Freundlichkeit der Fahrer' => ['question:driver_friendliness'],
'Pausenzeiten' => ['question:breaks'],
'Temperatur im Bus' => ['question:temperature'],
'Verhalten der Gäste im Bus' => ['question:guest_behaviour'],
'Waren den Fahrern alle Abfahrtsorte bekannt?' => ['question:drivers_knew_pickups'],
'Welche Abfahrtsorte waren nicht bekannt? Gab es dadurch Probleme?' => ['question:unknown_pickups'],
'War den Busfahrern der Zielort und die Ausladestelle bekannt?' => ['question:drivers_knew_destination'],
'Bitte ankreuzen:' => ['question:video', 'question:wc', 'question:luggage', 'question:smoking', 'question:snow_chains'],
'Entstanden während der Fahrt Schäden am Bus?' => ['question:bus_damage'],
'Was ist passiert?' => ['question:damage_description'],
'Das ging gar nicht / ist besonders hervorzuheben:' => ['question:bus_remarks'],
];
/**
* The house manager briefing of 2026-11-11, question by question, follow-ups included. The
* per-teamer details of guidings and courses are one bespoke question each. "team" is the
* list of the travel's teamers linking into the rating form, which is not part of the answers.
*/
private const array HOUSE_MANAGER_FEEDBACK = [
'Gruppe(n) im Haus?' => ['question:groups_in_house'],
'Busanreise?' => ['question:bus_arrival'],
'Unpünktlich?' => ['question:bus_late'],
'Wann kam der Bus?' => ['question:bus_arrival_time'],
'Gab es No-Shows?' => ['question:no_shows'],
'Wurden Leistungen nicht bezogen?' => ['question:unused_services'],
'Bitte trage hier den Vorfall des Kunden mit VG Nummer ein' => ['question:unused_services_details'],
'Gab es Guidings?' => ['question:guidings'],
'Wer hat das Guiding gegeben? / Welches Guiding wurde gegeben? / Anzahl Guidings? / Teilnehmendenanzahl pro Guiding?' => ['question:guiding_teamers', 'context:teamers'],
'Gab es Kurse?' => ['question:courses'],
'Welche Art von Kurs? / Tageszahl × Stundenzahl / Wann hat der Kurs stattgefunden?' => ['question:course_teamers', 'context:teamers'],
'Gab es Besonderheiten/Abweichungen vom Beispiel-Programm?' => ['question:programme_deviations'],
'Bitte beschreibe was genau' => ['question:programme_deviations_details'],
'Welches Programm hat stattgefunden? (mit Teilnehmendenanzahl, Sonstiges)' => ['question:programme'],
'Gab es besondere Vorkommnisse?' => ['question:incidents'],
'(Freitext zu den Vorkommnissen)' => ['question:incidents_details'],
'Feedback zur Gruppe' => ['question:group_feedback'],
'Bewerte dein Wochenteam' => ['team'],
];
public function testEveryHouseManagerFeedbackQuestionIsAskedOrDerived(): void
{
$destination = (new Destination())->setDateFrom(new \DateTimeImmutable('2027-03-27'))->setDateTo(new \DateTimeImmutable('2027-04-03'));
$this->assertComplete(
QuestionnaireCatalog::HOUSE_MANAGER_FEEDBACK,
self::HOUSE_MANAGER_FEEDBACK,
array_keys(DestinationContext::build($destination, [])),
);
}
public function testEveryTeamerFeedbackQuestionIsAskedOrDerived(): void
{
$this->assertComplete(QuestionnaireCatalog::TEAMER_FEEDBACK, self::TEAMER_FEEDBACK);
}
public function testEveryBusFeedbackQuestionIsAskedOrDerived(): void
{
$this->assertComplete(QuestionnaireCatalog::BUS_FEEDBACK, self::BUS_FEEDBACK);
}
/**
* The Google forms had 19 and 24 questions; with the checkbox list split there are 43 places
* an answer comes from.
*/
public function testTheMappingCoversBothGoogleForms(): void
{
$this->assertCount(19, self::TEAMER_FEEDBACK);
$this->assertCount(24, self::BUS_FEEDBACK);
}
/**
* A bus escort answers every question of both forms; anyone else every question of the
* teamer form.
*/
public function testABusEscortGetsBothQuestionnairesAndEveryoneTheTeamerOne(): void
{
$this->assertSame(
[QuestionnaireCatalog::TEAMER_FEEDBACK, QuestionnaireCatalog::BUS_FEEDBACK],
DispositionContext::questionnaires((new Assignment())->setPickup(4711)),
);
$this->assertSame(
[QuestionnaireCatalog::TEAMER_FEEDBACK],
DispositionContext::questionnaires((new Assignment())->setPickup(0)),
);
}
/**
* @param array<string, list<string>> $googleQuestions
* @param list<string>|null $contextFields what the subject snapshots; a disposition's by default
*/
private function assertComplete(string $questionnaire, array $googleQuestions, ?array $contextFields = null): void
{
$definition = new QuestionnaireCatalog(__DIR__.'/../../config/questionnaires')->get($questionnaire);
$contextFields ??= array_keys(DispositionContext::build(new Disposition(new Application(new Assignment(), new Teamer()))));
$mapped = [];
foreach ($googleQuestions as $label => $targets) {
foreach ($targets as $target) {
[$kind, $key] = explode(':', $target) + [1 => null];
if ('legs' === $kind) {
$this->assertTrue($definition->perBusLeg, sprintf('"%s" is not asked as the legs escorted', $label));
} elseif ('team' === $kind) {
// rendered by the house manager's page, not a question
$this->assertSame(QuestionnaireCatalog::HOUSE_MANAGER_FEEDBACK, $questionnaire);
} elseif ('question' === $kind) {
$this->assertNotNull($definition->getQuestion($key), sprintf('"%s" is not asked as "%s"', $label, $key));
$mapped[] = $key;
} else {
$this->assertContains($key, $contextFields, sprintf('"%s" is not snapshotted as "%s"', $label, $key));
}
}
}
// and nothing is asked that the Google form did not ask
$this->assertSame([], array_values(array_diff(array_keys($definition->getQuestions()), $mapped)));
}
}