Files
Plenario/templates/Slides/answers.php
T
gnilebeinandClaude Sonnet 5.5 d6432911ed
CI / Deploy / PHP 8.5 (push) Successful in 1m38s
CI / Deploy / PHP 8.4 (push) Successful in 1m39s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped
Add "Keine Angabe" to scales and an "Enthaltung" shortcut for choice slides
Scales and star ratings get an optional "Keine Angabe" answer (setting
allow_skip). It counts as taking part but stays out of the average and
the distribution; the number is shown separately on stage, in the
evaluation and in the PDF. The choice form gets a button that appends an
"Enthaltung" option.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-21 12:39:44 +01:00

123 lines
6.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* All answers of an open question or the ratings of a scale, including anonymous/internal
* feedback (private slides).
*
* @var \App\View\AppView $this
* @var \App\Model\Entity\Poll $poll
* @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 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');
$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>
<section class="card" data-modal-content>
<p class="eyebrow">
<?= h($slide->typeLabel()) ?>
<?php if ($slide->isPrivate()) : ?>· 🔒 <?= $scale !== null ? __('Internes Feedback') : __('Anonymes Feedback') ?><?php endif; ?>
</p>
<h1 id="modal-title"><?= h($slide->question) ?></h1>
<?php if ($scale !== null) : ?>
<p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?><?php if (!empty($scale['skipped'])) : ?> · <?= __('{0}× „Keine Angabe“', (int)$scale['skipped']) ?><?php endif; ?></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; ?>
<?php if ($slide->isPrivate()) : ?>
<p class="hint"><?= $scale !== null
? __('Dieses Ergebnis ist in der Präsentation zunächst verborgen und wird den Teilnehmenden nie angezeigt.')
: __('Diese Antworten sind in der Präsentation zunächst verborgen und werden den Teilnehmenden nie angezeigt.') ?></p>
<?php endif; ?>
<?php if ($scale !== null) : ?>
<?php if ($count === 0) : ?>
<p class="empty"><?= __('Noch keine Bewertungen.') ?></p>
<?php else : ?>
<p class="scale-average">
<?= __('Durchschnitt') ?>:
<strong><?= h($this->Number->format((float)$scale['average'], ['places' => 1, 'precision' => 1, 'locale' => 'de_DE'])) ?></strong>
<span class="muted"><?= $slide->isStarRating() ? __('von {0} Sternen', (int)$scale['max']) : '/ ' . (int)$scale['max'] ?></span>
</p>
<table class="scale-table">
<caption class="sr-only"><?= __('Verteilung der Bewertungen') ?></caption>
<thead>
<tr><th scope="col"><?= $slide->isStarRating() ? __('Sterne') : __('Wert') ?></th><th scope="col"><?= __('Anzahl') ?></th><th scope="col"><?= __('Anteil') ?></th></tr>
</thead>
<tbody>
<?php foreach ($scale['buckets'] as $i => $bucket) :
$label = match (true) {
$i === 0 && $scale['minLabel'] !== '' => $scale['minLabel'],
$i === count($scale['buckets']) - 1 && $scale['maxLabel'] !== '' => $scale['maxLabel'],
default => '',
}; ?>
<tr>
<th scope="row"><?= $this->element('rating', ['slide' => $slide, 'value' => (int)$bucket['value']]) ?><?php if ($label !== '') : ?> <span class="muted">(<?= h($label) ?>)</span><?php endif; ?></th>
<td><?= (int)$bucket['count'] ?></td>
<td>
<span class="scale-table__bar" style="width: <?= (float)$bucket['percent'] ?>%" aria-hidden="true"></span>
<?= h($this->Number->format((float)$bucket['percent'], ['places' => 0, 'precision' => 1, 'locale' => 'de_DE'])) ?> %
</td>
</tr>
<?php endforeach; ?>
</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') ?> <?= $this->element('rating', ['slide' => $slide, 'value' => (int)$comment['value']]) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li>
<?php endforeach; ?>
</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 : ?>
<ol class="answers-page" reversed>
<?php foreach ($answers as $answer) :
$created = new DateTime($answer['created']); ?>
<li>
<?= h($answer['text']) ?>
<time datetime="<?= h($answer['created']) ?>"><?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
</section>