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>
230 lines
12 KiB
PHP
230 lines
12 KiB
PHP
<?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; ?>
|