feat: keep questionnaires until submitted, remind teamers daily and take bus feedback per leg

This commit is contained in:
fromme committed 2026-11-10 16:38:51 +01:00
1 parent abf9c1be0b
commit e72616fdbf
37 files changed
+1119 -238

No files matched your search

+21 -4
View File
@@ -46,6 +46,19 @@ class QuestionnaireCatalogTest extends TestCase
}
}
/**
* An escort may ride the outbound bus, the return bus or both, so the bus feedback is answered
* per leg and no longer asks for the direction.
*/
public function testOnlyTheBusFeedbackIsAnsweredPerLeg(): void
{
$catalog = new QuestionnaireCatalog(self::SHIPPED_DIR);
$this->assertTrue($catalog->get(QuestionnaireCatalog::BUS_FEEDBACK)->perBusLeg);
$this->assertNull($catalog->get(QuestionnaireCatalog::BUS_FEEDBACK)->getQuestion('direction'));
$this->assertFalse($catalog->get(QuestionnaireCatalog::TEAMER_FEEDBACK)->perBusLeg);
}
public function testTheTwoQuestionnairesAreTheCurrentKeys(): void
{
$this->assertSame(
@@ -112,16 +125,16 @@ class QuestionnaireCatalogTest extends TestCase
$this->assertSame('Alte Frage', $catalog->get('sample', 1)->getQuestion('answer')->label);
}
public function testTheWindowStartsTheGivenDaysBeforeToday(): void
public function testTheGoLiveDateIsADay(): void
{
$this->assertEquals(new \DateTimeImmutable('today -2 days'), QuestionnaireCatalog::windowStart(2));
$this->assertEquals(new \DateTimeImmutable('2026-11-10 00:00'), QuestionnaireCatalog::parseGoLive('2026-11-10'));
}
public function testANegativeWindowFailsLoudly(): void
public function testAMalformedGoLiveDateFailsLoudly(): void
{
$this->expectException(\InvalidArgumentException::class);
QuestionnaireCatalog::windowStart(-1);
QuestionnaireCatalog::parseGoLive('10.11.2026');
}
public function testUnknownQuestionnaireIsRejected(): void
@@ -151,6 +164,10 @@ class QuestionnaireCatalogTest extends TestCase
static fn (array $d): array => self::withQuestion($d, 1, ['requried' => true]),
'unknown field(s) requried',
];
yield 'per_bus_leg not a boolean' => [
static fn (array $d): array => ['per_bus_leg' => 'yes'] + $d,
'per_bus_leg must be true or false',
];
yield 'unknown type' => [
static fn (array $d): array => self::withQuestion($d, 1, ['type' => 'slider']),
'unknown type "slider"',
@@ -19,7 +19,8 @@ use PHPUnit\Framework\TestCase;
*
* 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()). Google's "Bitte ankreuzen:" checkbox list was split
* 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
@@ -48,7 +49,7 @@ class QuestionnaireCompletenessTest extends TestCase
private const array BUS_FEEDBACK = [
'(Datum, ohne Titel)' => ['context:escortPickupDate', 'context:dateTo'],
'Hin- oder Rückfahrt' => ['question:direction'],
'Hin- oder Rückfahrt' => ['legs'],
'Reiseziel:' => ['context:destinationProduct'],
'Bus-Unternehmen:' => ['question:bus_company'],
'Name des Busunternehmens:' => ['question:bus_company_other'],
@@ -120,9 +121,11 @@ class QuestionnaireCompletenessTest extends TestCase
foreach ($googleQuestions as $label => $targets) {
foreach ($targets as $target) {
[$kind, $key] = explode(':', $target);
[$kind, $key] = explode(':', $target) + [1 => null];
if ('question' === $kind) {
if ('legs' === $kind) {
$this->assertTrue($definition->perBusLeg, sprintf('"%s" is not asked as the legs escorted', $label));
} elseif ('question' === $kind) {
$this->assertNotNull($definition->getQuestion($key), sprintf('"%s" is not asked as "%s"', $label, $key));
$mapped[] = $key;
} else {