diff --git a/AGENTS.md b/AGENTS.md index f4037bb..e2f6a54 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -53,7 +53,7 @@ passende Dokument und pflegt es danach** (Details zu Verhalten, Settings, Tests | Verzeichnisstruktur, Klassen, Tabellen | [docs/architecture.md](docs/architecture.md) | | Folientypen (Wortwolke, Quiz, Q&A, Reihenfolge, YouTube, Skala/Sterne, Kommentare), Checkliste „Neuen Folientyp hinzufügen“ | [docs/slide-types.md](docs/slide-types.md) | | Folienbilder (Upload, Ablage, Löschen) | [docs/images.md](docs/images.md) | -| Live-Schaltung, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung, internes Feedback | [docs/presenter.md](docs/presenter.md) | +| Live-Schaltung, Referentenansicht, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung, internes Feedback | [docs/presenter.md](docs/presenter.md) | | Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild | [docs/frontend.md](docs/frontend.md) | | PDF-Export | [docs/pdf-export.md](docs/pdf-export.md) | | Ablauf/Cleanup von Umfragen, CI/Deploy, Releases, Docker | [docs/operations.md](docs/operations.md) | diff --git a/config/routes.php b/config/routes.php index ed16c91..1ca5dba 100644 --- a/config/routes.php +++ b/config/routes.php @@ -76,6 +76,7 @@ return function (RouteBuilder $routes): void { $admin->connect('/delete', 'Admin::delete', ['_name' => 'admin:delete']) ->setPatterns($token)->setMethods(['POST']); $admin->connect('/present', 'Admin::present', ['_name' => 'admin:present'])->setPatterns($token); + $admin->connect('/speaker', 'Admin::speaker', ['_name' => 'admin:speaker'])->setPatterns($token); $admin->connect('/state', 'Admin::state', ['_name' => 'admin:state'])->setPatterns($token); $admin->connect('/live', 'Admin::live', ['_name' => 'admin:live'])->setPatterns($token); $admin->connect('/control', 'Admin::control', ['_name' => 'admin:control']) diff --git a/docs/frontend.md b/docs/frontend.md index 76a9b46..37dae90 100644 --- a/docs/frontend.md +++ b/docs/frontend.md @@ -12,7 +12,8 @@ Dashboard-Fragmente, Farbschema, Textformatierung, Vollbild. CSP-Regeln stehen i zurück (Dialog bleibt offen), Erfolg als Dashboard-Fragment (Dialog schließt). Ohne JS funktioniert alles als normale Seite. Die Liste folgt auch dem Presenter (Live-Markierung, Status): `initAdminDashboard()` pollt `admin:live` (`AdminController::live()`, nur `{version}` aus `PollStateService::dashboardVersion()`, billiger als der Presenter-State) und lädt `head`/`slides` nur bei geänderter Version - neu – nie bei offenem Dialog, laufender Anfrage oder Drag & Drop; der Fokus wird wiederhergestellt. Test: `PollResetTest::testDashboardLiveVersionFollowsThePresenter`. + neu – nie bei offenem Dialog, laufender Anfrage oder Drag & Drop; der Fokus wird wiederhergestellt. Wechselt dabei die Live-Folie, scrollt `revealCurrent()` sie per `scrollIntoView({block: 'nearest'})` in den + sichtbaren Bereich (bei langen Listen; bewegt nichts, wenn sie schon sichtbar ist; ohne Animation bei `prefers-reduced-motion`). Test: `PollResetTest::testDashboardLiveVersionFollowsThePresenter`. **Buttons mit Bestätigung** nutzen `Form->postButton()` + `data-confirm` (CakePHPs `postLink`/`confirm` erzeugt ein Inline-`onclick`, das die CSP blockiert); das JS fragt per `window.confirm()` vor dem Absenden. Tests: `AdminFragmentTest.php`. diff --git a/docs/presenter.md b/docs/presenter.md index f8fdc1b..0afdca4 100644 --- a/docs/presenter.md +++ b/docs/presenter.md @@ -7,6 +7,15 @@ Live-Schaltung, Pause, Ausblenden, Zurücksetzen, Duplizieren, Einbettung und an Kein WebSocket: Presenter (`/admin/{token}/state`) und Teilnehmende (`/p/{code}/state`) pollen per `fetch` (`Plenario.pollIntervalMs`). Die Teilnehmerseite lädt neu, wenn sich `version` im State ändert. +## Referentenansicht + +- `/admin/{token}/speaker` (`admin:speaker`, Button ⧉ im Präsentationsmodus und Link „Referentenansicht“ neben „Präsentieren“ in der Verwaltung, jeweils neues Fenster) ist für den eigenen Bildschirm des + Präsentierenden: gleiche Seite und gleiches JS wie `present` (`initPresenter`, Steuerung per Tasten/Buttons), plus + `data-next`-Kasten „Als Nächstes“ links neben der aktuellen Folie (`stage--speaker`). Anders als `present` startet sie die Präsentation nicht. +- Datenquelle ist `next` im Presenter-State (`PollStateService::nextPreview()`): Folie hinter der Live-Folie (ausgeblendete werden übersprungen), + bei Pause die pausierte, vor dem Start die erste, `null` nach der letzten. Nur Beschriftungen – nie `is_correct`, bei Reihenfolge keine Optionen + (die gespeicherte Reihenfolge ist die Lösung). Tests: `SpeakerViewTest.php`. + ## Pause - **Pause:** `current_slide_id = null` + `paused_slide_id` = Pause (Teilnehmende sehen „Kurze Pause“), ohne diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index a91c2d6..0fc4442 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -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. * diff --git a/src/Service/PollStateService.php b/src/Service/PollStateService.php index 0e42360..53ec116 100644 --- a/src/Service/PollStateService.php +++ b/src/Service/PollStateService.php @@ -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|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. diff --git a/templates/Admin/index.php b/templates/Admin/index.php index 44fcc3c..d632662 100644 --- a/templates/Admin/index.php +++ b/templates/Admin/index.php @@ -37,6 +37,8 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
▶ + ⧉ current_slide_id !== null) : ?> Form->postButton('⏸ ' . __('Pause'), $url('admin:control'), [ 'data' => ['action' => 'stop'], diff --git a/templates/Admin/present.php b/templates/Admin/present.php index 74e012d..5e78c29 100644 --- a/templates/Admin/present.php +++ b/templates/Admin/present.php @@ -4,6 +4,7 @@ * (Plenario.presenter) from /admin/{token}/state. * * Keyboard: ←/→ slides, P pause/resume (→ resumes too), V voting on/off, H hide results, F fullscreen, Q QR code, T light/dark. + * The speaker view (admin:speaker) is this page plus a preview of the next slide, meant for the presenter's own screen. * Q&A slides: V switches to the next stage; while discussing ←/→ step through the questions first. * * @var \App\View\AppView $this @@ -12,11 +13,13 @@ * @var string $joinUrl * @var string $joinBaseUrl * @var int $pollIntervalMs + * @var bool|null $speaker Speaker view (second window): adds the preview of the next slide */ +$speaker = $speaker ?? false; $this->assign('title', $poll->title); $host = preg_replace('#^https?://#', '', $joinBaseUrl); ?> -
+ + + +