Add optional comment field to multiple choice slides
Participants can justify their choice; the comment is stored once in the first response row, rotates on the stage like scale comments and is listed in the admin area and the PDF export. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
28bfd535f4
commit
61718ed7c6
14 files changed
+330
-29
No files matched your search
@@ -9,13 +9,18 @@
|
||||
* @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 list<array{id: int, text: string, value: int, created: string}> $comments Comments of a scale, oldest first
|
||||
* @var list<array{id: int, text: string, value: int|null, created: string}> $comments Comments of a scale or choice slide, oldest first
|
||||
*/
|
||||
use Cake\I18n\DateTime;
|
||||
|
||||
$this->assign('title', $slide->question);
|
||||
$this->assign('noindex', '1');
|
||||
$count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) : count($answers);
|
||||
$isChoice = $slide->type === 'choice';
|
||||
$count = match (true) {
|
||||
$scale !== null => array_sum(array_column($scale['buckets'], 'count')),
|
||||
$isChoice => count($comments),
|
||||
default => count($answers),
|
||||
};
|
||||
?>
|
||||
<p><a href="<?= $this->Url->build(['_name' => 'admin', 'token' => $adminToken]) ?>">← <?= __('Zurück zur Verwaltung') ?></a></p>
|
||||
|
||||
@@ -27,6 +32,8 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
|
||||
<h1><?= h($slide->question) ?></h1>
|
||||
<?php if ($scale !== null) : ?>
|
||||
<p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?></p>
|
||||
<?php elseif ($isChoice) : ?>
|
||||
<p class="muted"><?= __n('{0} Kommentar, neueste zuerst', '{0} Kommentare, neueste zuerst', $count, $count) ?></p>
|
||||
<?php else : ?>
|
||||
<p class="muted"><?= __n('{0} Antwort, neueste zuerst', '{0} Antworten, neueste zuerst', $count, $count) ?></p>
|
||||
<?php endif; ?>
|
||||
@@ -85,6 +92,20 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php elseif ($isChoice) : ?>
|
||||
<?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']) ?>"><?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php elseif ($answers === []) : ?>
|
||||
<p class="empty"><?= __('Noch keine Antworten.') ?></p>
|
||||
<?php else : ?>
|
||||
|
||||
Reference in new issue
Block a user