Add an optional countdown to every slide that collects answers
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / PHP 8.5 (push) Successful in 1m29s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

Choice, word cloud, open question, scale and ordering slides get a time
limit like the quiz. With a limit the slide waits ("ready") showing only
the question; next starts the countdown, the next one ends it, the third
moves on. Stage results and the ordering solution are withheld until the
countdown has started. The countdown music plays during any countdown.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-21 12:18:33 +01:00
1 parent 722e845cff
commit 27771e7470
19 files changed
+480 -34

No files matched your search

+4 -2
View File
@@ -134,7 +134,7 @@ class PollStateService
'next' => $this->nextPreview($poll, $slides, $index),
'hiddenCount' => $this->Slides->find()->where(['poll_id' => $poll->id, 'is_hidden' => true])->count(),
'slide' => $current ? $this->slidePayload($current, $poll) : null,
'results' => $current ? $this->results->forSlide($current) : null,
'results' => $current ? $this->results->forStage($current) : null,
];
}
@@ -196,7 +196,7 @@ class PollStateService
'index' => null,
'count' => null,
'slide' => $this->slidePayload($slide, $poll),
'results' => $this->results->forSlide($slide),
'results' => $this->results->forStage($slide),
];
}
@@ -250,6 +250,8 @@ class PollStateService
]),
'slide' => $showResults ? $this->slidePayload($slide, $poll) : null,
'results' => $showResults ? $this->participantResults($slide) : null,
// Countdown of a slide that is not a quiz (a quiz has its own state below)
'timer' => $slide !== null && !$slide->isQuiz() && $slide->usesPhases() ? $this->results->timer($slide) : null,
'words' => $words,
'quiz' => $quiz,
'qa' => $qa,
+42
View File
@@ -78,6 +78,9 @@ class ResultsService
'type' => $slide->type,
'participants' => $slide->isInteractive() ? $this->Responses->countParticipants($slide->id) : 0,
];
if ($slide->usesPhases()) {
$result['timer'] = $this->timer($slide);
}
return $result + match ($slide->type) {
Slide::TYPE_CHOICE => $this->choice($slide, $limit),
@@ -91,6 +94,45 @@ class ResultsService
};
}
/**
* Results for the stage (presenter view and embed). A slide with a countdown that has not been started yet
* shows only its question: no answers, no counts, no solution (`ready`), whatever is stored for it.
* The evaluation (admin, PDF) uses forSlide(), which is never gated.
*
* @param \App\Model\Entity\Slide $slide Slide
* @return array<string, mixed>
*/
public function forStage(Slide $slide): array
{
if ($slide->phase() === Slide::QUIZ_READY && !$slide->isQuiz()) {
return [
'type' => $slide->type,
'participants' => 0,
'ready' => true,
'timer' => $this->timer($slide),
];
}
return $this->forSlide($slide);
}
/**
* Countdown of a slide: phase (ready|running|finished), the limit and the seconds left while running.
*
* @param \App\Model\Entity\Slide $slide Slide with a countdown
* @return array{phase: string|null, timeLimit: int, remaining: int|null}
*/
public function timer(Slide $slide): array
{
$phase = $slide->phase();
return [
'phase' => $phase,
'timeLimit' => (int)$slide->setting('time_limit'),
'remaining' => $phase === Slide::QUIZ_RUNNING ? $slide->remainingSeconds() : null,
];
}
/**
* @param \App\Model\Entity\Slide $slide Slide
* @return array<string, mixed>
+2
View File
@@ -226,6 +226,8 @@ class VoteService
throw new VoteException(match (true) {
$slide->isQuiz() && $slide->voting_started_at === null => __('Das Quiz hat noch nicht begonnen.'),
$slide->isQuiz() => __('Die Zeit für dieses Quiz ist abgelaufen.'),
$slide->usesPhases() && $slide->voting_started_at === null => __('Die Abstimmung hat noch nicht begonnen.'),
$slide->usesPhases() => __('Die Zeit für diese Frage ist abgelaufen.'),
$slide->isQa() => __('Die Fragerunde läuft – Fragen und Stimmen sind nicht mehr möglich.'),
default => __('Die Abstimmung zu dieser Frage ist geschlossen.'),
});