Merge pull request 'Hide quiz answer options on stage until the quiz starts' (#73) from fix/quiz-hide-options-until-start into main
Reviewed-on: #73
This commit was merged in pull request #73.
This commit is contained in:
commit
303431c02b
3 files changed
+24
-1
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in new issue
Block a user