From 28bfd535f4b73882b404e1c33542158919f66868 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Fri, 13 Nov 2026 08:33:56 +0100 Subject: [PATCH] Hide quiz answer options on stage until the quiz starts Co-Authored-By: Claude Sonnet 5.5 --- src/Service/ResultsService.php | 6 ++++++ tests/TestCase/Service/QuizTest.php | 16 ++++++++++++++++ webroot/js/plenario.js | 3 ++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Service/ResultsService.php b/src/Service/ResultsService.php index b25cba2..5bedc67 100644 --- a/src/Service/ResultsService.php +++ b/src/Service/ResultsService.php @@ -182,6 +182,12 @@ class ResultsService 'remaining' => $phase === Slide::QUIZ_RUNNING ? $slide->remainingSeconds() : null, 'revealed' => $phase === Slide::QUIZ_FINISHED, ]; + if ($phase === Slide::QUIZ_READY) { + // Answers are only shown once the quiz has been started. + $result['options'] = []; + + return $result; + } if ($phase !== Slide::QUIZ_FINISHED) { $result['options'] = array_map(fn($option) => [ 'id' => $option->id, diff --git a/tests/TestCase/Service/QuizTest.php b/tests/TestCase/Service/QuizTest.php index 75eb26f..53ac694 100644 --- a/tests/TestCase/Service/QuizTest.php +++ b/tests/TestCase/Service/QuizTest.php @@ -110,6 +110,22 @@ class QuizTest extends TestCase $this->assertSame(Slide::QUIZ_FINISHED, $slide->quizPhase()); } + public function testReadyQuizHidesAnswerOptions(): void + { + [$poll, $slide] = $this->createQuiz(); + + $results = (new ResultsService())->forSlide($slide); + $this->assertSame('ready', $results['phase']); + $this->assertSame([], $results['options']); + + $state = $this->participantState($poll, 'p1'); + $this->assertStringNotContainsString('Berlin', (string)json_encode($state)); + + $slide = $this->setOpen($slide, true); + $results = (new ResultsService())->forSlide($slide); + $this->assertSame(['Berlin', 'Hamburg', 'München'], array_column($results['options'], 'label')); + } + public function testRunningQuizHidesCountsAndCorrectAnswers(): void { [$poll, $slide] = $this->createQuiz(); diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index c0dd20c..4827e32 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -892,7 +892,8 @@ } else if (results.phase === 'running') { children.push(el('p', { class: 'quiz-status', text: 'Quiz läuft – ohne Zeitlimit' })); } else { - children.push(el('p', { class: 'quiz-status', text: 'Bereit – starte das Quiz, um die Antworten freizugeben' })); + children.push(el('p', { class: 'quiz-status', text: 'Bereit – die Antworten erscheinen, sobald das Quiz gestartet wird' })); + return el('div', { class: 'quiz-results quiz-results--' + results.phase }, children); } children.push(el('ol', { class: 'quiz-grid' }, results.options.map(function (option, index) { return el('li', { class: 'quiz-tile quiz-tile--c' + (index % 6), text: option.label }); -- 2.54.1