Hide quiz answer options on stage until the quiz starts
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
19320f01c4
commit
28bfd535f4
3 files changed
+24
-1
No files matched your search
@@ -182,6 +182,12 @@ class ResultsService
|
|||||||
'remaining' => $phase === Slide::QUIZ_RUNNING ? $slide->remainingSeconds() : null,
|
'remaining' => $phase === Slide::QUIZ_RUNNING ? $slide->remainingSeconds() : null,
|
||||||
'revealed' => $phase === Slide::QUIZ_FINISHED,
|
'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) {
|
if ($phase !== Slide::QUIZ_FINISHED) {
|
||||||
$result['options'] = array_map(fn($option) => [
|
$result['options'] = array_map(fn($option) => [
|
||||||
'id' => $option->id,
|
'id' => $option->id,
|
||||||
|
|||||||
@@ -110,6 +110,22 @@ class QuizTest extends TestCase
|
|||||||
$this->assertSame(Slide::QUIZ_FINISHED, $slide->quizPhase());
|
$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
|
public function testRunningQuizHidesCountsAndCorrectAnswers(): void
|
||||||
{
|
{
|
||||||
[$poll, $slide] = $this->createQuiz();
|
[$poll, $slide] = $this->createQuiz();
|
||||||
|
|||||||
@@ -892,7 +892,8 @@
|
|||||||
} else if (results.phase === 'running') {
|
} else if (results.phase === 'running') {
|
||||||
children.push(el('p', { class: 'quiz-status', text: 'Quiz läuft – ohne Zeitlimit' }));
|
children.push(el('p', { class: 'quiz-status', text: 'Quiz läuft – ohne Zeitlimit' }));
|
||||||
} else {
|
} 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) {
|
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 });
|
return el('li', { class: 'quiz-tile quiz-tile--c' + (index % 6), text: option.label });
|
||||||
|
|||||||
Reference in new issue
Block a user