Add ordering slide type
CI / Deploy / test (push) Successful in 50s
CI / Deploy / deploy (push) Skipped

Participants bring shuffled items into the correct order and submit it
once. The admin enters the items in the correct order and can reorder
them by drag & drop or arrow keys. Closing the voting reveals the
solution: how many got it completely right and how often each item was
placed correctly; participants see whether their order was right.

The drag & drop mechanics of the slide list are extracted into a
reusable makeSortable() helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-07 16:47:37 +01:00
1 parent 4eed568a64
commit 918e077734
17 files changed
+922 -95

No files matched your search

+7
View File
@@ -96,6 +96,8 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
'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->isOrder() && !$slide->is_voting_open) : ?>
<span class="muted">· <?= __('Abstimmung geschlossen, aufgelöst') ?></span>
<?php elseif (!$slide->is_voting_open) : ?><span class="muted">· <?= __('Abstimmung geschlossen') ?></span><?php endif; ?>
<?php if ($slide->isPrivate()) : ?><span class="badge" title="<?= __('Antworten werden nicht öffentlich angezeigt') ?>">🔒 <?= __('anonym') ?></span><?php endif; ?>
<?php endif; ?>
@@ -108,6 +110,11 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
fn($o) => $o->is_correct ? '✓ ' . $o->label : $o->label,
$slide->slide_options,
))) ?></p>
<?php elseif ($slide->isOrder() && $slide->slide_options) : ?>
<p class="slide-item__options muted"><?= h(implode(' → ', array_map(
fn($o) => $o->label,
$slide->slide_options,
))) ?></p>
<?php endif; ?>
<details class="slide-embed">
<summary><?= __('Einbett-Link') ?></summary>
+41
View File
@@ -7,6 +7,7 @@
* @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 int $pollIntervalMs
*/
$this->assign('title', $poll->title);
@@ -15,6 +16,7 @@ $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 '';
@@ -125,6 +127,44 @@ $countdown = function (?int $remaining): string {
<?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') : ?>
@@ -222,6 +262,7 @@ $countdown = function (?int $remaining): string {
<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) : ?>
+34
View File
@@ -9,6 +9,7 @@
* @var \App\Model\Entity\Slide $slide
* @var string $optionsText
* @var list<array{label: string, correct: bool}> $quizOptions
* @var list<string> $orderOptions Ordering slide: labels in the correct order
* @var bool|null $hasResponses
*/
@@ -217,6 +218,39 @@ $optionsError = $slide->getError('options_text');
'value' => $settings['time_limit'],
]) ?>
<p class="hint"><?= __('Das Quiz startet erst, wenn du es in der Präsentation startest. Du kannst es jederzeit vorzeitig beenden.') ?></p>
<?php elseif ($slide->isOrder()) :
$orderError = $slide->getError('order_options');
$max = \App\Model\Table\SlidesTable::MAX_ORDER_OPTIONS;
$rows = array_pad($orderOptions, min($max, max(4, count($orderOptions) + 1)), '');
?>
<fieldset class="order-options<?= $orderError ? ' error' : '' ?>" data-order-options data-max="<?= $max ?>"
aria-describedby="order-options-hint<?= $orderError ? ' order-options-error' : '' ?>">
<legend><?= __('Einträge in der richtigen Reihenfolge') ?></legend>
<p class="hint" id="order-options-hint"><?= __('Mindestens zwei, maximal {0} Einträge – von oben (zuerst) nach unten. Teilnehmende bekommen sie gemischt und müssen sie sortieren. Leere Zeilen werden ignoriert.', $max) ?></p>
<p class="hint" data-order-hint hidden><?= __('Zum Umsortieren den Griff ⠿ ziehen, oder Griff fokussieren und Pfeiltasten nutzen.') ?></p>
<ol class="order-options__list" data-order-list>
<?php foreach ($rows as $i => $label) : ?>
<li class="order-option" data-order-row>
<button type="button" class="drag-handle" data-drag-handle hidden
aria-label="<?= __('Eintrag verschieben (Pfeiltasten)') ?>" title="<?= __('Ziehen zum Sortieren') ?>">⠿</button>
<span class="order-option__pos" data-position aria-hidden="true"><?= $i + 1 ?>.</span>
<label class="sr-only" for="order-option-<?= $i ?>" data-row-label><?= __('Platz {0}', $i + 1) ?></label>
<input type="text" id="order-option-<?= $i ?>" name="order_options[]"
value="<?= h($label) ?>" maxlength="255" <?= $i < 2 ? 'required' : '' ?>
placeholder="<?= __('Eintrag {0}', $i + 1) ?>">
</li>
<?php endforeach; ?>
</ol>
<p class="sr-only" role="status" aria-live="polite" data-order-status></p>
<button type="button" class="button button--small" data-order-add hidden>+ <?= __('Eintrag hinzufügen') ?></button>
<?php if ($orderError) : ?>
<div class="error-message" id="order-options-error"><?= h(implode(' ', (array)$orderError)) ?></div>
<?php endif; ?>
<?php if (!empty($hasResponses)) : ?>
<p class="hint"><?= __('Achtung: Umbenannte oder entfernte Einträge zählen bei bisherigen Antworten als falsch. Eine neue Reihenfolge gilt sofort für die Auswertung.') ?></p>
<?php endif; ?>
</fieldset>
<p class="hint"><?= __('Aufgelöst wird, sobald du die Abstimmung schließt: Dann siehst du, wie viele richtig lagen, und jede Person sieht, ob ihre Reihenfolge stimmt.') ?></p>
<?php elseif ($slide->type === 'qa') :
$upvoteOptions = [];
foreach (range(1, \App\Model\Entity\Slide::QA_MAX_UPVOTES) as $n) {