Add internal feedback and comments to choice slides
CI / Deploy / test (push) Successful in 55s
CI / Deploy / deploy (push) Skipped

Same options as for scales: "private" shows only the number of votes on
the stage, "comments" adds an optional comment field whose comments
rotate in the presentation, "comment_ratings" shows the chosen answer(s)
next to each comment. With multiple choice the comment is stored on the
participant's first row. Settings and participant fields are shared
elements for scale and choice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-08 18:57:35 +01:00
1 parent 3e09906830
commit 547b564e32
18 files changed
+485 -108

No files matched your search

+50 -22
View File
@@ -8,7 +8,9 @@
* @var string $adminToken
* @var \App\Model\Entity\Slide $slide
* @var list<array{text: string, created: string}> $answers
* @var array<string, mixed>|null $scale Distribution of a scale slide, null for open questions
* @var array<string, mixed>|null $scale Distribution of a scale slide, null otherwise
* @var array<string, mixed>|null $choice Votes of a choice slide, null otherwise
* @var int $participants Participants who answered
* @var list<array{id: int, text: string, value: int, created: string}> $comments Comments of a scale, oldest first
*/
use Cake\I18n\DateTime;
@@ -22,21 +24,46 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
<section class="card">
<p class="eyebrow">
<?= h($slide->typeLabel()) ?>
<?php if ($slide->isPrivate()) : ?>· 🔒 <?= $scale !== null ? __('Internes Feedback') : __('Anonymes Feedback') ?><?php endif; ?>
<?php if ($slide->isPrivate()) : ?>· 🔒 <?= $slide->type === 'open' ? __('Anonymes Feedback') : __('Internes Feedback') ?><?php endif; ?>
</p>
<h1><?= h($slide->question) ?></h1>
<?php if ($scale !== null) : ?>
<p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?></p>
<?php elseif ($choice !== null) : ?>
<p class="muted"><?= __n('{0} Person hat abgestimmt', '{0} Personen haben abgestimmt', $participants, $participants) ?></p>
<?php else : ?>
<p class="muted"><?= __n('{0} Antwort, neueste zuerst', '{0} Antworten, neueste zuerst', $count, $count) ?></p>
<?php endif; ?>
<?php if ($slide->isPrivate()) : ?>
<p class="hint"><?= $scale !== null
? __('Dieses Ergebnis wird weder in der Präsentation noch den Teilnehmenden angezeigt.')
: __('Diese Antworten werden weder in der Präsentation noch den Teilnehmenden angezeigt.') ?></p>
<p class="hint"><?= $slide->type === 'open'
? __('Diese Antworten werden weder in der Präsentation noch den Teilnehmenden angezeigt.')
: __('Dieses Ergebnis wird weder in der Präsentation noch den Teilnehmenden angezeigt.') ?></p>
<?php endif; ?>
<?php if ($scale !== null) : ?>
<?php if ($choice !== null) : ?>
<?php if ($participants === 0) : ?>
<p class="empty"><?= __('Noch keine Stimmen.') ?></p>
<?php else : ?>
<table class="scale-table">
<caption class="sr-only"><?= __('Stimmen je Antwort') ?></caption>
<thead>
<tr><th scope="col"><?= __('Antwort') ?></th><th scope="col"><?= __('Anzahl') ?></th><th scope="col"><?= __('Anteil') ?></th></tr>
</thead>
<tbody>
<?php foreach ($choice['options'] as $option) : ?>
<tr>
<th scope="row"><?= h($option['label']) ?></th>
<td><?= (int)$option['count'] ?></td>
<td>
<span class="scale-table__bar" style="width: <?= (float)$option['percent'] ?>%" aria-hidden="true"></span>
<?= h($this->Number->format((float)$option['percent'], ['places' => 0, 'precision' => 1, 'locale' => 'de_DE'])) ?> %
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php elseif ($scale !== null) : ?>
<?php if ($count === 0) : ?>
<p class="empty"><?= __('Noch keine Bewertungen.') ?></p>
<?php else : ?>
@@ -69,22 +96,6 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
</tbody>
</table>
<?php endif; ?>
<?php if ($slide->hasComments()) : ?>
<h2><?= __n('{0} Kommentar', '{0} Kommentare', count($comments), count($comments)) ?></h2>
<?php if ($comments === []) : ?>
<p class="empty"><?= __('Noch keine Kommentare.') ?></p>
<?php else : ?>
<ol class="answers-page" reversed>
<?php foreach (array_reverse($comments) as $comment) :
$created = new DateTime($comment['created']); ?>
<li>
<?= h($comment['text']) ?>
<time datetime="<?= h($comment['created']) ?>"><?= __('Bewertung {0}', $comment['value']) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php endif; ?>
<?php elseif ($answers === []) : ?>
<p class="empty"><?= __('Noch keine Antworten.') ?></p>
<?php else : ?>
@@ -98,4 +109,21 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php if ($slide->hasComments()) : ?>
<h2><?= __n('{0} Kommentar', '{0} Kommentare', count($comments), count($comments)) ?></h2>
<?php if ($comments === []) : ?>
<p class="empty"><?= __('Noch keine Kommentare.') ?></p>
<?php else : ?>
<ol class="answers-page" reversed>
<?php foreach (array_reverse($comments) as $comment) :
$created = new DateTime($comment['created']); ?>
<li>
<?= h($comment['text']) ?>
<time datetime="<?= h($comment['created']) ?>"><?= $choice !== null ? __('Antwort: {0}', h($comment['value'])) : __('Bewertung {0}', $comment['value']) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php endif; ?>
</section>