Hide quiz answer options on stage until the quiz starts #73

Merged
gnilebein merged 1 commits from fix/quiz-hide-options-until-start into main 2026-11-13 08:35:51 +01:00
3 changed files with 24 additions and 1 deletions
Showing only changes of commit 28bfd535f4 - Show all commits

No files matched your search

+6
View File
@@ -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,
+16
View File
@@ -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();
+2 -1
View File
@@ -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 });