Replace CSV export with PDF export
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:
1 parent
5cd1be1cf8
commit
d1facd32a6
21 files changed
+1102
-110
No files matched your search
@@ -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; ?>
|
||||
@@ -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>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* All answers of an open question or the ratings of a scale – the only place where
|
||||
* anonymous/internal feedback (private slides) can be read, besides the CSV export.
|
||||
* anonymous/internal feedback (private slides) can be read, besides the complete version of the PDF export.
|
||||
*
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\Poll $poll
|
||||
|
||||
@@ -135,7 +135,7 @@ $optionsError = $slide->getError('options_text');
|
||||
'label' => __('Anonymes Feedback: Antworten nicht öffentlich anzeigen'),
|
||||
'checked' => (bool)$settings['private'],
|
||||
]) ?>
|
||||
<p class="hint"><?= __('Präsentation und Teilnehmende sehen nur, wie viele Antworten eingegangen sind. Die Texte siehst nur du hier in der Verwaltung (und im CSV-Export).') ?></p>
|
||||
<p class="hint"><?= __('Präsentation und Teilnehmende sehen nur, wie viele Antworten eingegangen sind. Die Texte siehst nur du hier in der Verwaltung (und in der vollständigen Fassung des PDF-Exports).') ?></p>
|
||||
<?php elseif ($slide->type === 'wordcloud') : ?>
|
||||
<?= $this->Form->control('settings.allow_upvotes', [
|
||||
'type' => 'checkbox',
|
||||
@@ -182,7 +182,7 @@ $optionsError = $slide->getError('options_text');
|
||||
'label' => __('Internes Feedback: Ergebnis nicht öffentlich anzeigen'),
|
||||
'checked' => (bool)$settings['private'],
|
||||
]) ?>
|
||||
<p class="hint"><?= __('Präsentation und Teilnehmende sehen nur, wie viele Bewertungen eingegangen sind. Verteilung, Durchschnitt und Kommentare siehst nur du hier in der Verwaltung (und im CSV-Export).') ?></p>
|
||||
<p class="hint"><?= __('Präsentation und Teilnehmende sehen nur, wie viele Bewertungen eingegangen sind. Verteilung, Durchschnitt und Kommentare siehst nur du hier in der Verwaltung (und in der vollständigen Fassung des PDF-Exports).') ?></p>
|
||||
<?php elseif ($slide->type === 'quiz') :
|
||||
$quizError = $slide->getError('quiz_options');
|
||||
$rows = $quizOptions;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Layout for PDF documents (rendered by App\View\PdfView with Dompdf).
|
||||
* Self-contained: no external resources, colors as literals (Dompdf has no CSS variables),
|
||||
* font DejaVu Sans (ships with Dompdf, covers umlauts and arrows).
|
||||
*
|
||||
* @var \App\View\AppView $this
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title><?= h($this->fetch('title')) ?></title>
|
||||
<style>
|
||||
@page { margin: 22mm 16mm 20mm; }
|
||||
body { font-family: "DejaVu Sans", sans-serif; font-size: 10pt; line-height: 1.4; color: #1d1f33; }
|
||||
h1 { font-size: 20pt; margin: 0 0 2mm; color: #1d1f33; }
|
||||
h2 { font-size: 13pt; margin: 0 0 1mm; }
|
||||
h3 { font-size: 10.5pt; margin: 4mm 0 1.5mm; }
|
||||
h2, h3, .eyebrow { page-break-after: avoid; }
|
||||
p { margin: 0 0 2mm; }
|
||||
.page-header { position: fixed; top: -14mm; left: 0; right: 0; font-size: 8pt; color: #5d6280; }
|
||||
.page-header .brand { color: #4b3fe0; font-weight: bold; }
|
||||
/* Page numbers bottom right are drawn by PdfView::addPageNumbers(). */
|
||||
.page-footer { position: fixed; bottom: -12mm; left: 0; right: 0; font-size: 8pt; color: #5d6280; }
|
||||
.confidential { color: #c42b4b; font-weight: bold; }
|
||||
.muted { color: #5d6280; }
|
||||
.meta { margin-bottom: 6mm; color: #5d6280; }
|
||||
.banner { border: 1px solid #c42b4b; background: #fdecef; color: #8a1730; padding: 3mm 4mm; margin-bottom: 6mm; }
|
||||
.banner--info { border-color: #dde0ee; background: #eef0f8; color: #1d1f33; }
|
||||
.slide { border-top: 1px solid #dde0ee; padding-top: 4mm; margin-top: 5mm; page-break-inside: avoid; }
|
||||
.slide--long { page-break-inside: auto; }
|
||||
.eyebrow { font-size: 8pt; text-transform: uppercase; letter-spacing: .5pt; color: #4b3fe0; margin-bottom: 1mm; }
|
||||
.tag { color: #a86400; }
|
||||
.tag--internal { color: #c42b4b; }
|
||||
table { width: 100%; border-collapse: collapse; margin: 2mm 0; }
|
||||
th, td { text-align: left; vertical-align: top; padding: 1.2mm 2mm; border-bottom: 1px solid #eef0f8; }
|
||||
th { font-size: 8.5pt; color: #5d6280; font-weight: normal; }
|
||||
td.num, th.num { text-align: right; white-space: nowrap; width: 18mm; }
|
||||
td.bar { width: 55mm; }
|
||||
.bar__track { background: #eef0f8; height: 3.2mm; }
|
||||
.bar__fill { background: #4b3fe0; height: 3.2mm; }
|
||||
.bar__fill--ok { background: #18865a; }
|
||||
.correct { color: #18865a; font-weight: bold; }
|
||||
ol.list, ul.list { margin: 1mm 0 0; padding-left: 6mm; }
|
||||
ol.list li, ul.list li { margin-bottom: 1.2mm; }
|
||||
.stat { font-size: 12pt; font-weight: bold; }
|
||||
.empty { color: #5d6280; font-style: italic; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<?= $this->fetch('content') ?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user