Quiz slides have predefined answers with one or more marked as correct. The presenter starts the quiz, which then runs until its optional time limit expires or the presenter ends it. Counts and correct answers are only revealed once the quiz is finished; participants then see whether their answer was right. - migration: slide_options.is_correct, slides.voting_started_at/voting_ends_at - Slide::isVotingOpen() includes the quiz deadline, expired quizzes are closed lazily when the state is read - presenter countdown, quiz tiles and reveal with correct-answer summary - CSV export marks quiz answers as right/wrong Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
175 lines
9.2 KiB
PHP
175 lines
9.2 KiB
PHP
<?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
|
||
*/
|
||
$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; ?>
|
||
<?= __('{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>
|
||
<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; ?>
|
||
|
||
<ol class="slide-list">
|
||
<?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' : '' ?>">
|
||
<div class="slide-item__pos"><?= $i + 1 ?></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->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; ?>
|
||
</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>
|
||
<?= $this->Form->postLink('↑', $url('slides:move', ['id' => $slide->id, 'direction' => 'up']), [
|
||
'class' => 'button button--small button--icon', 'title' => __('Nach oben'),
|
||
]) ?>
|
||
<?= $this->Form->postLink('↓', $url('slides:move', ['id' => $slide->id, 'direction' => 'down']), [
|
||
'class' => 'button button--small button--icon', 'title' => __('Nach unten'),
|
||
]) ?>
|
||
<?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>
|
||
|
||
<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">
|
||
<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>
|