Add ordering slide type
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:
1 parent
4eed568a64
commit
918e077734
17 files changed
+922
-95
No files matched your search
@@ -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) : ?>
|
||||
|
||||
Reference in new issue
Block a user