Files
Plenario/templates/Admin/export.php
T
gnilebeinandClaude Opus 5.5 c1f9be2eef Add a star rating style to scale slides
Scales can now be shown as stars (1 to n) instead of numbered steps:
participants tap stars, the stage shows the average as partly filled
stars and the distribution as bars from most to fewest stars, and the
evaluation page and PDF export print ratings as stars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 12:46:33 +01:00

233 lines
12 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
/**
* PDF report with the results of all interactive slides (App\View\PdfView, layout "pdf").
* Without $includeInternal private slides only show how many people took part.
*
* @var \App\View\AppView $this
* @var \App\Model\Entity\Poll $poll
* @var list<array{slide: \App\Model\Entity\Slide, number: int, internal: bool, withheld: bool, results: array<string, mixed>}> $sections
* @var bool $includeInternal
* @var bool $hasInternal Poll has private slides
* @var \Cake\I18n\DateTime $exportedAt
*/
$this->assign('title', $poll->title);
$number = fn(float $value, int $places = 0) => $this->Number->format($value, [
'places' => $places,
'precision' => max(1, $places),
'locale' => 'de_DE',
]);
$bar = function (float $percent, bool $ok = false): string {
$width = max(0, min(100, $percent));
if ($width <= 0) {
// An empty fill would still be drawn as a hairline.
return '<div class="bar__track"></div>';
}
return '<div class="bar__track"><div class="bar__fill' . ($ok ? ' bar__fill--ok' : '') . '" style="width: '
. $width . '%"></div></div>';
};
?>
<div class="page-header">
<span class="brand">PlenarIO</span> · <?= h($poll->title) ?>
<?php if ($includeInternal && $hasInternal) : ?>
· <span class="confidential"><?= __('Vertraulich – enthält interne Antworten') ?></span>
<?php endif; ?>
</div>
<div class="page-footer">
<?= __('Stand: {0}', $exportedAt->i18nFormat('dd.MM.yyyy')) ?> · <?= __('Code {0}', h($poll->formattedJoinCode())) ?>
</div>
<p class="eyebrow"><?= __('Ergebnisse') ?></p>
<h1><?= h($poll->title) ?></h1>
<p class="meta">
<?= __n('{0} Folie mit Abstimmung', '{0} Folien mit Abstimmung', count($sections), count($sections)) ?>
· <?= __('Stand: {0}', $exportedAt->i18nFormat('dd.MM.yyyy')) ?>
</p>
<?php if ($hasInternal && $includeInternal) : ?>
<div class="banner">
<strong><?= __('Vollständige Fassung.') ?></strong>
<?= __('Dieses Dokument enthält anonymes bzw. internes Feedback, das in der Präsentation nicht gezeigt wurde. Bitte nicht weitergeben.') ?>
</div>
<?php elseif ($hasInternal) : ?>
<div class="banner banner--info">
<strong><?= __('Fassung ohne interne Inhalte.') ?></strong>
<?= __('Bei anonymem bzw. internem Feedback ist nur die Zahl der Teilnehmenden enthalten.') ?>
</div>
<?php endif; ?>
<?php if ($sections === []) : ?>
<p class="empty"><?= __('Diese Umfrage hat noch keine Folien mit Abstimmung.') ?></p>
<?php endif; ?>
<?php foreach ($sections as $section) :
$slide = $section['slide'];
$r = $section['results'];
$participants = (int)$r['participants'];
$isScale = $slide->type === 'scale';
// Short sections stay on one page, long lists may break across pages.
$long = count($r['answers'] ?? []) > 8 || count($r['words'] ?? []) > 15
|| count($r['questions'] ?? []) > 10 || count($r['comments'] ?? []) > 5;
?>
<section class="slide<?= $long ? ' slide--long' : '' ?>">
<p class="eyebrow">
<?= __('Folie {0}', $section['number']) ?> · <?= h($slide->typeLabel()) ?>
<?php if ($section['internal']) : ?>
· <span class="tag<?= $section['withheld'] ? '' : ' tag--internal' ?>"><?= $isScale ? __('Internes Feedback') : __('Anonymes Feedback') ?></span>
<?php endif; ?>
</p>
<h2><?= h($slide->question) ?></h2>
<?php if ($slide->description) : ?>
<p class="muted"><?= nl2br(h($slide->description)) ?></p>
<?php endif; ?>
<p class="muted"><?= __n('{0} Person hat teilgenommen', '{0} Personen haben teilgenommen', $participants, $participants) ?></p>
<?php if ($section['withheld']) : ?>
<p class="empty"><?= $isScale
? __('Verteilung, Durchschnitt und Kommentare sind in dieser Fassung nicht enthalten.')
: __('Die Antworten sind in dieser Fassung nicht enthalten.') ?></p>
<?php elseif ($participants === 0) : ?>
<p class="empty"><?= __('Keine Antworten.') ?></p>
<?php elseif ($slide->type === 'choice') : ?>
<table>
<thead><tr><th><?= __('Antwort') ?></th><th class="num"><?= __('Stimmen') ?></th><th class="num"><?= __('Anteil') ?></th><th></th></tr></thead>
<tbody>
<?php foreach ($r['options'] as $option) : ?>
<tr>
<td><?= h($option['label']) ?></td>
<td class="num"><?= (int)$option['count'] ?></td>
<td class="num"><?= $number((float)$option['percent']) ?> %</td>
<td class="bar"><?= $bar((float)$option['percent']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php elseif ($slide->type === 'quiz') : ?>
<?php if (!$r['revealed']) : ?>
<p class="empty"><?= __('Das Quiz wurde nicht beendet, daher gibt es keine Auswertung.') ?></p>
<?php else : ?>
<p><span class="stat"><?= __('{0} von {1}', (int)$r['correctCount'], $participants) ?></span> <?= __('richtig beantwortet') ?></p>
<table>
<thead><tr><th><?= __('Antwort') ?></th><th class="num"><?= __('Stimmen') ?></th><th class="num"><?= __('Anteil') ?></th><th></th></tr></thead>
<tbody>
<?php foreach ($r['options'] as $option) : ?>
<tr>
<td<?= $option['correct'] ? ' class="correct"' : '' ?>><?= $option['correct'] ? '✓ ' : '' ?><?= h($option['label']) ?></td>
<td class="num"><?= (int)$option['count'] ?></td>
<td class="num"><?= $number((float)$option['percent']) ?> %</td>
<td class="bar"><?= $bar((float)$option['percent'], $option['correct']) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php elseif ($slide->type === 'order') : ?>
<?php if (!$r['revealed']) : ?>
<p class="empty"><?= __('Die Abstimmung ist noch offen, die Auflösung gibt es erst nach dem Schließen.') ?></p>
<?php else : ?>
<p><span class="stat"><?= __('{0} von {1}', (int)$r['correctCount'], $participants) ?></span> <?= __('komplett richtig sortiert') ?></p>
<table>
<thead><tr><th class="num"><?= __('Platz') ?></th><th><?= __('Eintrag') ?></th><th class="num"><?= __('richtig platziert') ?></th><th></th></tr></thead>
<tbody>
<?php foreach ($r['items'] as $item) : ?>
<tr>
<td class="num"><?= (int)$item['position'] ?>.</td>
<td><?= h($item['label']) ?></td>
<td class="num"><?= (int)$item['placed'] ?> (<?= $number((float)$item['percent']) ?> %)</td>
<td class="bar"><?= $bar((float)$item['percent'], true) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php elseif ($slide->type === 'wordcloud') :
$hasDown = array_sum(array_column($r['words'], 'down')) > 0; ?>
<table>
<thead><tr><th><?= __('Begriff') ?></th><th class="num"><?= __('Nennungen') ?></th><?php if ($hasDown) : ?><th class="num"><?= __('Downvotes') ?></th><?php endif; ?></tr></thead>
<tbody>
<?php foreach ($r['words'] as $word) : ?>
<tr>
<td><?= h($word['text']) ?></td>
<td class="num"><?= (int)$word['count'] ?></td>
<?php if ($hasDown) : ?><td class="num"><?= (int)$word['down'] ?></td><?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php elseif ($slide->type === 'open') : ?>
<h3><?= __n('{0} Antwort', '{0} Antworten', count($r['answers']), count($r['answers'])) ?> <span class="muted">(<?= __('in Eingangsreihenfolge') ?>)</span></h3>
<ol class="list">
<?php foreach (array_reverse($r['answers']) as $answer) : ?>
<li><?= nl2br(h($answer['text'])) ?></li>
<?php endforeach; ?>
</ol>
<?php elseif ($isScale) : ?>
<p>
<?= __('Durchschnitt') ?>:
<span class="stat"><?= $r['average'] === null ? '–' : $number((float)$r['average'], 1) ?></span>
<span class="muted"><?= !empty($r['stars'])
? __('von {0} Sternen', (int)$r['max'])
: __('auf einer Skala von {0} bis {1}', (int)$r['min'], (int)$r['max']) ?></span>
</p>
<table>
<thead><tr><th><?= !empty($r['stars']) ? __('Sterne') : __('Wert') ?></th><th class="num"><?= __('Anzahl') ?></th><th class="num"><?= __('Anteil') ?></th><th></th></tr></thead>
<tbody>
<?php foreach ($r['buckets'] as $i => $bucket) :
$label = match (true) {
$i === 0 => (string)$r['minLabel'],
$i === count($r['buckets']) - 1 => (string)$r['maxLabel'],
default => '',
}; ?>
<tr>
<td<?= !empty($r['stars']) ? ' class="stars"' : '' ?>><?= h($slide->ratingText((int)$bucket['value'])) ?><?php if ($label !== '') : ?> <span class="muted">(<?= h($label) ?>)</span><?php endif; ?></td>
<td class="num"><?= (int)$bucket['count'] ?></td>
<td class="num"><?= $number((float)$bucket['percent']) ?> %</td>
<td class="bar"><?= $bar((float)$bucket['percent']) ?></td>
</tr>
<?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'])) ?>
<?php if ($comment['value'] !== null) : ?><span class="muted">(<?= __('Bewertung {0}', h($slide->ratingText((int)$comment['value']))) ?>)</span><?php endif; ?>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php endif; ?>
<?php elseif ($slide->type === 'qa') : ?>
<?php if ($r['questions'] === []) : ?>
<p class="empty"><?= __('Keine Fragen eingereicht.') ?></p>
<?php else : ?>
<?php $withUpvotes = $r['maxUpvotes'] > 0; ?>
<table>
<thead><tr><th class="num">#</th><th><?= __('Frage') ?></th><?php if ($withUpvotes) : ?><th class="num"><?= __('Upvotes') ?></th><?php endif; ?></tr></thead>
<tbody>
<?php foreach ($r['questions'] as $i => $question) : ?>
<tr>
<td class="num"><?= $i + 1 ?>.</td>
<td><?= nl2br(h($question['text'])) ?></td>
<?php if ($withUpvotes) : ?><td class="num"><?= (int)$question['votes'] ?></td><?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php endif; ?>
</section>
<?php endforeach; ?>