Files
Plenario/templates/Admin/index.php
T
gnilebeinandClaude Opus 5.5 07a292d109
CI / Deploy / test (push) Successful in 1m4s
CI / Deploy / deploy (push) Skipped
Add embeddable slides and pause mode
Every slide gets an embed URL /e/{key}/{id} for presentation software
like Canva. The page goes live while it is visible, keeps itself live
with heartbeats and pauses when it disappears; stale embeds are paused
lazily. The embed key is separate from the admin token and only allows
showing, activating, pausing and voting controls of that slide.

Participants see a pause page while no slide is live. The presenter
can pause (P) and resume the paused slide with the arrow keys; the
dashboard has a pause button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 16:26:05 +01:00

215 lines
12 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Admin dashboard of a poll.
*
* @var \App\View\AppView $this
* @var \App\Model\Entity\Poll $poll
* @var string $adminToken
* @var list<\App\Model\Entity\Slide> $slides
* @var array<int, int> $responseCounts
* @var array<string, string> $typeLabels
* @var array<string, string> $typeDescriptions
* @var string $joinUrl
* @var string $embedKey
*/
$this->assign('title', $poll->title);
$this->assign('noindex', '1');
$url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $adminToken] + $params;
?>
<div class="admin-head">
<div>
<p class="eyebrow"><?= __('Verwaltung') ?></p>
<h1><?= h($poll->title) ?></h1>
<p class="muted">
<?php if ($poll->is_active) : ?>
<span class="badge badge--ok"><?= __('aktiv') ?></span>
<?php else : ?>
<span class="badge badge--off"><?= __('geschlossen') ?></span>
<?php endif; ?>
<?php if ($poll->isPaused()) : ?>
<span class="badge"><?= __('Pause') ?></span>
<?php endif; ?>
<?= __('{0} Folien', count($slides)) ?>
</p>
</div>
<div class="admin-head__actions">
<a class="button button--primary" target="_blank" rel="noopener"
href="<?= $this->Url->build($url('admin:present')) ?>">▶ <?= __('Präsentieren') ?></a>
<?php if ($poll->current_slide_id !== null) : ?>
<?= $this->Form->postLink('⏸ ' . __('Pause'), $url('admin:control'), [
'data' => ['action' => 'stop'],
'class' => 'button',
'title' => __('Keine Folie zeigen – Teilnehmende sehen eine Pause-Seite'),
]) ?>
<?php endif; ?>
<a class="button" href="<?= $this->Url->build($url('admin:export')) ?>"><?= __('CSV-Export') ?></a>
</div>
</div>
<div class="notice">
<strong><?= __('Bookmark diese Seite!') ?></strong>
<?= __('Diese URL ist dein Zugang zur Umfrage. Wer sie kennt, kann alles bearbeiten.') ?>
</div>
<div class="grid grid--sidebar">
<section>
<div class="section-head">
<h2><?= __('Folien') ?></h2>
</div>
<?php if ($slides === []) : ?>
<div class="empty">
<p><?= __('Noch keine Folien. Wähle unten einen Typ, um die erste Frage anzulegen.') ?></p>
</div>
<?php endif; ?>
<?php if (count($slides) > 1) : ?>
<p class="muted slide-list__hint" data-sortable-hint hidden><?= __('Tipp: Folien am Griff ⠿ ziehen, um die Reihenfolge zu ändern (oder Griff fokussieren und Pfeiltasten nutzen).') ?></p>
<?php endif; ?>
<ol class="slide-list" data-sortable="<?= h($this->Url->build($url('slides:reorder'))) ?>">
<?php foreach ($slides as $i => $slide) :
$isCurrent = $poll->current_slide_id === $slide->id;
$count = $responseCounts[$slide->id] ?? 0;
?>
<li class="slide-item<?= $isCurrent ? ' slide-item--current' : '' ?>" data-slide-id="<?= $slide->id ?>">
<div class="slide-item__lead">
<button type="button" class="drag-handle" data-drag-handle hidden
aria-label="<?= h(__('Folie „{0}“ verschieben (Pfeiltasten)', $slide->question)) ?>"
title="<?= __('Ziehen zum Sortieren') ?>">⠿</button>
<span class="slide-item__pos" data-position><?= $i + 1 ?></span>
</div>
<div class="slide-item__body">
<div class="slide-item__meta">
<span class="badge badge--type-<?= h($slide->type) ?>"><?= h($slide->typeLabel()) ?></span>
<?php if ($isCurrent) : ?><span class="badge badge--live"><?= __('live') ?></span><?php endif; ?>
<?php if ($slide->isInteractive()) : ?>
<span class="muted"><?= __n('{0} Antwort', '{0} Antworten', $count, $count) ?></span>
<?php if ($slide->isQuiz()) : ?>
<span class="muted">· <?= h([
'ready' => __('Quiz noch nicht gestartet'),
'running' => __('Quiz läuft'),
'finished' => __('Quiz beendet'),
][$slide->quizPhase()]) ?></span>
<?php elseif ($slide->isQa()) : ?>
<span class="muted">· <?= h([
'collect' => __('Fragen sammeln'),
'vote' => __('Abstimmung läuft'),
'discuss' => __('Fragen werden besprochen'),
][$slide->qaStage()]) ?> · <?= __n('max. {0} Upvote pro Person', 'max. {0} Upvotes pro Person', (int)$slide->setting('max_upvotes'), (int)$slide->setting('max_upvotes')) ?></span>
<?php elseif (!$slide->is_voting_open) : ?><span class="muted">· <?= __('Abstimmung geschlossen') ?></span><?php endif; ?>
<?php endif; ?>
</div>
<a class="slide-item__title" href="<?= $this->Url->build($url('slides:edit', ['id' => $slide->id])) ?>"><?= h($slide->question) ?></a>
<?php if ($slide->type === 'choice' && $slide->slide_options) : ?>
<p class="slide-item__options muted"><?= h(implode(' · ', array_map(fn($o) => $o->label, $slide->slide_options))) ?></p>
<?php elseif ($slide->isQuiz() && $slide->slide_options) : ?>
<p class="slide-item__options muted"><?= h(implode(' · ', array_map(
fn($o) => $o->is_correct ? '✓ ' . $o->label : $o->label,
$slide->slide_options,
))) ?></p>
<?php endif; ?>
<details class="slide-embed">
<summary><?= __('Einbett-Link') ?></summary>
<div class="copy-field">
<input type="text" readonly data-copy-source
value="<?= h($this->Url->build(['_name' => 'embed', 'key' => $embedKey, 'id' => $slide->id], ['fullBase' => true])) ?>"
aria-label="<?= h(__('Einbett-Link für Folie „{0}“', $slide->question)) ?>">
<button type="button" class="button button--small" data-copy><?= __('Kopieren') ?></button>
</div>
</details>
</div>
<div class="slide-item__actions">
<?php if (!$isCurrent) : ?>
<?= $this->Form->postLink(__('Live'), $url('admin:control'), [
'data' => ['action' => 'goto', 'slide_id' => $slide->id],
'class' => 'button button--small',
'title' => __('Diese Folie jetzt den Teilnehmenden zeigen'),
]) ?>
<?php endif; ?>
<a class="button button--small" href="<?= $this->Url->build($url('slides:edit', ['id' => $slide->id])) ?>"><?= __('Bearbeiten') ?></a>
<?php if ($count > 0) : ?>
<?= $this->Form->postLink(__('Zurücksetzen'), $url('slides:reset', ['id' => $slide->id]), [
'class' => 'button button--small',
'confirm' => __('Alle {0} Antworten dieser Folie löschen?', $count),
]) ?>
<?php endif; ?>
<?= $this->Form->postLink(__('Löschen'), $url('slides:delete', ['id' => $slide->id]), [
'class' => 'button button--small button--danger',
'confirm' => __('Folie „{0}“ inkl. aller Antworten löschen?', $slide->question),
]) ?>
</div>
</li>
<?php endforeach; ?>
</ol>
<p class="sr-only" role="status" aria-live="polite" data-sortable-status></p>
<h3><?= __('Neue Folie') ?></h3>
<div class="type-picker">
<?php foreach ($typeLabels as $type => $label) : ?>
<a class="type-card type-card--<?= h($type) ?>" href="<?= $this->Url->build($url('slides:add', ['?' => ['type' => $type]])) ?>">
<strong><?= h($label) ?></strong>
<span><?= h($typeDescriptions[$type]) ?></span>
</a>
<?php endforeach; ?>
</div>
</section>
<aside class="sidebar">
<section class="card">
<h2><?= __('Teilnahme') ?></h2>
<p class="join-code"><?= h($poll->formattedJoinCode()) ?></p>
<img class="qr" src="<?= $this->Url->build($url('admin:qr')) ?>" alt="<?= __('QR-Code zur Teilnahme') ?>" width="160" height="160">
<div class="copy-field">
<input type="text" readonly value="<?= h($joinUrl) ?>" aria-label="<?= __('Teilnahme-Link') ?>" data-copy-source>
<button type="button" class="button button--small" data-copy><?= __('Kopieren') ?></button>
</div>
</section>
<section class="card" id="embed">
<h2><?= __('In Präsentation einbetten') ?></h2>
<p class="hint"><?= __('Jede Folie hat einen eigenen Einbett-Link (unter „Einbett-Link“ in der Folienliste). Füge ihn z. B. in Canva als Einbettung auf einer Folie ein.') ?></p>
<p class="hint"><?= __('Sobald die eingebettete Folie im Vortrag zu sehen ist, wird sie live geschaltet. Bei allen anderen Folien sehen Teilnehmende eine Pause-Seite.') ?></p>
<p class="hint"><?= __('Der Link zeigt nur diese Folie und kann sie live schalten – die Umfrage bearbeiten kann damit niemand.') ?></p>
<?= $this->Form->postLink(__('Neue Einbett-Links erzeugen'), $url('admin:rotate-embed'), [
'class' => 'button button--small',
'confirm' => __('Neue Einbett-Links erzeugen? Alle bisher eingebetteten Folien funktionieren danach nicht mehr.'),
]) ?>
</section>
<section class="card">
<h2><?= __('Einstellungen') ?></h2>
<?= $this->Form->create($poll, ['url' => $url('admin:settings'), 'type' => 'post']) ?>
<?= $this->Form->control('title', ['label' => __('Titel'), 'maxlength' => 200]) ?>
<?= $this->Form->control('is_active', [
'type' => 'checkbox',
'label' => __('Umfrage ist aktiv (Teilnehmende können abstimmen)'),
]) ?>
<?= $this->Form->control('show_results_to_participants', [
'type' => 'checkbox',
'label' => __('Teilnehmende sehen Ergebnisse nach ihrer Antwort'),
]) ?>
<?= $this->Form->button(__('Speichern'), ['class' => 'button']) ?>
<?= $this->Form->end() ?>
</section>
<section class="card card--danger">
<h2><?= __('Sicherheit') ?></h2>
<p class="hint"><?= __('Link versehentlich geteilt? Erzeuge einen neuen – der alte wird sofort ungültig.') ?></p>
<?= $this->Form->postLink(__('Neuen Admin-Link erzeugen'), $url('admin:rotate'), [
'class' => 'button button--small',
'confirm' => __('Neuen Admin-Link erzeugen? Der aktuelle Link funktioniert danach nicht mehr.'),
]) ?>
<h3><?= __('Umfrage löschen') ?></h3>
<?= $this->Form->create(null, ['url' => $url('admin:delete')]) ?>
<?= $this->Form->control('confirm_code', [
'label' => __('Zum Bestätigen Code {0} eingeben', $poll->join_code),
'autocomplete' => 'off',
'required' => true,
]) ?>
<?= $this->Form->button(__('Endgültig löschen'), ['class' => 'button button--danger']) ?>
<?= $this->Form->end() ?>
</section>
</aside>
</div>