Add internal feedback and comments to choice slides
Same options as for scales: "private" shows only the number of votes on the stage, "comments" adds an optional comment field whose comments rotate in the presentation, "comment_ratings" shows the chosen answer(s) next to each comment. With multiple choice the comment is stored on the participant's first row. Settings and participant fields are shared elements for scale and choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e09906830
commit
547b564e32
18 files changed
+485
-108
No files matched your search
@@ -55,7 +55,7 @@ src/
|
||||
HomeController Startseite, Anlegen (/create), Bestätigung, Join, Recover
|
||||
AdminAppController Basis für /admin/{token}: löst Poll über Token-Hash auf (404 sonst), setzt Privacy-Header
|
||||
AdminController Dashboard, Settings, Present, State-JSON, Control, QR, CSV-Export, Token rotieren, Löschen
|
||||
SlidesController Folien-CRUD, Antworten offener Fragen bzw. Skala-Auswertung (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen,
|
||||
SlidesController Folien-CRUD, Antworten offener Fragen bzw. Auswertung von Skala/Umfrage (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen,
|
||||
YouTube-Link prüfen (`youtubeCheck`, JSON)
|
||||
ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen; anonymes Cookie plenario_pid
|
||||
EmbedController /e/{key}/{id}: eine Folie zum Einbetten (z. B. Canva), activate/heartbeat/pause/control
|
||||
@@ -92,7 +92,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
||||
Mehrfachauswahl/mehrere Wörter = mehrere Zeilen mit gleichem `participant_hash`.
|
||||
Q&A: Frage = Zeile mit `text_value`, Upvote = Zeile mit `parent_id` (= id der Frage, FK mit CASCADE).
|
||||
Reihenfolge: eine Zeile pro Person, `text_value` = Options-ids kommagetrennt (`VoteService::parseOrder()`).
|
||||
Skala: `numeric_value`, optional Kommentar in `text_value`.
|
||||
Skala: `numeric_value`, optional Kommentar in `text_value`; Umfrage: Kommentar in `text_value` der ersten Zeile.
|
||||
|
||||
### Zentrale Regeln (nicht versehentlich brechen)
|
||||
|
||||
@@ -169,15 +169,18 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
|
||||
Presenter-/Embed-JSON (`results.answers` leer, nur `participants`) und nie bei Teilnehmenden (keine `results`,
|
||||
unabhängig von `show_results_to_participants`). Lesen nur in der Verwaltung (`slides:answers`,
|
||||
`ResultsService::answers()`) und im CSV-Export.
|
||||
- **Internes Feedback** (Skala mit Setting `private`, ebenfalls `Slide::isPrivate()`): Presenter-/Embed-JSON enthält
|
||||
`buckets: []` und `average: null` (nur `participants`), Teilnehmende bekommen keine `results`. Verteilung und
|
||||
Durchschnitt nur in der Verwaltung (`slides:answers` → „Auswertung“, `ResultsService::scaleResults()`) und im CSV-Export.
|
||||
- **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value`
|
||||
in derselben Zeile wie `numeric_value` (ohne Setting wird es ignoriert). Öffentliche Skalen liefern im Presenter-/Embed-State
|
||||
`results.comments` (Teilnehmende bekommen immer `[]`, `PollStateService::participantResults()`)
|
||||
(älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch („Kommentar X von N“,
|
||||
vor/zurück/Pause, Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback bleibt `comments` leer,
|
||||
lesbar nur in der Auswertung (`ResultsService::comments()`) und im CSV-Export.
|
||||
- **Internes Feedback** (Skala und Umfrage mit Setting `private`, ebenfalls `Slide::isPrivate()`): Presenter-/Embed-JSON
|
||||
enthält kein Ergebnis (Skala `buckets: []`/`average: null`, Umfrage `options: []`, nur `participants`), Teilnehmende
|
||||
bekommen keine `results`. Ergebnis nur in der Verwaltung (`slides:answers` → „Auswertung“,
|
||||
`ResultsService::scaleResults()` / `choiceResults()`) und im CSV-Export.
|
||||
- **Kommentare** (Skala und Umfrage, Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als
|
||||
`text_value` in der (bei Mehrfachauswahl: ersten) Zeile der Antwort, ohne Setting ignoriert (`VoteService::comment()`).
|
||||
Öffentliche Folien liefern im Presenter-/Embed-State `results.comments` (älteste zuerst, je `id`, `text`, `value` –
|
||||
`value` = Bewertung bzw. gewählte Antwort(en), nur mit Setting `comment_ratings`, sonst `null`). Teilnehmende bekommen
|
||||
immer `[]` (`PollStateService::participantResults()`). `Comments` in `plenario.js` blättert sie automatisch durch
|
||||
(„Kommentar X von N“, vor/zurück/Pause, Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback bleibt
|
||||
`comments` leer, lesbar nur in der Auswertung (`ResultsService::comments()`) und im CSV-Export.
|
||||
Formular-/Teilnehmerfelder: Elemente `feedback_settings` und `feedback_fields`.
|
||||
|
||||
### Neuen Folientyp hinzufügen (Checkliste)
|
||||
|
||||
|
||||
@@ -307,6 +307,8 @@ class AdminController extends AdminAppController
|
||||
$answer = match (true) {
|
||||
$slide->isOrder() => $this->orderAnswer($slide, $labels, (string)$response->text_value),
|
||||
$response->parent_id !== null => __('Upvote: {0}', $texts[$response->parent_id] ?? ''),
|
||||
$response->slide_option_id !== null && $response->text_value !== null
|
||||
=> __('{0} (Kommentar: {1})', $labels[$response->slide_option_id] ?? '', $response->text_value),
|
||||
$response->slide_option_id !== null => $labels[$response->slide_option_id] ?? '',
|
||||
$response->text_value !== null && $response->numeric_value === VoteService::DOWNVOTE
|
||||
=> __('Downvote: {0}', $response->text_value),
|
||||
|
||||
@@ -164,7 +164,7 @@ class SlidesController extends AdminAppController
|
||||
}
|
||||
|
||||
/**
|
||||
* All answers of an open question or the ratings of a scale
|
||||
* All answers of an open question, the ratings of a scale or the votes of a choice
|
||||
* (also anonymous/internal feedback, which is never shown on the stage).
|
||||
*
|
||||
* @param string $id Slide id
|
||||
@@ -173,13 +173,15 @@ class SlidesController extends AdminAppController
|
||||
public function answers(string $id): void
|
||||
{
|
||||
$slide = $this->loadSlide($id);
|
||||
if (!in_array($slide->type, [Slide::TYPE_OPEN, Slide::TYPE_SCALE], true)) {
|
||||
if (!in_array($slide->type, [Slide::TYPE_OPEN, Slide::TYPE_SCALE, Slide::TYPE_CHOICE], true)) {
|
||||
throw new NotFoundException(__('Folie nicht gefunden.'));
|
||||
}
|
||||
$results = new ResultsService();
|
||||
$this->set('slide', $slide);
|
||||
$this->set('answers', $slide->type === Slide::TYPE_OPEN ? $results->answers($slide) : []);
|
||||
$this->set('scale', $slide->type === Slide::TYPE_SCALE ? $results->scaleResults($slide) : null);
|
||||
$this->set('choice', $slide->type === Slide::TYPE_CHOICE ? $results->choiceResults($slide) : null);
|
||||
$this->set('participants', $this->Slides->Responses->countParticipants($slide->id));
|
||||
$this->set('comments', $slide->hasComments() ? $results->comments($slide) : []);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,14 +79,15 @@ class Slide extends Entity
|
||||
* @var array<string, array<string, mixed>>
|
||||
*/
|
||||
public const DEFAULT_SETTINGS = [
|
||||
self::TYPE_CHOICE => ['multiple' => false],
|
||||
// private / comments / comment_ratings: see TYPE_SCALE (comment_ratings = show the chosen answer)
|
||||
self::TYPE_CHOICE => ['multiple' => false, 'private' => false, 'comments' => false, 'comment_ratings' => false],
|
||||
// allow_downvotes only takes effect together with allow_upvotes
|
||||
self::TYPE_WORDCLOUD => ['allow_upvotes' => true, 'allow_downvotes' => true],
|
||||
// private: anonymous feedback, answers only visible in the admin area (never on the stage)
|
||||
self::TYPE_OPEN => ['private' => false],
|
||||
// private: internal feedback, ratings only visible in the admin area (never on the stage)
|
||||
// comments: optional comment field, comments rotate in the presentation (unless private)
|
||||
// comment_ratings: show the rating next to each comment in the presentation
|
||||
// comment_ratings: show the rating (choice: the chosen answer) next to each comment in the presentation
|
||||
self::TYPE_SCALE => [
|
||||
'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false,
|
||||
'comments' => false, 'comment_ratings' => false,
|
||||
@@ -383,23 +384,24 @@ class Slide extends Entity
|
||||
}
|
||||
|
||||
/**
|
||||
* Open question or scale collecting anonymous/internal feedback: answers and ratings are
|
||||
* Open question, scale or choice collecting anonymous/internal feedback: answers and results are
|
||||
* never shown on the presenter screen or to participants, only in the admin area and the CSV export.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isPrivate(): bool
|
||||
{
|
||||
return in_array($this->type, [self::TYPE_OPEN, self::TYPE_SCALE], true) && (bool)$this->setting('private');
|
||||
return in_array($this->type, [self::TYPE_OPEN, self::TYPE_SCALE, self::TYPE_CHOICE], true)
|
||||
&& (bool)$this->setting('private');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scale with an optional comment field for participants.
|
||||
* Scale or choice with an optional comment field for participants.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasComments(): bool
|
||||
{
|
||||
return $this->type === self::TYPE_SCALE && (bool)$this->setting('comments');
|
||||
return in_array($this->type, [self::TYPE_SCALE, self::TYPE_CHOICE], true) && (bool)$this->setting('comments');
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,9 @@ class SlidesTable extends Table
|
||||
switch ($type) {
|
||||
case Slide::TYPE_CHOICE:
|
||||
$settings['multiple'] = filter_var($input['multiple'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$settings['private'] = filter_var($input['private'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$settings['comments'] = filter_var($input['comments'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
break;
|
||||
case Slide::TYPE_WORDCLOUD:
|
||||
$settings['allow_upvotes'] = filter_var($input['allow_upvotes'] ?? true, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
@@ -12,7 +12,8 @@ use Cake\ORM\Locator\LocatorAwareTrait;
|
||||
* rendered by webroot/js/plenario.js (presenter + participant views).
|
||||
*
|
||||
* Shape (always present): ['type' => string, 'participants' => int, ...]
|
||||
* - choice: 'options' => [['id', 'label', 'count', 'percent']]
|
||||
* - choice: 'options' => [['id', 'label', 'count', 'percent']], 'votes', 'private' (bool), 'comments' (like scale,
|
||||
* 'value' = chosen answer(s) as text); private: 'options' and 'comments' empty, only via choiceResults()
|
||||
* - wordcloud: 'words' => [['key' (lower case), 'text', 'count', 'down', 'weight' (0..1)]]
|
||||
* (count = participants who named or upvoted the word, down = downvotes,
|
||||
* weight follows count)
|
||||
@@ -136,6 +137,22 @@ class ResultsService
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function choice(Slide $slide): array
|
||||
{
|
||||
if ($slide->isPrivate()) {
|
||||
return ['options' => [], 'votes' => 0, 'private' => true, 'comments' => []];
|
||||
}
|
||||
|
||||
return $this->choiceResults($slide) + ['private' => false, 'comments' => $this->publicComments($slide)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Votes per option – also of private slides, so only for the admin area
|
||||
* (never for the presenter screen or participants).
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Choice slide incl. slide_options
|
||||
* @return array{options: list<array{id: int, label: string, count: int, percent: float|int}>, votes: int}
|
||||
*/
|
||||
public function choiceResults(Slide $slide): array
|
||||
{
|
||||
$counts = $this->Responses->find()
|
||||
->select(['slide_option_id', 'n' => $this->Responses->find()->func()->count('*')])
|
||||
@@ -314,17 +331,7 @@ class ResultsService
|
||||
protected function scale(Slide $slide): array
|
||||
{
|
||||
if (!$slide->isPrivate()) {
|
||||
$showRatings = (bool)$slide->setting('comment_ratings');
|
||||
$comments = [];
|
||||
foreach ($slide->hasComments() ? $this->comments($slide, self::MAX_ANSWERS) : [] as $comment) {
|
||||
$comments[] = [
|
||||
'id' => $comment['id'],
|
||||
'text' => $comment['text'],
|
||||
'value' => $showRatings ? $comment['value'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->scaleResults($slide) + ['private' => false, 'comments' => $comments];
|
||||
return $this->scaleResults($slide) + ['private' => false, 'comments' => $this->publicComments($slide)];
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -340,29 +347,80 @@ class ResultsService
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments of a scale with their rating, oldest first – also of private slides,
|
||||
* so the unfiltered call is only for the admin area.
|
||||
* Comments for the presentation: without date, the rating/answer only with the setting comment_ratings.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Scale slide
|
||||
* @param \App\Model\Entity\Slide $slide Public scale or choice
|
||||
* @return list<array{id: int, text: string, value: int|string|null}>
|
||||
*/
|
||||
protected function publicComments(Slide $slide): array
|
||||
{
|
||||
if (!$slide->hasComments()) {
|
||||
return [];
|
||||
}
|
||||
$showRatings = (bool)$slide->setting('comment_ratings');
|
||||
$comments = [];
|
||||
foreach ($this->comments($slide, self::MAX_ANSWERS) as $comment) {
|
||||
$comments[] = [
|
||||
'id' => $comment['id'],
|
||||
'text' => $comment['text'],
|
||||
'value' => $showRatings ? $comment['value'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
return $comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comments of a scale or choice with the rating (scale) or the chosen answers (choice),
|
||||
* oldest first – also of private slides, so the unfiltered call is only for the admin area.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Scale or choice slide (choice incl. slide_options)
|
||||
* @param int|null $limit Max. comments (the newest ones), null = all
|
||||
* @return list<array{id: int, text: string, value: int, created: string}>
|
||||
* @return list<array{id: int, text: string, value: int|string, created: string}>
|
||||
*/
|
||||
public function comments(Slide $slide, ?int $limit = null): array
|
||||
{
|
||||
$isChoice = $slide->type === Slide::TYPE_CHOICE;
|
||||
$query = $this->Responses->find()
|
||||
->select(['id', 'text_value', 'numeric_value', 'created'])
|
||||
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null, 'numeric_value IS NOT' => null])
|
||||
->select(['id', 'text_value', 'numeric_value', 'participant_hash', 'created'])
|
||||
->where([
|
||||
'slide_id' => $slide->id,
|
||||
'text_value IS NOT' => null,
|
||||
($isChoice ? 'slide_option_id' : 'numeric_value') . ' IS NOT' => null,
|
||||
])
|
||||
->orderBy(['id' => 'DESC']);
|
||||
if ($limit !== null) {
|
||||
$query->limit($limit);
|
||||
}
|
||||
$rows = $query->all()->toList();
|
||||
|
||||
// Choice: all answers of the commenting participants (multiple choice = several rows).
|
||||
$chosen = [];
|
||||
if ($isChoice && $rows !== []) {
|
||||
$labels = [];
|
||||
foreach ($slide->slide_options ?? [] as $option) {
|
||||
$labels[$option->id] = $option->label;
|
||||
}
|
||||
$answers = $this->Responses->find()
|
||||
->select(['participant_hash', 'slide_option_id'])
|
||||
->where([
|
||||
'slide_id' => $slide->id,
|
||||
'slide_option_id IS NOT' => null,
|
||||
'participant_hash IN' => array_map(fn($row) => $row->participant_hash, $rows),
|
||||
])
|
||||
->orderBy(['id' => 'ASC'])
|
||||
->all();
|
||||
foreach ($answers as $answer) {
|
||||
$chosen[$answer->participant_hash][] = $labels[$answer->slide_option_id] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
$comments = [];
|
||||
foreach ($query->all() as $row) {
|
||||
foreach ($rows as $row) {
|
||||
$comments[] = [
|
||||
'id' => (int)$row->id,
|
||||
'text' => (string)$row->text_value,
|
||||
'value' => (int)$row->numeric_value,
|
||||
'value' => $isChoice ? implode(', ', $chosen[$row->participant_hash] ?? []) : (int)$row->numeric_value,
|
||||
'created' => $row->created->toIso8601String(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -142,7 +142,11 @@ class VoteService
|
||||
throw new VoteException(__('Bitte wähle nur eine Antwort aus.'));
|
||||
}
|
||||
|
||||
return array_map(fn(int $id) => ['slide_option_id' => $id], $selected);
|
||||
$rows = array_map(fn(int $id) => ['slide_option_id' => $id, 'text_value' => null], $selected);
|
||||
// The optional comment is stored once, in the first row of the participant.
|
||||
$rows[0]['text_value'] = $this->comment($slide, $data);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -422,12 +426,24 @@ class VoteService
|
||||
if ($value === false || $value < $min || $value > $max) {
|
||||
throw new VoteException(__('Bitte wähle einen Wert zwischen {0} und {1}.', $min, $max));
|
||||
}
|
||||
// The optional comment is stored in the same row; ignored if the slide has no comment field.
|
||||
// The optional comment is stored in the same row.
|
||||
return [['numeric_value' => $value, 'text_value' => $this->comment($slide, $data)]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional comment of a scale or choice; ignored if the slide has no comment field.
|
||||
*
|
||||
* @param \App\Model\Entity\Slide $slide Slide
|
||||
* @param array<string, mixed> $data Request data
|
||||
* @return string|null Null if empty
|
||||
*/
|
||||
protected function comment(Slide $slide, array $data): ?string
|
||||
{
|
||||
$comment = $slide->hasComments() ? trim((string)($data['comment'] ?? '')) : '';
|
||||
if (mb_strlen($comment) > self::MAX_TEXT_LENGTH) {
|
||||
throw new VoteException(__('Der Kommentar darf maximal {0} Zeichen lang sein.', self::MAX_TEXT_LENGTH));
|
||||
}
|
||||
|
||||
return [['numeric_value' => $value, 'text_value' => $comment === '' ? null : $comment]];
|
||||
return $comment === '' ? null : $comment;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
|
||||
<span class="muted">· <?= __('Abstimmung geschlossen, aufgelöst') ?></span>
|
||||
<?php elseif (!$slide->is_voting_open) : ?><span class="muted">· <?= __('Abstimmung geschlossen') ?></span><?php endif; ?>
|
||||
<?php if ($slide->hasComments()) : ?><span class="badge" title="<?= __('Teilnehmende können einen Kommentar abgeben') ?>">💬 <?= __('Kommentare') ?></span><?php endif; ?>
|
||||
<?php if ($slide->isPrivate()) : ?><span class="badge" title="<?= __('Antworten werden nicht öffentlich angezeigt') ?>">🔒 <?= $slide->type === 'scale' ? __('intern') : __('anonym') ?></span><?php endif; ?>
|
||||
<?php if ($slide->isPrivate()) : ?><span class="badge" title="<?= __('Antworten werden nicht öffentlich angezeigt') ?>">🔒 <?= $slide->type === 'open' ? __('anonym') : __('intern') ?></span><?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<a class="slide-item__title" href="<?= $this->Url->build($url('slides:edit', ['id' => $slide->id])) ?>"><?= h($slide->question) ?></a>
|
||||
@@ -136,7 +136,7 @@ $url = fn(string $name, array $params = []) => ['_name' => $name, 'token' => $ad
|
||||
]) ?>
|
||||
<?php endif; ?>
|
||||
<?php if (($slide->type === 'open' || $slide->isPrivate() || $slide->hasComments()) && $count > 0) : ?>
|
||||
<a class="button button--small" href="<?= $this->Url->build($url('slides:answers', ['id' => $slide->id])) ?>"><?= $slide->type === 'scale' ? __('Auswertung') : __('Antworten') ?></a>
|
||||
<a class="button button--small" href="<?= $this->Url->build($url('slides:answers', ['id' => $slide->id])) ?>"><?= $slide->type === 'open' ? __('Antworten') : __('Auswertung') ?></a>
|
||||
<?php endif; ?>
|
||||
<a class="button button--small" href="<?= $this->Url->build($url('slides:edit', ['id' => $slide->id])) ?>"><?= __('Bearbeiten') ?></a>
|
||||
<?php if ($count > 0) : ?>
|
||||
|
||||
@@ -217,7 +217,7 @@ $countdown = function (?int $remaining): string {
|
||||
<?php if ($slide->type === 'choice') :
|
||||
$multiple = (bool)$slide->setting('multiple'); ?>
|
||||
<?php if ($multiple) : ?><p class="hint"><?= __('Mehrfachauswahl möglich') ?></p><?php endif; ?>
|
||||
<div class="choices">
|
||||
<div class="choices"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
|
||||
<?php foreach ($slide->slide_options as $option) : ?>
|
||||
<label class="choice">
|
||||
<input type="<?= $multiple ? 'checkbox' : 'radio' ?>"
|
||||
@@ -227,6 +227,7 @@ $countdown = function (?int $remaining): string {
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?= $this->element('feedback_fields', ['slide' => $slide, 'placeholder' => __('Möchtest du deine Wahl begründen?')]) ?>
|
||||
|
||||
<?php elseif ($slide->type === 'open') : ?>
|
||||
<textarea name="text" rows="4" maxlength="500" required
|
||||
@@ -251,16 +252,7 @@ $countdown = function (?int $remaining): string {
|
||||
<span><?= h((string)$slide->setting('min_label')) ?></span>
|
||||
<span><?= h((string)$slide->setting('max_label')) ?></span>
|
||||
</div>
|
||||
<?php if ($slide->hasComments()) : ?>
|
||||
<label class="scale-comment" for="scale-comment"><?= __('Kommentar (optional)') ?></label>
|
||||
<textarea id="scale-comment" name="comment" rows="3" maxlength="500"
|
||||
placeholder="<?= __('Möchtest du deine Bewertung begründen?') ?>"></textarea>
|
||||
<?php endif; ?>
|
||||
<?php if ($slide->isPrivate()) : ?>
|
||||
<p class="hint private-hint" id="private-hint">
|
||||
🔒 <?= __('Internes Feedback: Das Ergebnis wird nicht öffentlich angezeigt und deine Bewertung nicht mit deinem Namen gespeichert.') ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<?= $this->element('feedback_fields', ['slide' => $slide, 'placeholder' => __('Möchtest du deine Bewertung begründen?')]) ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?= $this->Form->button(__('Absenden'), ['class' => 'button button--primary button--block']) ?>
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
* @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 array<string, mixed>|null $scale Distribution of a scale slide, null otherwise
|
||||
* @var array<string, mixed>|null $choice Votes of a choice slide, null otherwise
|
||||
* @var int $participants Participants who answered
|
||||
* @var list<array{id: int, text: string, value: int, created: string}> $comments Comments of a scale, oldest first
|
||||
*/
|
||||
use Cake\I18n\DateTime;
|
||||
@@ -22,21 +24,46 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
|
||||
<section class="card">
|
||||
<p class="eyebrow">
|
||||
<?= h($slide->typeLabel()) ?>
|
||||
<?php if ($slide->isPrivate()) : ?>· 🔒 <?= $scale !== null ? __('Internes Feedback') : __('Anonymes Feedback') ?><?php endif; ?>
|
||||
<?php if ($slide->isPrivate()) : ?>· 🔒 <?= $slide->type === 'open' ? __('Anonymes Feedback') : __('Internes Feedback') ?><?php endif; ?>
|
||||
</p>
|
||||
<h1><?= h($slide->question) ?></h1>
|
||||
<?php if ($scale !== null) : ?>
|
||||
<p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?></p>
|
||||
<?php elseif ($choice !== null) : ?>
|
||||
<p class="muted"><?= __n('{0} Person hat abgestimmt', '{0} Personen haben abgestimmt', $participants, $participants) ?></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 wird weder in der Präsentation noch den Teilnehmenden angezeigt.')
|
||||
: __('Diese Antworten werden weder in der Präsentation noch den Teilnehmenden angezeigt.') ?></p>
|
||||
<p class="hint"><?= $slide->type === 'open'
|
||||
? __('Diese Antworten werden weder in der Präsentation noch den Teilnehmenden angezeigt.')
|
||||
: __('Dieses Ergebnis wird weder in der Präsentation noch den Teilnehmenden angezeigt.') ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($scale !== null) : ?>
|
||||
<?php if ($choice !== null) : ?>
|
||||
<?php if ($participants === 0) : ?>
|
||||
<p class="empty"><?= __('Noch keine Stimmen.') ?></p>
|
||||
<?php else : ?>
|
||||
<table class="scale-table">
|
||||
<caption class="sr-only"><?= __('Stimmen je Antwort') ?></caption>
|
||||
<thead>
|
||||
<tr><th scope="col"><?= __('Antwort') ?></th><th scope="col"><?= __('Anzahl') ?></th><th scope="col"><?= __('Anteil') ?></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($choice['options'] as $option) : ?>
|
||||
<tr>
|
||||
<th scope="row"><?= h($option['label']) ?></th>
|
||||
<td><?= (int)$option['count'] ?></td>
|
||||
<td>
|
||||
<span class="scale-table__bar" style="width: <?= (float)$option['percent'] ?>%" aria-hidden="true"></span>
|
||||
<?= h($this->Number->format((float)$option['percent'], ['places' => 0, 'precision' => 1, 'locale' => 'de_DE'])) ?> %
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<?php elseif ($scale !== null) : ?>
|
||||
<?php if ($count === 0) : ?>
|
||||
<p class="empty"><?= __('Noch keine Bewertungen.') ?></p>
|
||||
<?php else : ?>
|
||||
@@ -69,22 +96,6 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
|
||||
</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 {0}', $comment['value']) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php elseif ($answers === []) : ?>
|
||||
<p class="empty"><?= __('Noch keine Antworten.') ?></p>
|
||||
<?php else : ?>
|
||||
@@ -98,4 +109,21 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?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']) ?>"><?= $choice !== null ? __('Antwort: {0}', h($comment['value'])) : __('Bewertung {0}', $comment['value']) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
@@ -129,6 +129,10 @@ $optionsError = $slide->getError('options_text');
|
||||
'label' => __('Mehrfachauswahl erlauben'),
|
||||
'checked' => (bool)$settings['multiple'],
|
||||
]) ?>
|
||||
<?= $this->element('feedback_settings', [
|
||||
'settings' => $settings,
|
||||
'ratingLabel' => __('Gewählte Antwort beim Kommentar in der Präsentation anzeigen'),
|
||||
]) ?>
|
||||
<?php elseif ($slide->type === 'open') : ?>
|
||||
<?= $this->Form->control('settings.private', [
|
||||
'type' => 'checkbox',
|
||||
@@ -166,23 +170,10 @@ $optionsError = $slide->getError('options_text');
|
||||
'placeholder' => __('z. B. sehr'), 'value' => $settings['max_label'],
|
||||
]) ?>
|
||||
</div>
|
||||
<?= $this->Form->control('settings.comments', [
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'),
|
||||
'checked' => (bool)$settings['comments'],
|
||||
<?= $this->element('feedback_settings', [
|
||||
'settings' => $settings,
|
||||
'ratingLabel' => __('Bewertung beim Kommentar in der Präsentation anzeigen'),
|
||||
]) ?>
|
||||
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden). Bei internem Feedback siehst du sie nur in der Auswertung.') ?></p>
|
||||
<?= $this->Form->control('settings.comment_ratings', [
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Bewertung beim Kommentar in der Präsentation anzeigen'),
|
||||
'checked' => (bool)$settings['comment_ratings'],
|
||||
]) ?>
|
||||
<?= $this->Form->control('settings.private', [
|
||||
'type' => 'checkbox',
|
||||
'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>
|
||||
<?php elseif ($slide->type === 'quiz') :
|
||||
$quizError = $slide->getError('quiz_options');
|
||||
$rows = $quizOptions;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Optional comment field and internal-feedback hint below a scale or choice on the participant page.
|
||||
*
|
||||
* @var \App\View\AppView $this
|
||||
* @var \App\Model\Entity\Slide $slide Scale or choice slide
|
||||
* @var string $placeholder Placeholder of the comment field
|
||||
*/
|
||||
?>
|
||||
<?php if ($slide->hasComments()) : ?>
|
||||
<label class="comment-label" for="feedback-comment"><?= __('Kommentar (optional)') ?></label>
|
||||
<textarea id="feedback-comment" name="comment" rows="3" maxlength="500"
|
||||
placeholder="<?= h($placeholder) ?>"></textarea>
|
||||
<?php endif; ?>
|
||||
<?php if ($slide->isPrivate()) : ?>
|
||||
<p class="hint private-hint" id="private-hint">
|
||||
🔒 <?= __('Internes Feedback: Das Ergebnis wird nicht öffentlich angezeigt und deine Antwort nicht mit deinem Namen gespeichert.') ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Settings "comment field" and "internal feedback" of a scale or choice slide.
|
||||
*
|
||||
* @var \App\View\AppView $this
|
||||
* @var array<string, mixed> $settings Current settings
|
||||
* @var string $ratingLabel Label of the setting comment_ratings
|
||||
*/
|
||||
?>
|
||||
<?= $this->Form->control('settings.comments', [
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Antwort optional begründen)'),
|
||||
'checked' => (bool)$settings['comments'],
|
||||
]) ?>
|
||||
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden). Bei internem Feedback siehst du sie nur in der Auswertung.') ?></p>
|
||||
<?= $this->Form->control('settings.comment_ratings', [
|
||||
'type' => 'checkbox',
|
||||
'label' => $ratingLabel,
|
||||
'checked' => (bool)$settings['comment_ratings'],
|
||||
]) ?>
|
||||
<?= $this->Form->control('settings.private', [
|
||||
'type' => 'checkbox',
|
||||
'label' => __('Internes Feedback: Ergebnis nicht öffentlich anzeigen'),
|
||||
'checked' => (bool)$settings['private'],
|
||||
]) ?>
|
||||
<p class="hint"><?= __('Präsentation und Teilnehmende sehen nur, wie viele abgestimmt haben. Das Ergebnis und die Kommentare siehst nur du hier in der Verwaltung (und im CSV-Export).') ?></p>
|
||||
@@ -84,7 +84,10 @@ class AdminControllerTest extends TestCase
|
||||
$slide = $this->slidesTable()->find()->contain(['SlideOptions'])->firstOrFail();
|
||||
$this->assertSame($poll->id, $slide->poll_id);
|
||||
$this->assertSame(['Pizza', 'Pasta'], array_map(fn($o) => $o->label, $slide->slide_options));
|
||||
$this->assertSame(['multiple' => true], $slide->settings);
|
||||
$this->assertSame(
|
||||
['multiple' => true, 'private' => false, 'comments' => false, 'comment_ratings' => false],
|
||||
$slide->settings,
|
||||
);
|
||||
$this->assertSame(1, $slide->position);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Test\TestCase\Controller;
|
||||
|
||||
use App\Model\Entity\Poll;
|
||||
use App\Model\Entity\Slide;
|
||||
use App\Model\Table\SlidesTable;
|
||||
use App\Service\VoteService;
|
||||
use App\Test\TestCase\PlenarioTestTrait;
|
||||
use Cake\TestSuite\IntegrationTestTrait;
|
||||
use Cake\TestSuite\TestCase;
|
||||
|
||||
/**
|
||||
* Choice slides as internal feedback and with an optional comment field.
|
||||
*/
|
||||
class ChoiceFeedbackTest extends TestCase
|
||||
{
|
||||
use IntegrationTestTrait;
|
||||
use PlenarioTestTrait;
|
||||
|
||||
/**
|
||||
* @var list<string>
|
||||
*/
|
||||
protected array $fixtures = ['app.Polls', 'app.Slides', 'app.SlideOptions', 'app.Responses'];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->enableCsrfToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Choice "Ja/Nein/Vielleicht" (multiple) with two votes and one comment.
|
||||
*
|
||||
* @param array<string, mixed> $settings Settings
|
||||
* @return array{0: \App\Model\Entity\Poll, 1: string, 2: \App\Model\Entity\Slide}
|
||||
*/
|
||||
protected function choiceWithVotes(array $settings): array
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_CHOICE, ['settings' => $settings + ['multiple' => true]], ['Ja', 'Nein', 'Vielleicht']);
|
||||
$poll = $this->goLive($poll, $slide);
|
||||
[$yes, $no, $maybe] = array_map(fn($option) => $option->id, $slide->slide_options);
|
||||
$votes = new VoteService();
|
||||
$votes->submit($poll, $slide, $this->hash('a', $poll), ['option_ids' => [$yes, $maybe], 'comment' => 'Weil <darum>']);
|
||||
$votes->submit($poll, $slide, $this->hash('b', $poll), ['option_ids' => [$no]]);
|
||||
|
||||
return [$poll, $token, $slide];
|
||||
}
|
||||
|
||||
protected function hash(string $char, Poll $poll): string
|
||||
{
|
||||
return VoteService::participantHash(str_repeat($char, 32), $poll->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function presenterResults(string $token): array
|
||||
{
|
||||
$this->get("/admin/$token/state");
|
||||
|
||||
return json_decode((string)$this->_response->getBody(), true)['results'];
|
||||
}
|
||||
|
||||
public function testSettingsAreSanitized(): void
|
||||
{
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_CHOICE, ['private' => '1', 'comments' => '1', 'comment_ratings' => '1']);
|
||||
$this->assertTrue($settings['private']);
|
||||
$this->assertTrue($settings['comments']);
|
||||
$this->assertTrue($settings['comment_ratings']);
|
||||
|
||||
$settings = SlidesTable::sanitizeSettings(Slide::TYPE_CHOICE, []);
|
||||
$this->assertFalse($settings['private']);
|
||||
$this->assertFalse($settings['comments']);
|
||||
$this->assertFalse($settings['comment_ratings']);
|
||||
|
||||
[$poll] = $this->createPoll();
|
||||
$slide = $this->createSlide($poll, Slide::TYPE_CHOICE, ['settings' => ['multiple' => false]]);
|
||||
$this->assertFalse($slide->isPrivate());
|
||||
$this->assertFalse($slide->hasComments());
|
||||
}
|
||||
|
||||
public function testFormOffersFeedbackSettings(): void
|
||||
{
|
||||
[, $token] = $this->createPoll();
|
||||
|
||||
$this->get("/admin/$token/slides/add?type=choice");
|
||||
$this->assertResponseOk();
|
||||
$this->assertResponseContains('name="settings[comments]"');
|
||||
$this->assertResponseContains('Gewählte Antwort beim Kommentar');
|
||||
$this->assertResponseContains('name="settings[private]"');
|
||||
|
||||
$this->get("/admin/$token/slides/add?type=scale");
|
||||
$this->assertResponseOk();
|
||||
$this->assertResponseContains('Bewertung beim Kommentar');
|
||||
}
|
||||
|
||||
public function testCommentIsStoredOnceForMultipleChoice(): void
|
||||
{
|
||||
[, , $slide] = $this->choiceWithVotes(['comments' => true]);
|
||||
|
||||
$texts = $this->slidesTable()->Responses->find()
|
||||
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null])
|
||||
->all()
|
||||
->extract('text_value')
|
||||
->toList();
|
||||
$this->assertSame(['Weil <darum>'], $texts);
|
||||
}
|
||||
|
||||
public function testCommentIsIgnoredWithoutCommentField(): void
|
||||
{
|
||||
[, , $slide] = $this->choiceWithVotes([]);
|
||||
|
||||
$this->assertFalse($this->slidesTable()->Responses->exists(['slide_id' => $slide->id, 'text_value IS NOT' => null]));
|
||||
}
|
||||
|
||||
public function testParticipantPageShowsCommentFieldAndHint(): void
|
||||
{
|
||||
[$poll, , $slide] = $this->choiceWithVotes(['comments' => true, 'private' => true]);
|
||||
$this->slidesTable()->Responses->deleteAll(['slide_id' => $slide->id]);
|
||||
|
||||
$this->get('/p/' . $poll->join_code);
|
||||
$this->assertResponseContains('name="comment"');
|
||||
$this->assertResponseContains('Internes Feedback');
|
||||
}
|
||||
|
||||
public function testPresenterGetsCommentsWithoutAnswerByDefault(): void
|
||||
{
|
||||
[, $token] = $this->choiceWithVotes(['comments' => true]);
|
||||
|
||||
$results = $this->presenterResults($token);
|
||||
|
||||
$this->assertFalse($results['private']);
|
||||
$this->assertSame([1, 1, 1], array_column($results['options'], 'count'));
|
||||
$this->assertSame(['Weil <darum>'], array_column($results['comments'], 'text'));
|
||||
$this->assertSame([null], array_column($results['comments'], 'value'));
|
||||
}
|
||||
|
||||
public function testChosenAnswersNextToCommentAreOptional(): void
|
||||
{
|
||||
[, $token] = $this->choiceWithVotes(['comments' => true, 'comment_ratings' => true]);
|
||||
|
||||
$this->assertSame(['Ja, Vielleicht'], array_column($this->presenterResults($token)['comments'], 'value'));
|
||||
}
|
||||
|
||||
public function testParticipantsNeverSeeComments(): void
|
||||
{
|
||||
[$poll] = $this->choiceWithVotes(['comments' => true]);
|
||||
$this->cookie('plenario_pid', str_repeat('a', 32));
|
||||
|
||||
$this->get('/p/' . $poll->join_code . '/state');
|
||||
$state = json_decode((string)$this->_response->getBody(), true);
|
||||
|
||||
$this->assertNotEmpty($state['results']['options']);
|
||||
$this->assertSame([], $state['results']['comments']);
|
||||
$this->assertResponseNotContains('darum');
|
||||
}
|
||||
|
||||
public function testPrivateChoiceShowsOnlyTheCount(): void
|
||||
{
|
||||
[$poll, $token, $slide] = $this->choiceWithVotes(['private' => true, 'comments' => true]);
|
||||
|
||||
$results = $this->presenterResults($token);
|
||||
$this->assertTrue($results['private']);
|
||||
$this->assertSame([], $results['options']);
|
||||
$this->assertSame([], $results['comments']);
|
||||
$this->assertSame(2, $results['participants']);
|
||||
$this->assertResponseNotContains('darum');
|
||||
|
||||
$key = $this->pollsTable()->ensureEmbedKey($poll);
|
||||
$this->get("/e/$key/{$slide->id}/state");
|
||||
$this->assertResponseNotContains('darum');
|
||||
|
||||
$this->cookie('plenario_pid', str_repeat('a', 32));
|
||||
$this->get('/p/' . $poll->join_code . '/state');
|
||||
$this->assertNull(json_decode((string)$this->_response->getBody(), true)['results']);
|
||||
}
|
||||
|
||||
public function testAdminEvaluationShowsVotesAndComments(): void
|
||||
{
|
||||
[, $token, $slide] = $this->choiceWithVotes(['private' => true, 'comments' => true]);
|
||||
|
||||
$this->get("/admin/$token");
|
||||
$this->assertResponseContains("/slides/{$slide->id}/answers");
|
||||
$this->assertResponseContains('intern');
|
||||
|
||||
$this->get("/admin/$token/slides/{$slide->id}/answers");
|
||||
$this->assertResponseOk();
|
||||
$this->assertResponseContains('2 Personen haben abgestimmt');
|
||||
$this->assertResponseContains('Internes Feedback');
|
||||
$this->assertResponseContains('1 Kommentar');
|
||||
$this->assertResponseContains('Weil <darum>');
|
||||
$this->assertResponseContains('Antwort: Ja, Vielleicht');
|
||||
}
|
||||
|
||||
public function testExportContainsComment(): void
|
||||
{
|
||||
[, $token] = $this->choiceWithVotes(['comments' => true]);
|
||||
|
||||
$this->get("/admin/$token/export.csv");
|
||||
|
||||
$this->assertResponseContains('Ja (Kommentar: Weil <darum>)');
|
||||
$this->assertResponseContains(';Vielleicht;');
|
||||
}
|
||||
}
|
||||
@@ -131,14 +131,14 @@ class PrivateFeedbackTest extends TestCase
|
||||
$this->assertHeader('Referrer-Policy', 'no-referrer');
|
||||
}
|
||||
|
||||
public function testAnswersPageOnlyForOwnOpenSlides(): void
|
||||
public function testAnswersPageOnlyForOwnSlidesWithEvaluation(): void
|
||||
{
|
||||
[$poll, $token] = $this->createPoll();
|
||||
$choice = $this->createSlide($poll);
|
||||
$quiz = $this->createSlide($poll, Slide::TYPE_QUIZ);
|
||||
[$other] = $this->createPoll('Andere');
|
||||
$foreign = $this->createSlide($other, Slide::TYPE_OPEN);
|
||||
|
||||
$this->get("/admin/$token/slides/{$choice->id}/answers");
|
||||
$this->get("/admin/$token/slides/{$quiz->id}/answers");
|
||||
$this->assertResponseCode(404);
|
||||
$this->get("/admin/$token/slides/{$foreign->id}/answers");
|
||||
$this->assertResponseCode(404);
|
||||
|
||||
@@ -513,7 +513,7 @@ button.qa-steps__step:hover:not(:disabled) { color: var(--text); border-color: v
|
||||
.answers-page { list-style: none; padding: 0; margin: 0; }
|
||||
.answers-page li { padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--surface); white-space: pre-line; overflow-wrap: anywhere; }
|
||||
.answers-page time { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
|
||||
.scale-comment { display: block; margin-top: 16px; font-weight: 600; }
|
||||
.comment-label { display: block; margin-top: 16px; font-weight: 600; }
|
||||
.comments { margin-top: 20px; padding: 16px 20px; background: var(--surface-2); border-radius: 14px; }
|
||||
.comments__counter { margin: 0 0 6px; font-size: .85em; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.comments__text { margin: 0; font-size: 1.25em; font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; }
|
||||
|
||||
+35
-10
@@ -303,8 +303,14 @@
|
||||
timer: null,
|
||||
items: [],
|
||||
node: null,
|
||||
valuePrefix: '',
|
||||
|
||||
render: function (items) {
|
||||
/**
|
||||
* @param {Array} items [{id, text, value|null}]
|
||||
* @param {string} valuePrefix e.g. 'Bewertung: ' or 'Antwort: '
|
||||
*/
|
||||
render: function (items, valuePrefix) {
|
||||
Comments.valuePrefix = valuePrefix;
|
||||
// A different first comment means a different slide (or a reset): start over.
|
||||
var key = String(items[0].id);
|
||||
if (key !== Comments.key) {
|
||||
@@ -387,7 +393,7 @@
|
||||
'Kommentar ' + (Comments.index + 1) + ' von ' + Comments.items.length;
|
||||
text.textContent = item.text;
|
||||
var value = node.querySelector('[data-comment-value]');
|
||||
value.textContent = item.value === null || item.value === undefined ? '' : 'Bewertung: ' + item.value;
|
||||
value.textContent = item.value === null || item.value === undefined ? '' : Comments.valuePrefix + item.value;
|
||||
value.hidden = value.textContent === '';
|
||||
// Only announce changes the viewer triggered, not every automatic rotation.
|
||||
node.setAttribute('aria-live', Comments.paused ? 'polite' : 'off');
|
||||
@@ -409,6 +415,24 @@
|
||||
|
||||
// ------------------------------------------------------------------ results
|
||||
|
||||
/**
|
||||
* Anonymous/internal feedback: only the number of answers reaches the stage.
|
||||
*/
|
||||
function privateSummary(n, singular, plural) {
|
||||
return el('div', { class: 'private-summary' }, [
|
||||
el('p', { class: 'private-summary__count', text: String(n) }),
|
||||
el('p', { text: (n === 1 ? singular : plural) + ' eingegangen' }),
|
||||
el('p', { class: 'private-summary__hint', text: '🔒 Ergebnis wird nicht öffentlich angezeigt.' })
|
||||
]);
|
||||
}
|
||||
|
||||
function withComments(node, results, valuePrefix) {
|
||||
if (!results.comments || !results.comments.length) {
|
||||
return node;
|
||||
}
|
||||
return el('div', {}, [node, Comments.render(results.comments, valuePrefix)]);
|
||||
}
|
||||
|
||||
var Results = {
|
||||
/**
|
||||
* @param {Object} [options] renderer specific; wordcloud: {mine: [keys], onUpvote: fn(word)|null}
|
||||
@@ -441,6 +465,13 @@
|
||||
},
|
||||
|
||||
choice: function (results) {
|
||||
if (results.private) {
|
||||
return privateSummary(results.participants, 'Stimme', 'Stimmen');
|
||||
}
|
||||
return withComments(Results.choiceBars(results), results, 'Antwort: ');
|
||||
},
|
||||
|
||||
choiceBars: function (results) {
|
||||
var max = Math.max.apply(null, results.options.map(function (o) { return o.count; }).concat([1]));
|
||||
return el('div', { class: 'bars' }, results.options.map(function (option, index) {
|
||||
return el('div', { class: 'bar bar--c' + (index % 6) }, [
|
||||
@@ -455,13 +486,7 @@
|
||||
|
||||
scale: function (results) {
|
||||
if (results.private) {
|
||||
// Internal feedback: the ratings never reach the stage, only the count.
|
||||
var n = results.participants;
|
||||
return el('div', { class: 'private-summary' }, [
|
||||
el('p', { class: 'private-summary__count', text: String(n) }),
|
||||
el('p', { text: (n === 1 ? 'Bewertung' : 'Bewertungen') + ' eingegangen' }),
|
||||
el('p', { class: 'private-summary__hint', text: '🔒 Ergebnis wird nicht öffentlich angezeigt.' })
|
||||
]);
|
||||
return privateSummary(results.participants, 'Bewertung', 'Bewertungen');
|
||||
}
|
||||
var max = Math.max.apply(null, results.buckets.map(function (b) { return b.count; }).concat([1]));
|
||||
var total = results.buckets.reduce(function (sum, b) { return sum + b.count; }, 0);
|
||||
@@ -509,7 +534,7 @@
|
||||
]),
|
||||
gauge
|
||||
]);
|
||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments) : null;
|
||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments, 'Bewertung: ') : null;
|
||||
return el('div', { class: 'scale-results' }, [average, columns, labels, comments]);
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user