Wake lock is on by default and restored after slide reloads; fullscreen is a manual toggle. Buttons stay hidden where the APIs are unsupported. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
351 lines
24 KiB
PHP
351 lines
24 KiB
PHP
<?php
|
||
/**
|
||
* Participant page. Server rendered; webroot/js/plenario.js (Plenario.participant)
|
||
* polls /p/{code}/state, reloads when the slide changes and updates results live.
|
||
*
|
||
* @var \App\View\AppView $this
|
||
* @var \App\Model\Entity\Poll $poll
|
||
* @var \App\Model\Entity\Slide|null $slide
|
||
* @var array<string, mixed> $state
|
||
* @var string $participantHash Seed for the shuffled items of ordering slides
|
||
* @var string|null $ownText Own open answer or scale comment (editable while voting is open)
|
||
* @var int $pollIntervalMs
|
||
*/
|
||
use App\Service\VoteService;
|
||
|
||
$this->assign('title', $poll->title);
|
||
$this->assign('bodyClass', 'participant');
|
||
$voteUrl = ['_name' => 'participate:vote', 'code' => $poll->join_code];
|
||
$words = $state['words'] ?? null;
|
||
$quiz = $state['quiz'] ?? null;
|
||
$qa = $state['qa'] ?? null;
|
||
$order = $state['order'] ?? null;
|
||
$countdown = function (?int $remaining): string {
|
||
if ($remaining === null) {
|
||
return '';
|
||
}
|
||
|
||
return '<p class="countdown" role="timer" data-countdown data-remaining="' . $remaining . '">'
|
||
. '<span class="countdown__label">' . h(__('Noch')) . '</span> '
|
||
. '<strong class="countdown__value" data-countdown-value>' . sprintf('%d:%02d', intdiv($remaining, 60), $remaining % 60) . '</strong>'
|
||
. '</p>';
|
||
};
|
||
?>
|
||
<div class="participant-view"
|
||
data-participant
|
||
data-state-url="<?= $this->Url->build(['_name' => 'participate:state', 'code' => $poll->join_code]) ?>"
|
||
data-version="<?= h($state['version']) ?>"
|
||
data-vote-url="<?= $this->Url->build($voteUrl) ?>"
|
||
data-interval="<?= (int)$pollIntervalMs ?>">
|
||
|
||
<p class="eyebrow eyebrow--poll center"><?= h($poll->title) ?></p>
|
||
|
||
<?php // Both buttons stay hidden unless the browser supports the API (no fullscreen on iPhone Safari). ?>
|
||
<div class="screen-tools center" role="group" aria-label="<?= h(__('Anzeige')) ?>">
|
||
<button type="button" class="button button--small" data-fullscreen-toggle hidden aria-pressed="false"
|
||
data-label-on="<?= h(__('Vollbild beenden')) ?>" data-label-off="<?= h(__('Vollbild')) ?>"><?= __('Vollbild') ?></button>
|
||
<button type="button" class="button button--small" data-wakelock-toggle hidden aria-pressed="false"
|
||
data-label-on="<?= h(__('Display bleibt an')) ?>" data-label-off="<?= h(__('Display anlassen')) ?>"><?= __('Display bleibt an') ?></button>
|
||
</div>
|
||
|
||
<?php if (!$poll->is_active) : ?>
|
||
<section class="card center">
|
||
<h1><?= __('Diese Umfrage ist geschlossen.') ?></h1>
|
||
<p class="muted"><?= __('Danke fürs Vorbeischauen!') ?></p>
|
||
</section>
|
||
|
||
<?php elseif ($slide === null && $poll->isPaused()) : ?>
|
||
<section class="card center waiting waiting--pause">
|
||
<div class="pulse" aria-hidden="true"></div>
|
||
<h1><?= __('Kurze Pause') ?></h1>
|
||
<p class="muted"><?= __('Gerade ist keine Frage aktiv. Sobald es weitergeht, erscheint sie hier automatisch – du musst nichts tun.') ?></p>
|
||
</section>
|
||
|
||
<?php elseif ($slide === null) : ?>
|
||
<section class="card center waiting">
|
||
<div class="pulse" aria-hidden="true"></div>
|
||
<h1><?= __('Gleich geht’s los …') ?></h1>
|
||
<p class="muted"><?= __('Warte, bis die erste Frage gestartet wird. Die Seite aktualisiert sich automatisch.') ?></p>
|
||
</section>
|
||
|
||
<?php elseif ($slide->isYouTube()) :
|
||
$watchUrl = $slide->youtubeWatchUrl(); ?>
|
||
<section class="card">
|
||
<p class="eyebrow"><?= __('Video') ?></p>
|
||
<h1><?= h($slide->question) ?></h1>
|
||
<?php if ($slide->description) : ?>
|
||
<div class="prose formatted"><?= $this->Format->text($slide->description) ?></div>
|
||
<?php endif; ?>
|
||
<?php if ($watchUrl !== null) : ?>
|
||
<p class="video-link">
|
||
<a class="button button--primary button--block" href="<?= h($watchUrl) ?>" target="_blank" rel="noopener noreferrer">
|
||
▶ <?= __('Auf YouTube ansehen') ?>
|
||
</a>
|
||
</p>
|
||
<div class="copy-field share-field">
|
||
<input type="text" readonly value="<?= h($watchUrl) ?>" aria-label="<?= __('Link zum Video') ?>" data-copy-source>
|
||
<button type="button" class="button" hidden
|
||
data-share data-share-url="<?= h($watchUrl) ?>" data-share-title="<?= h($slide->question) ?>"
|
||
data-label-share="<?= __('Teilen') ?>" data-label-copy="<?= __('Link kopieren') ?>"><?= __('Teilen') ?></button>
|
||
</div>
|
||
<?php endif; ?>
|
||
</section>
|
||
|
||
<?php elseif (!$slide->isInteractive()) : ?>
|
||
<section class="card">
|
||
<h1><?= h($slide->question) ?></h1>
|
||
<?php if ($slide->description) : ?>
|
||
<div class="prose formatted"><?= $this->Format->text($slide->description) ?></div>
|
||
<?php endif; ?>
|
||
</section>
|
||
|
||
<?php else : ?>
|
||
<section class="card">
|
||
<h1 class="question"><?= h($slide->question) ?></h1>
|
||
<?php if ($slide->description) : ?>
|
||
<div class="muted formatted"><?= $this->Format->text($slide->description) ?></div>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($quiz !== null) : ?>
|
||
<?php if ($quiz['phase'] === 'ready') : ?>
|
||
<div class="waiting center">
|
||
<div class="pulse" aria-hidden="true"></div>
|
||
<p class="muted"><?= __('Das Quiz startet gleich. Die Antworten erscheinen, sobald es losgeht.') ?></p>
|
||
</div>
|
||
<?php elseif ($quiz['phase'] === 'running' && $state['hasResponded']) : ?>
|
||
<?= $countdown($quiz['remaining']) ?>
|
||
<p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p>
|
||
<p class="muted"><?= __('Die Auflösung gibt es, sobald das Quiz beendet ist.') ?></p>
|
||
<?php elseif ($quiz['phase'] === 'running') : ?>
|
||
<?= $countdown($quiz['remaining']) ?>
|
||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form', 'data-quiz-form' => true]) ?>
|
||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||
<fieldset class="choices choices--quiz">
|
||
<legend class="sr-only"><?= __('Antworten') ?></legend>
|
||
<?php foreach ($slide->slide_options as $index => $option) : ?>
|
||
<label class="choice choice--quiz choice--c<?= $index % 6 ?>">
|
||
<input type="radio" name="option_id" value="<?= (int)$option->id ?>" required>
|
||
<span><?= h($option->label) ?></span>
|
||
</label>
|
||
<?php endforeach; ?>
|
||
</fieldset>
|
||
<?= $this->Form->button(__('Antwort abgeben'), ['class' => 'button button--primary button--block']) ?>
|
||
<?= $this->Form->end() ?>
|
||
<?php elseif ($quiz['isCorrect'] === true) : ?>
|
||
<p class="verdict verdict--correct">✓ <?= __('Richtig!') ?></p>
|
||
<?php elseif ($quiz['isCorrect'] === false) : ?>
|
||
<p class="verdict verdict--wrong">✗ <?= __('Leider falsch.') ?></p>
|
||
<?php else : ?>
|
||
<p class="muted"><?= __('Das Quiz ist beendet – du hast keine Antwort abgegeben.') ?></p>
|
||
<?php endif; ?>
|
||
<?php elseif ($order !== null) : ?>
|
||
<?php if ($order['revealed'] && $order['isCorrect'] === true) : ?>
|
||
<p class="verdict verdict--correct">✓ <?= __('Richtig – deine Reihenfolge stimmt!') ?></p>
|
||
<?php elseif ($order['revealed'] && $order['isCorrect'] === false) : ?>
|
||
<p class="verdict verdict--wrong">✗ <?= __('Leider nicht ganz richtig.') ?></p>
|
||
<p class="muted"><?= __('Unten siehst du die richtige Reihenfolge – ✓ markiert, was du richtig platziert hast.') ?></p>
|
||
<?php elseif ($order['revealed']) : ?>
|
||
<p class="muted"><?= __('Die Abstimmung ist geschlossen – du hast keine Reihenfolge eingereicht.') ?></p>
|
||
<?php elseif ($state['hasResponded']) : ?>
|
||
<p class="done">✓ <?= __('Deine Reihenfolge ist angekommen.') ?></p>
|
||
<p class="muted"><?= __('Die Auflösung gibt es, sobald die Abstimmung geschlossen wird.') ?></p>
|
||
<?php else :
|
||
$items = $slide->shuffledOptions($participantHash); ?>
|
||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form order-form', 'data-order-form' => true]) ?>
|
||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||
<p class="hint" id="order-hint"><?= __('Bring die Einträge in die richtige Reihenfolge – oben steht der erste. Ziehe sie am Griff ⠿ oder nutze die Pfeile.') ?></p>
|
||
<noscript><p class="muted"><?= __('Zum Sortieren wird JavaScript benötigt.') ?></p></noscript>
|
||
<ol class="order-list" data-order-list aria-describedby="order-hint">
|
||
<?php foreach ($items as $index => $option) : ?>
|
||
<li class="order-item choice--c<?= $index % 6 ?>" data-order-item>
|
||
<input type="hidden" name="order[]" value="<?= (int)$option->id ?>">
|
||
<button type="button" class="drag-handle" data-drag-handle
|
||
aria-label="<?= h(__('„{0}“ verschieben (Pfeiltasten)', $option->label)) ?>">⠿</button>
|
||
<span class="order-item__pos" data-position aria-hidden="true"><?= $index + 1 ?></span>
|
||
<span class="order-item__label" data-label><?= h($option->label) ?></span>
|
||
<span class="order-item__moves">
|
||
<button type="button" class="order-move" data-move="up"
|
||
aria-label="<?= h(__('„{0}“ nach oben', $option->label)) ?>">▲</button>
|
||
<button type="button" class="order-move" data-move="down"
|
||
aria-label="<?= h(__('„{0}“ nach unten', $option->label)) ?>">▼</button>
|
||
</span>
|
||
</li>
|
||
<?php endforeach; ?>
|
||
</ol>
|
||
<p class="sr-only" role="status" aria-live="polite" data-order-status></p>
|
||
<?= $this->Form->button(__('Reihenfolge einreichen'), ['class' => 'button button--primary button--block']) ?>
|
||
<?= $this->Form->end() ?>
|
||
<?php endif; ?>
|
||
<?php elseif ($qa !== null) : ?>
|
||
<div class="qa" data-qa>
|
||
<?php if ($qa['stage'] === 'collect') : ?>
|
||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form qa-form', 'data-qa-form' => true]) ?>
|
||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||
<label for="qa-question" class="qa-form__label"><?= __('Deine Frage') ?></label>
|
||
<textarea id="qa-question" name="question" rows="3" maxlength="500" required
|
||
aria-describedby="qa-hint" placeholder="<?= __('Was möchtest du wissen?') ?>"></textarea>
|
||
<p class="hint" id="qa-hint"><?= $qa['maxUpvotes'] > 0
|
||
? __('Anonym. Du kannst mehrere Fragen stellen. Schau unten, ob deine Frage schon gestellt wurde – dann unterstützt du sie einfach beim Abstimmen, das nach der Sammelphase beginnt.')
|
||
: __('Anonym. Du kannst mehrere Fragen stellen. Schau unten, ob deine Frage schon gestellt wurde.') ?></p>
|
||
<?= $this->Form->button(__('Frage einreichen'), ['class' => 'button button--primary button--block']) ?>
|
||
<?= $this->Form->end() ?>
|
||
<?php else : ?>
|
||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||
<p class="hint"><?php if ($qa['stage'] === 'vote') : ?>
|
||
<?php if ($qa['maxUpvotes'] === 1) : ?>
|
||
<?= __('Du hast eine Stimme: Gib sie mit „+“ der Frage, die dir am wichtigsten ist. Mit „−“ nimmst du sie zurück.') ?>
|
||
<?php elseif ($qa['maxPerQuestion'] === 1) : ?>
|
||
<?= __('Du hast {0} Stimmen: Verteile sie mit „+“ auf die Fragen, die dir wichtig sind – jede Frage kann eine Stimme von dir bekommen. Mit „−“ nimmst du sie zurück.', $qa['maxUpvotes']) ?>
|
||
<?php elseif ($qa['maxPerQuestion'] < $qa['maxUpvotes']) : ?>
|
||
<?= __('Du hast {0} Stimmen: Verteile sie mit „+“ auf die Fragen, die dir wichtig sind – höchstens {1} auf eine Frage. Mit „−“ nimmst du eine zurück.', $qa['maxUpvotes'], $qa['maxPerQuestion']) ?>
|
||
<?php else : ?>
|
||
<?= __('Du hast {0} Stimmen: Verteile sie mit „+“ auf die Fragen, die dir wichtig sind – gern auch mehrere auf eine Frage. Mit „−“ nimmst du eine zurück.', $qa['maxUpvotes']) ?>
|
||
<?php endif; ?>
|
||
<?php elseif ($qa['maxUpvotes'] > 0) : ?>
|
||
<?= __('Die Fragen werden jetzt besprochen – die mit den meisten Stimmen zuerst.') ?>
|
||
<?php else : ?>
|
||
<?= __('Die Fragen werden jetzt besprochen – in der Reihenfolge, in der sie eingegangen sind.') ?>
|
||
<?php endif; ?></p>
|
||
<noscript><p class="muted"><?= __('Zum Abstimmen wird JavaScript benötigt.') ?></p></noscript>
|
||
<?php endif; ?>
|
||
<p class="qa-message" data-qa-message role="status" aria-live="polite"></p>
|
||
<div data-qa-list></div>
|
||
</div>
|
||
<?php elseif ($words !== null && $slide->is_voting_open) : ?>
|
||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form word-form', 'data-word-form' => true]) ?>
|
||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||
<p class="hint"><?= __('Du kannst beliebig viele Begriffe abgeben.') ?></p>
|
||
<div class="word-entry">
|
||
<input type="text" name="word" maxlength="40" class="word-input" required autofocus
|
||
autocomplete="off" autocapitalize="off" spellcheck="false"
|
||
placeholder="<?= __('Begriff eingeben …') ?>"
|
||
role="combobox" aria-autocomplete="list" aria-expanded="false"
|
||
aria-controls="word-suggestions" data-word-input>
|
||
<ul class="suggestions" id="word-suggestions" role="listbox" hidden data-suggestions></ul>
|
||
</div>
|
||
<p class="word-message" data-word-message aria-live="polite"></p>
|
||
<?= $this->Form->button(__('Begriff senden'), ['class' => 'button button--primary button--block']) ?>
|
||
<?= $this->Form->end() ?>
|
||
<div class="own-words" data-own-words hidden>
|
||
<h2 class="own-words__heading"><?= __('Deine Begriffe') ?></h2>
|
||
<p class="hint"><?= __('Vertippt? Entferne den Begriff mit „ד und gib ihn neu ein.') ?></p>
|
||
<ul class="own-words__list" data-own-words-list></ul>
|
||
</div>
|
||
<?php elseif ($state['hasResponded']) : ?>
|
||
<p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p>
|
||
<?php if (VoteService::hasEditableText($slide) && $slide->isVotingOpen()) :
|
||
$isOpen = $slide->type === 'open'; ?>
|
||
<?php if ($ownText !== null) : ?>
|
||
<p class="own-comment__label"><?= $isOpen ? __('Deine Antwort:') : __('Dein Kommentar:') ?></p>
|
||
<blockquote class="own-comment"><?= nl2br(h($ownText)) ?></blockquote>
|
||
<?php endif; ?>
|
||
<details class="own-comment__edit">
|
||
<summary><?= match (true) {
|
||
$isOpen => __('Antwort bearbeiten'),
|
||
$ownText !== null => __('Kommentar bearbeiten'),
|
||
default => __('Kommentar hinzufügen'),
|
||
} ?></summary>
|
||
<?= $this->Form->create(null, ['url' => ['_name' => 'participate:edit', 'code' => $poll->join_code], 'class' => 'vote-form']) ?>
|
||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||
<label class="scale-comment" for="edit-text"><?= $isOpen ? __('Antwort') : __('Kommentar') ?></label>
|
||
<textarea id="edit-text" name="<?= $isOpen ? 'text' : 'comment' ?>" rows="3" maxlength="500"
|
||
<?= $isOpen ? 'required' : '' ?>
|
||
aria-describedby="edit-text-hint"><?= h((string)$ownText) ?></textarea>
|
||
<p class="hint" id="edit-text-hint"><?= $isOpen
|
||
? __('Möglich, solange die Abstimmung läuft.')
|
||
: __('Möglich, solange die Abstimmung läuft. Ein leeres Feld entfernt deinen Kommentar, deine Bewertung bleibt.') ?></p>
|
||
<?= $this->Form->button($isOpen ? __('Antwort speichern') : __('Kommentar speichern'), ['class' => 'button button--primary button--block']) ?>
|
||
<?= $this->Form->end() ?>
|
||
</details>
|
||
<?php endif; ?>
|
||
<?php elseif (!$slide->is_voting_open) : ?>
|
||
<p class="muted"><?= __('Die Abstimmung zu dieser Frage ist geschlossen.') ?></p>
|
||
<?php else : ?>
|
||
<?= $this->Form->create(null, ['url' => $voteUrl, 'class' => 'vote-form']) ?>
|
||
<?= $this->Form->hidden('slide_id', ['value' => $slide->id]) ?>
|
||
|
||
<?php if ($slide->type === 'choice') :
|
||
$multiple = (bool)$slide->setting('multiple'); ?>
|
||
<?php if ($multiple) : ?><p class="hint"><?= __('Mehrfachauswahl möglich') ?></p><?php endif; ?>
|
||
<div class="choices">
|
||
<?php foreach ($slide->slide_options as $option) : ?>
|
||
<label class="choice">
|
||
<input type="<?= $multiple ? 'checkbox' : 'radio' ?>"
|
||
name="<?= $multiple ? 'option_ids[]' : 'option_id' ?>"
|
||
value="<?= (int)$option->id ?>" <?= $multiple ? '' : 'required' ?>>
|
||
<span><?= h($option->label) ?></span>
|
||
</label>
|
||
<?php endforeach; ?>
|
||
</div>
|
||
|
||
<?php elseif ($slide->type === 'open') : ?>
|
||
<textarea name="text" rows="4" maxlength="500" required
|
||
<?= $slide->isPrivate() ? 'aria-describedby="private-hint"' : '' ?>
|
||
placeholder="<?= __('Deine Antwort …') ?>"></textarea>
|
||
<?php if ($slide->isPrivate()) : ?>
|
||
<p class="hint private-hint" id="private-hint">
|
||
🔒 <?= __('Anonymes Feedback: Die Antworten erscheinen nicht automatisch in der Präsentation, und deine Antwort wird nicht mit deinem Namen gespeichert.') ?>
|
||
</p>
|
||
<?php endif; ?>
|
||
|
||
<?php elseif ($slide->type === 'scale') :
|
||
$maxValue = (int)$slide->setting('scale_max'); ?>
|
||
<?php if ($slide->isStarRating()) : ?>
|
||
<div class="stars<?= $maxValue > 6 ? ' stars--many' : '' ?>" role="radiogroup" aria-label="<?= __('Bewertung in Sternen') ?>"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
|
||
<?php for ($v = 1; $v <= $maxValue; $v++) : ?>
|
||
<label class="stars__star">
|
||
<input type="radio" name="value" value="<?= $v ?>" required>
|
||
<span class="stars__icon" aria-hidden="true">★</span>
|
||
<span class="sr-only"><?= __('{0} von {1} Sternen', $v, $maxValue) ?></span>
|
||
</label>
|
||
<?php endfor; ?>
|
||
</div>
|
||
<?php else : ?>
|
||
<div class="scale"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
|
||
<?php for ($v = (int)$slide->setting('scale_min'); $v <= $maxValue; $v++) : ?>
|
||
<label class="scale__step">
|
||
<input type="radio" name="value" value="<?= $v ?>" required>
|
||
<span><?= $v ?></span>
|
||
</label>
|
||
<?php endfor; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
<div class="scale__labels">
|
||
<span><?= h((string)$slide->setting('min_label')) ?></span>
|
||
<span><?= h((string)$slide->setting('max_label')) ?></span>
|
||
</div>
|
||
<?php if ($slide->hasComments()) : ?>
|
||
<label class="scale-comment" for="scale-comment"><?= __('Kommentar (optional)') ?></label>
|
||
<textarea id="scale-comment" name="comment" rows="3" maxlength="500"
|
||
placeholder="<?= __('Möchtest du deine Bewertung begründen?') ?>"></textarea>
|
||
<?php endif; ?>
|
||
<?php if ($slide->isPrivate()) : ?>
|
||
<p class="hint private-hint" id="private-hint">
|
||
🔒 <?= __('Internes Feedback: Das Ergebnis erscheint nicht automatisch in der Präsentation, und deine Bewertung wird nicht mit deinem Namen gespeichert.') ?>
|
||
</p>
|
||
<?php endif; ?>
|
||
<?php endif; ?>
|
||
|
||
<?= $this->Form->button(__('Absenden'), ['class' => 'button button--primary button--block']) ?>
|
||
<?= $this->Form->end() ?>
|
||
<?php endif; ?>
|
||
</section>
|
||
|
||
<section class="card results-card" data-results-card <?= $state['results'] ? '' : 'hidden' ?>>
|
||
<h2><?= match (true) {
|
||
$words !== null => __('Wortwolke'),
|
||
$quiz !== null => __('Auflösung'),
|
||
$order !== null => __('Richtige Reihenfolge'),
|
||
default => __('Ergebnisse'),
|
||
} ?></h2>
|
||
<?php if ($words !== null && $words['allowUpvotes'] && $slide->is_voting_open) : ?>
|
||
<p class="hint" data-upvote-hint><?= $words['allowDownvotes']
|
||
? __('Tippe auf einen Begriff, um ihn zu unterstützen, oder auf „−“, um ihn abzulehnen.')
|
||
: __('Tippe auf einen Begriff, um ihn zu unterstützen.') ?></p>
|
||
<?php endif; ?>
|
||
<div data-results></div>
|
||
</section>
|
||
<script type="application/json" data-initial-state><?= json_encode($state, JSON_HEX_TAG | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE) ?></script>
|
||
<?php endif; ?>
|
||
</div>
|