Add a speaker view with a next-slide preview and keep the live slide in view
CI / Deploy / PHP 8.4 (push) Successful in 1m11s
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped

- New /admin/{token}/speaker page for a second window: current slide, preview of
  the next slide and the usual controls. It does not start the presentation.
- The presenter state gets `next` (labels only, no solutions).
- The dashboard scrolls the live slide into view when the presenter moves on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-16 15:43:49 +01:00
1 parent 8262411225
commit 66ed198f87
11 files changed
+264 -5

No files matched your search

+23 -1
View File
@@ -169,7 +169,16 @@ class AdminController extends AdminAppController
*/
public function present(): void
{
if ($this->poll->current_slide_id === null && !$this->poll->isPaused()) {
$this->prepareStage(true);
}
/**
* @param bool $start Show the first slide if the presentation has not been started yet
* @return void
*/
private function prepareStage(bool $start): void
{
if ($start && $this->poll->current_slide_id === null && !$this->poll->isPaused()) {
$first = $this->Slides->find()
->where(['poll_id' => $this->poll->id, 'is_hidden' => false])
->orderBy(['position' => 'ASC', 'id' => 'ASC'])
@@ -186,6 +195,19 @@ class AdminController extends AdminAppController
$this->setPollInterval();
}
/**
* Speaker view for a second window or screen: current slide, preview of the next one and the
* same controls as the presenter screen. Unlike present() it never starts the presentation.
*
* @return void
*/
public function speaker(): void
{
$this->prepareStage(false);
$this->set('speaker', true);
$this->viewBuilder()->setTemplate('present');
}
/**
* JSON state for the presenter screen.
*
+39
View File
@@ -131,12 +131,51 @@ class PollStateService
], $slides),
'index' => $index,
'count' => count($slides),
'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,
];
}
/**
* Preview of the slide that comes next for the speaker view: the one behind the live slide, the
* paused one while paused (that is where "continue" goes), the first one before the start.
* Labels only: never `is_correct` and never the options of an order slide (they are stored in the
* correct order), so nothing leaks that is not allowed in the JSON before the slide is resolved.
*
* @param \App\Model\Entity\Poll $poll Poll
* @param list<\App\Model\Entity\Slide> $slides Visible slides in presentation order
* @param int|null $index Index of the live slide in `$slides`
* @return array<string, mixed>|null Null after the last slide
*/
private function nextPreview(Poll $poll, array $slides, ?int $index): ?array
{
if ($index !== null) {
$next = $slides[$index + 1] ?? null;
} else {
$next = $slides[0] ?? null;
foreach ($slides as $slide) {
if ($poll->paused_slide_id !== null && $slide->id === $poll->paused_slide_id) {
$next = $slide;
}
}
}
if ($next === null) {
return null;
}
return [
'id' => $next->id,
'type' => $next->type,
'typeLabel' => $next->typeLabel(),
'question' => $next->question,
'description' => (string)$next->description,
'options' => $next->isOrder() ? [] : array_map(fn($o) => $o->label, $next->slide_options ?? []),
'hasImage' => $next->hasImage(),
];
}
/**
* State of one embedded slide (/e/{key}/{slide}/state). Same shape as forPresenter(),
* but always for this slide, live or not, plus `isLive`. Never contains the slide list.