Replace CSV export with PDF export
CI / Deploy / test (push) Successful in 53s
CI / Deploy / deploy (push) Skipped

The results export is now a PDF (Dompdf) with all interactive slides.
By default private slides (anonymous/internal feedback) only show their
number of participants; ?internal=1 creates the complete version incl.
their answers, marked as confidential on every page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-08 19:21:10 +01:00
1 parent 5cd1be1cf8
commit d1facd32a6
21 files changed
+1102 -110

No files matched your search

+229
View File
@@ -0,0 +1,229 @@
<?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"><?= __('auf einer Skala von {0} bis {1}', (int)$r['min'], (int)$r['max']) ?></span>
</p>
<table>
<thead><tr><th><?= __('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><?= (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}', (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 : ?>
<table>
<thead><tr><th class="num">#</th><th><?= __('Frage') ?></th><th class="num"><?= __('Upvotes') ?></th></tr></thead>
<tbody>
<?php foreach ($r['questions'] as $i => $question) : ?>
<tr>
<td class="num"><?= $i + 1 ?>.</td>
<td><?= nl2br(h($question['text'])) ?></td>
<td class="num"><?= (int)$question['votes'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php endif; ?>
</section>
<?php endforeach; ?>
+29 -1
View File
@@ -15,6 +15,7 @@
$this->assign('title', $poll->title);
$this->assign('noindex', '1');
$url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $adminToken] + $params;
$hasInternal = array_filter($slides, fn($slide) => $slide->isInteractive() && $slide->isPrivate()) !== [];
?>
<div class="admin-head">
<div>
@@ -42,7 +43,7 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
'title' => __('Keine Folie zeigen – Teilnehmende sehen eine Pause-Seite'),
]) ?>
<?php endif; ?>
<a class="button" href="<?= $this->Url->build($url('admin:export')) ?>"><?= __('CSV-Export') ?></a>
<a class="button" href="#export"><?= __('PDF-Export') ?></a>
</div>
</div>
@@ -177,6 +178,33 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
</div>
</section>
<section class="card" id="export">
<h2><?= __('Ergebnisse als PDF') ?></h2>
<p class="hint"><?= __('Alle Folien mit Abstimmung und ihre Ergebnisse in einem Dokument, z. B. fürs Protokoll.') ?></p>
<?= $this->Form->create(null, ['url' => $url('admin:export'), 'type' => 'get']) ?>
<?php if ($hasInternal) : ?>
<fieldset class="export-choice">
<legend><?= __('Welche Fassung?') ?></legend>
<label>
<input type="radio" name="internal" value="0" checked>
<span>
<strong><?= __('Ohne interne Inhalte') ?></strong>
<span class="hint"><?= __('Zum Weitergeben. Bei anonymem bzw. internem Feedback steht nur, wie viele teilgenommen haben.') ?></span>
</span>
</label>
<label>
<input type="radio" name="internal" value="1">
<span>
<strong><?= __('Vollständig, inkl. interner Inhalte') ?></strong>
<span class="hint"><?= __('Enthält anonyme Antworten und interne Bewertungen samt Kommentaren. Nur für dich, nicht weitergeben.') ?></span>
</span>
</label>
</fieldset>
<?php endif; ?>
<?= $this->Form->button(__('PDF herunterladen'), ['class' => 'button']) ?>
<?= $this->Form->end() ?>
</section>
<section class="card" id="embed">
<h2><?= __('In Präsentation einbetten') ?></h2>
<p class="hint"><?= __('Jede Folie hat einen eigenen Einbett-Link (unter „Einbett-Link“ in der Folienliste). Füge ihn z. B. in Canva als Einbettung auf einer Folie ein.') ?></p>