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
@@ -103,6 +103,18 @@ $bar = function (float $percent, bool $ok = false): string {
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if ($slide->hasComments()) : ?>
|
||||
<h3><?= __n('{0} Kommentar', '{0} Kommentare', count($r['comments']), count($r['comments'])) ?></h3>
|
||||
<?php if ($r['comments'] === []) : ?>
|
||||
<p class="empty"><?= __('Keine Kommentare.') ?></p>
|
||||
<?php else : ?>
|
||||
<ol class="list">
|
||||
<?php foreach ($r['comments'] as $comment) : ?>
|
||||
<li><?= nl2br(h($comment['text'])) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ($slide->type === 'quiz') : ?>
|
||||
<?php if (!$r['revealed']) : ?>
|
||||
|
||||
@@ -143,7 +143,11 @@ $hasInternal = array_filter($slides, fn($slide) => !$slide->is_hidden && $slide-
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?php if (($slide->type === 'open' || $slide->isPrivate() || $slide->hasComments()) && $count > 0) :
|
||||
$answersLabel = $slide->type === 'scale' ? __('Auswertung') : __('Antworten'); ?>
|
||||
$answersLabel = match ($slide->type) {
|
||||
'scale' => __('Auswertung'),
|
||||
'choice' => __('Kommentare'),
|
||||
default => __('Antworten'),
|
||||
}; ?>
|
||||
<a class="button button--small button--icon" href="<?= $this->Url->build($url('slides:answers', ['id' => $slide->id])) ?>"
|
||||
title="<?= h($answersLabel) ?>" aria-label="<?= h(__('{0} der Folie „{1}“ ansehen', $answersLabel, $slide->question)) ?>">📊</a>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -266,7 +266,9 @@ $countdown = function (?int $remaining): string {
|
||||
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>
|
||||
: ($slide->type === 'choice'
|
||||
? __('Möglich, solange die Abstimmung läuft. Ein leeres Feld entfernt deinen Kommentar, deine Auswahl bleibt.')
|
||||
: __('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>
|
||||
@@ -290,6 +292,11 @@ $countdown = function (?int $remaining): string {
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($slide->hasComments()) : ?>
|
||||
<label class="scale-comment" for="choice-comment"><?= __('Kommentar (optional)') ?></label>
|
||||
<textarea id="choice-comment" name="comment" rows="3" maxlength="500"
|
||||
placeholder="<?= __('Möchtest du deine Auswahl begründen?') ?>"></textarea>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php elseif ($slide->type === 'open') : ?>
|
||||
<textarea name="text" rows="4" maxlength="500" required
|
||||
|
||||
@@ -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 : ?>
|
||||
|
||||
@@ -132,6 +132,12 @@ $optionsError = $slide->getError('options_text');
|
||||
'label' => __('Mehrfachauswahl erlauben'),
|
||||
'checked' => (bool)$settings['multiple'],
|
||||
]) ?>
|
||||
<?= $this->Form->control('settings.comments', [
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Auswahl optional begründen)'),
|
||||
'checked' => (bool)$settings['comments'],
|
||||
]) ?>
|
||||
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander unter dem Ergebnis durch (nicht bei den Teilnehmenden). Das Tempo stellst du für die ganze Umfrage in den Einstellungen im Dashboard ein.') ?></p>
|
||||
<?php elseif ($slide->type === 'open') : ?>
|
||||
<?= $this->Form->control('settings.private', [
|
||||
'type' => 'checkbox',
|
||||
|
||||
Reference in new issue
Block a user