Allow a comment without a rating on scales instead of "Keine Angabe"
CI / Deploy / PHP 8.5 (push) Successful in 1m13s
CI / Deploy / PHP 8.4 (push) Successful in 1m18s
CI / Deploy / test (push) Successful in 1s
CI / Deploy / deploy (push) Skipped

With the comment field enabled, scales and star ratings accept a
comment alone. It counts as taking part but not in the average or the
distribution; the number is shown separately. The explicit skip button
and its setting are removed again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-21 12:58:01 +01:00
1 parent d6432911ed
commit dbac9e93c7
14 files changed
+85 -105

No files matched your search

+7 -5
View File
@@ -146,11 +146,13 @@ geändert wird es nur über die Presenter-Steuerung (`SlideControlService`) bzw.
(`Results.scaleLayout()` / `Results.donut()`). Setting `scale_view` (`Slide::SCALE_VIEWS`: `both` | `average` | `chart`, (`Results.scaleLayout()` / `Results.donut()`). Setting `scale_view` (`Slide::SCALE_VIEWS`: `both` | `average` | `chart`,
Dropdown im Formular) zeigt nur einen Teil, dann zentriert; im JSON `results.view`, die Daten bleiben vollständig. Dropdown im Formular) zeigt nur einen Teil, dann zentriert; im JSON `results.view`, die Daten bleiben vollständig.
Gilt nur für Presenter/Embed, Auswertung und PDF zeigen immer beides. Gilt nur für Presenter/Embed, Auswertung und PDF zeigen immer beides.
- **Keine Angabe** (Setting `allow_skip`, Standard aus): zweiter Button neben „Absenden“ (`skip=1`, `formnovalidate`). `VoteService::scaleRows()` - **Nur Kommentar ohne Bewertung** (Skala/Sterne mit Setting `comments`): die Bewertung ist dann nicht mehr Pflicht (die Radios sind nicht `required`),
speichert eine Zeile **ohne** `numeric_value` und ohne Kommentar: zählt als Teilnahme (einmal pro Person, `countParticipants`), geht aber nicht in ein nicht leerer Kommentar genügt. `VoteService::scaleRows()` speichert eine Zeile **ohne** `numeric_value`: zählt als Teilnahme (einmal pro Person),
Verteilung und Durchschnitt ein. `ResultsService::scaleResults()` liefert die Zahl separat als `skipped` (Bühne: „· N× keine Angabe“ unter der geht aber nicht in Verteilung und Durchschnitt ein. Weder Bewertung noch Kommentar = Fehler, es gibt keinen leeren „Überspringen“-Knopf.
Bewertungszahl, Auswertung, PDF); private Folien strippen sie wie den Rest (`withoutContents()`). Ein Kommentar nachträglich geht nicht `ResultsService::scaleResults()` liefert die Zahl als `commentOnly` (Bühne: „· N× nur Kommentar“, Auswertung, PDF; private Folien strippen sie
(`editText()` lehnt ab, `VoteService::hasSkipped()` blendet das Formular aus). Tests: `VoteServiceTest`, `ParticipateControllerTest`. mit `withoutContents()`). Der Kommentar läuft wie die anderen durch, `value` ist `null` (mit `comment_ratings` zeigt die Bühne „Ohne Bewertung“, damit
die Box gleich hoch bleibt). Nachträglich bearbeiten geht, aber der Kommentar darf dann nicht leer werden (`editText()`). Bei Auswahlfolien gibt es das
bewusst nicht (der Kommentar hängt an der ersten Optionszeile). Tests: `VoteServiceTest`, `ParticipateControllerTest`.
- **Enthaltung bei Auswahlfolien:** kein eigenes Feature, sondern eine normale Option (zählt in Prozenten mit, wie bei Vereinsabstimmungen üblich). - **Enthaltung bei Auswahlfolien:** kein eigenes Feature, sondern eine normale Option (zählt in Prozenten mit, wie bei Vereinsabstimmungen üblich).
Im Folienformular fügt der Button „Option ‚Enthaltung‘ hinzufügen“ (`data-add-option`, `initAddOption()` in `plenario.js`, idempotent, nur mit JS sichtbar) die Zeile ein. Im Folienformular fügt der Button „Option ‚Enthaltung‘ hinzufügen“ (`data-add-option`, `initAddOption()` in `plenario.js`, idempotent, nur mit JS sichtbar) die Zeile ein.
- **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage - **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage
+2 -5
View File
@@ -93,14 +93,11 @@ class ParticipateController extends AppController
$slide = $poll->is_active ? $stateService->currentSlide($poll) : null; $slide = $poll->is_active ? $stateService->currentSlide($poll) : null;
$participantHash = $this->participantHash($poll); $participantHash = $this->participantHash($poll);
$state = $stateService->forParticipant($poll, $participantHash, $slide); $state = $stateService->forParticipant($poll, $participantHash, $slide);
$voteService = new VoteService();
$ownText = $slide !== null && VoteService::hasEditableText($slide) && $state['hasResponded'] $ownText = $slide !== null && VoteService::hasEditableText($slide) && $state['hasResponded']
? $voteService->ownText($slide, $participantHash) ? (new VoteService())->ownText($slide, $participantHash)
: null; : null;
// "Keine Angabe" has no rating to comment on
$skipped = $slide !== null && $state['hasResponded'] && $voteService->hasSkipped($slide, $participantHash);
$this->set(compact('poll', 'slide', 'state', 'participantHash', 'ownText', 'skipped')); $this->set(compact('poll', 'slide', 'state', 'participantHash', 'ownText'));
$this->setPollInterval(); $this->setPollInterval();
} }
+2 -2
View File
@@ -123,7 +123,7 @@ class Slide extends Entity
// private: internal feedback, ratings only visible in the admin area (never on the stage) // 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) // 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 next to each comment in the presentation
// allow_skip: participants may answer "Keine Angabe" (row without numeric_value, not part of the average) // with comments, participants may also send only a comment (row without numeric_value, not part of the average)
// (time per comment depends on its length, see Comments.delay() in plenario.js) // (time per comment depends on its length, see Comments.delay() in plenario.js)
// style: numbers or stars (SCALE_*), stars always start at scale_min = 1 // style: numbers or stars (SCALE_*), stars always start at scale_min = 1
// scale_view: parts of the result shown in the presentation (presenter/embed, SCALE_VIEWS); // scale_view: parts of the result shown in the presentation (presenter/embed, SCALE_VIEWS);
@@ -131,7 +131,7 @@ class Slide extends Entity
self::TYPE_SCALE => [ self::TYPE_SCALE => [
'style' => self::SCALE_NUMBERS, 'style' => self::SCALE_NUMBERS,
'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false, 'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false,
'comments' => false, 'comment_ratings' => false, 'allow_skip' => false, 'comments' => false, 'comment_ratings' => false,
'scale_view' => self::SCALE_VIEW_BOTH, 'scale_view' => self::SCALE_VIEW_BOTH,
'time_limit' => 0, 'time_limit' => 0,
], ],
-1
View File
@@ -177,7 +177,6 @@ class SlidesTable extends Table
$settings['private'] = filter_var($input['private'] ?? 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['comments'] = filter_var($input['comments'] ?? false, FILTER_VALIDATE_BOOLEAN);
$settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN); $settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN);
$settings['allow_skip'] = filter_var($input['allow_skip'] ?? false, FILTER_VALIDATE_BOOLEAN);
$view = $input['scale_view'] ?? null; $view = $input['scale_view'] ?? null;
$settings['scale_view'] = in_array($view, Slide::SCALE_VIEWS, true) ? $view : Slide::SCALE_VIEW_BOTH; $settings['scale_view'] = in_array($view, Slide::SCALE_VIEWS, true) ? $view : Slide::SCALE_VIEW_BOTH;
break; break;
+12 -12
View File
@@ -21,7 +21,7 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* - open: 'answers' => [['text', 'created']] newest first, 'private' (bool); * - open: 'answers' => [['text', 'created']] newest first, 'private' (bool);
* - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null, * - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null,
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool), 'stars' (bool: star rating, min = 1); * 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool), 'stars' (bool: star rating, min = 1);
* 'skipped' (int: answers "Keine Angabe", setting allow_skip; not part of buckets/average); * 'commentOnly' (int: participants who sent only a comment without a rating, not part of buckets/average);
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else []; * 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
* 'value' is null unless the setting comment_ratings is on; * 'value' is null unless the setting comment_ratings is on;
* 'view' (both|average|chart): parts shown in the presentation (setting scale_view, * 'view' (both|average|chart): parts shown in the presentation (setting scale_view,
@@ -487,7 +487,7 @@ class ResultsService
if (isset($results['buckets'])) { if (isset($results['buckets'])) {
$results['buckets'] = []; $results['buckets'] = [];
$results['average'] = null; $results['average'] = null;
$results['skipped'] = 0; $results['commentOnly'] = 0;
$results['comments'] = []; $results['comments'] = [];
} }
@@ -504,13 +504,15 @@ class ResultsService
*/ */
public function comments(Slide $slide, ?int $limit = null): array public function comments(Slide $slide, ?int $limit = null): array
{ {
// Scale: the rating row carries the comment. Choice: the comment sits in the first of the // Scale: the rating row carries the comment (no rating = comment only). Choice: the comment
// participant's rows, which always has an option. // sits in the first of the participant's rows, which always has an option.
$answered = $slide->type === Slide::TYPE_CHOICE ? 'slide_option_id IS NOT' : 'numeric_value IS NOT';
$query = $this->Responses->find() $query = $this->Responses->find()
->select(['id', 'text_value', 'numeric_value', 'created']) ->select(['id', 'text_value', 'numeric_value', 'created'])
->where(['slide_id' => $slide->id, 'text_value IS NOT' => null, $answered => null]) ->where(['slide_id' => $slide->id, 'text_value IS NOT' => null])
->orderBy(['id' => 'DESC']); ->orderBy(['id' => 'DESC']);
if ($slide->type === Slide::TYPE_CHOICE) {
$query->where(['slide_option_id IS NOT' => null]);
}
if ($limit !== null) { if ($limit !== null) {
$query->limit($limit); $query->limit($limit);
} }
@@ -532,7 +534,7 @@ class ResultsService
* Distribution and average of a scale. * Distribution and average of a scale.
* *
* @param \App\Model\Entity\Slide $slide Scale slide * @param \App\Model\Entity\Slide $slide Scale slide
* @return array{buckets: list<array{value: int, count: int, percent: float|int}>, average: float|null, min: int, max: int, minLabel: string, maxLabel: string, stars: bool, skipped: int} * @return array{buckets: list<array{value: int, count: int, percent: float|int}>, average: float|null, min: int, max: int, minLabel: string, maxLabel: string, stars: bool, commentOnly: int}
*/ */
public function scaleResults(Slide $slide): array public function scaleResults(Slide $slide): array
{ {
@@ -547,10 +549,8 @@ class ResultsService
->combine('numeric_value', 'n') ->combine('numeric_value', 'n')
->toArray(); ->toArray();
// "Keine Angabe": taking part without a rating, never part of the average or the distribution // Comment only: taking part without a rating, never part of the average or the distribution
$skipped = $slide->setting('allow_skip') $commentOnly = $this->Responses->find()->where(['slide_id' => $slide->id, 'numeric_value IS' => null])->count();
? $this->Responses->find()->where(['slide_id' => $slide->id, 'numeric_value IS' => null])->count()
: 0;
$total = 0; $total = 0;
$sum = 0; $sum = 0;
@@ -576,7 +576,7 @@ class ResultsService
'minLabel' => (string)$slide->setting('min_label'), 'minLabel' => (string)$slide->setting('min_label'),
'maxLabel' => (string)$slide->setting('max_label'), 'maxLabel' => (string)$slide->setting('max_label'),
'stars' => $slide->isStarRating(), 'stars' => $slide->isStarRating(),
'skipped' => $skipped, 'commentOnly' => $commentOnly,
]; ];
} }
} }
+11 -23
View File
@@ -179,8 +179,9 @@ class VoteService
default => __('Bitte gib zuerst deine Bewertung ab.'), default => __('Bitte gib zuerst deine Bewertung ab.'),
}); });
} }
if ($slide->type === Slide::TYPE_SCALE && $row->numeric_value === null) { if ($slide->type === Slide::TYPE_SCALE && $row->numeric_value === null && $text === null) {
throw new VoteException(__('Zu „Keine Angabe“ gibt es keinen Kommentar.')); // Without a rating the comment is the whole answer.
throw new VoteException(__('Ohne Bewertung darf der Kommentar nicht leer sein.'));
} }
$row->text_value = $text; $row->text_value = $text;
$this->Responses->saveOrFail($row); $this->Responses->saveOrFail($row);
@@ -206,22 +207,6 @@ class VoteService
return $row['text_value'] ?? null; return $row['text_value'] ?? null;
} }
/**
* Whether the participant answered a scale with "Keine Angabe" (a row without rating).
*
* @param \App\Model\Entity\Slide $slide Slide
* @param string $participantHash Participant hash
* @return bool
*/
public function hasSkipped(Slide $slide, string $participantHash): bool
{
return $slide->type === Slide::TYPE_SCALE && $this->Responses->exists([
'slide_id' => $slide->id,
'participant_hash' => $participantHash,
'numeric_value IS' => null,
]);
}
/** /**
* Poll active, slide live and interactive, voting open. * Poll active, slide live and interactive, voting open.
* *
@@ -701,13 +686,16 @@ class VoteService
*/ */
protected function scaleRows(Slide $slide, array $data): array protected function scaleRows(Slide $slide, array $data): array
{ {
if (self::stringField($data, 'skip') === '1') { if (self::stringField($data, 'value') === '' && $slide->hasComments()) {
if (!$slide->setting('allow_skip')) { // Comment only: no rating, but a comment is required (this is not a way to skip).
throw new VoteException(__('„Keine Angabe“ ist bei dieser Frage nicht möglich.')); $comment = self::comment($data);
if ($comment === null) {
throw new VoteException($slide->isStarRating()
? __('Bitte vergib Sterne oder schreibe einen Kommentar.')
: __('Bitte wähle einen Wert oder schreibe einen Kommentar.'));
} }
// Counts as taking part, but has no rating and no comment. return [['numeric_value' => null, 'text_value' => $comment]];
return [['numeric_value' => null, 'text_value' => null]];
} }
$value = filter_var($data['value'] ?? null, FILTER_VALIDATE_INT); $value = filter_var($data['value'] ?? null, FILTER_VALIDATE_INT);
$min = (int)$slide->setting('scale_min'); $min = (int)$slide->setting('scale_min');
+2 -2
View File
@@ -205,8 +205,8 @@ $bar = function (float $percent, bool $ok = false): string {
<span class="muted"><?= !empty($r['stars']) <span class="muted"><?= !empty($r['stars'])
? __('von {0} Sternen', (int)$r['max']) ? __('von {0} Sternen', (int)$r['max'])
: __('auf einer Skala von {0} bis {1}', (int)$r['min'], (int)$r['max']) ?></span> : __('auf einer Skala von {0} bis {1}', (int)$r['min'], (int)$r['max']) ?></span>
<?php if (!empty($r['skipped'])) : ?> <?php if (!empty($r['commentOnly'])) : ?>
· <span class="muted"><?= __('{0}× „Keine Angabe“ (nicht im Durchschnitt)', (int)$r['skipped']) ?></span> · <span class="muted"><?= __('{0}× nur Kommentar (nicht im Durchschnitt)', (int)$r['commentOnly']) ?></span>
<?php endif; ?> <?php endif; ?>
</p> </p>
<table> <table>
+4 -10
View File
@@ -9,7 +9,6 @@
* @var array<string, mixed> $state * @var array<string, mixed> $state
* @var string $participantHash Seed for the shuffled items of ordering slides * @var string $participantHash Seed for the shuffled items of ordering slides
* @var string|null $ownText Own open answer or scale comment (editable while voting is open) * @var string|null $ownText Own open answer or scale comment (editable while voting is open)
* @var bool $skipped Whether the participant answered the scale with "Keine Angabe"
* @var int $pollIntervalMs * @var int $pollIntervalMs
*/ */
use App\Service\VoteService; use App\Service\VoteService;
@@ -242,7 +241,7 @@ $countdown = function (?int $remaining): string {
</div> </div>
<?php elseif ($state['hasResponded']) : ?> <?php elseif ($state['hasResponded']) : ?>
<p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p> <p class="done">✓ <?= __('Deine Antwort ist angekommen.') ?></p>
<?php if (VoteService::hasEditableText($slide) && $slide->isVotingOpen() && !$skipped) : <?php if (VoteService::hasEditableText($slide) && $slide->isVotingOpen()) :
$isOpen = $slide->type === 'open'; ?> $isOpen = $slide->type === 'open'; ?>
<?php if ($ownText !== null) : ?> <?php if ($ownText !== null) : ?>
<p class="own-comment__label"><?= $isOpen ? __('Deine Antwort:') : __('Dein Kommentar:') ?></p> <p class="own-comment__label"><?= $isOpen ? __('Deine Antwort:') : __('Dein Kommentar:') ?></p>
@@ -310,7 +309,7 @@ $countdown = function (?int $remaining): string {
<div class="stars<?= $maxValue > 6 ? ' stars--many' : '' ?>" role="radiogroup" aria-label="<?= __('Bewertung in Sternen') ?>"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>> <div class="stars<?= $maxValue > 6 ? ' stars--many' : '' ?>" role="radiogroup" aria-label="<?= __('Bewertung in Sternen') ?>"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
<?php for ($v = 1; $v <= $maxValue; $v++) : ?> <?php for ($v = 1; $v <= $maxValue; $v++) : ?>
<label class="stars__star"> <label class="stars__star">
<input type="radio" name="value" value="<?= $v ?>" required> <input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasComments() ? '' : 'required' ?>>
<span class="stars__icon" aria-hidden="true">★</span> <span class="stars__icon" aria-hidden="true">★</span>
<span class="sr-only"><?= __('{0} von {1} Sternen', $v, $maxValue) ?></span> <span class="sr-only"><?= __('{0} von {1} Sternen', $v, $maxValue) ?></span>
</label> </label>
@@ -320,7 +319,7 @@ $countdown = function (?int $remaining): string {
<div class="scale"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>> <div class="scale"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
<?php for ($v = (int)$slide->setting('scale_min'); $v <= $maxValue; $v++) : ?> <?php for ($v = (int)$slide->setting('scale_min'); $v <= $maxValue; $v++) : ?>
<label class="scale__step"> <label class="scale__step">
<input type="radio" name="value" value="<?= $v ?>" required> <input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasComments() ? '' : 'required' ?>>
<span><?= $v ?></span> <span><?= $v ?></span>
</label> </label>
<?php endfor; ?> <?php endfor; ?>
@@ -332,6 +331,7 @@ $countdown = function (?int $remaining): string {
</div> </div>
<?php if ($slide->hasComments()) : ?> <?php if ($slide->hasComments()) : ?>
<label class="scale-comment" for="scale-comment"><?= __('Kommentar (optional)') ?></label> <label class="scale-comment" for="scale-comment"><?= __('Kommentar (optional)') ?></label>
<p class="hint"><?= __('Du kannst auch nur einen Kommentar abgeben, ohne zu bewerten.') ?></p>
<textarea id="scale-comment" name="comment" rows="3" maxlength="500" <textarea id="scale-comment" name="comment" rows="3" maxlength="500"
placeholder="<?= __('Möchtest du deine Bewertung begründen?') ?>"></textarea> placeholder="<?= __('Möchtest du deine Bewertung begründen?') ?>"></textarea>
<?php endif; ?> <?php endif; ?>
@@ -343,12 +343,6 @@ $countdown = function (?int $remaining): string {
<?php endif; ?> <?php endif; ?>
<?= $this->Form->button(__('Absenden'), ['class' => 'button button--primary button--block']) ?> <?= $this->Form->button(__('Absenden'), ['class' => 'button button--primary button--block']) ?>
<?php if ($slide->type === 'scale' && $slide->setting('allow_skip')) : ?>
<?= $this->Form->button(__('Keine Angabe'), [
'name' => 'skip', 'value' => '1', 'formnovalidate' => true,
'class' => 'button button--block button--skip',
]) ?>
<?php endif; ?>
<?= $this->Form->end() ?> <?= $this->Form->end() ?>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
+2 -2
View File
@@ -31,7 +31,7 @@ $count = match (true) {
</p> </p>
<h1 id="modal-title"><?= h($slide->question) ?></h1> <h1 id="modal-title"><?= h($slide->question) ?></h1>
<?php if ($scale !== null) : ?> <?php if ($scale !== null) : ?>
<p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?><?php if (!empty($scale['skipped'])) : ?> · <?= __('{0}× „Keine Angabe“', (int)$scale['skipped']) ?><?php endif; ?></p> <p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?><?php if (!empty($scale['commentOnly'])) : ?> · <?= __('{0}× nur Kommentar', (int)$scale['commentOnly']) ?><?php endif; ?></p>
<?php elseif ($isChoice) : ?> <?php elseif ($isChoice) : ?>
<p class="muted"><?= __n('{0} Kommentar, neueste zuerst', '{0} Kommentare, neueste zuerst', $count, $count) ?></p> <p class="muted"><?= __n('{0} Kommentar, neueste zuerst', '{0} Kommentare, neueste zuerst', $count, $count) ?></p>
<?php else : ?> <?php else : ?>
@@ -86,7 +86,7 @@ $count = match (true) {
$created = new DateTime($comment['created']); ?> $created = new DateTime($comment['created']); ?>
<li> <li>
<?= h($comment['text']) ?> <?= h($comment['text']) ?>
<time datetime="<?= h($comment['created']) ?>"><?= __('Bewertung') ?> <?= $this->element('rating', ['slide' => $slide, 'value' => (int)$comment['value']]) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time> <time datetime="<?= h($comment['created']) ?>"><?php if ($comment['value'] !== null) : ?><?= __('Bewertung') ?> <?= $this->element('rating', ['slide' => $slide, 'value' => (int)$comment['value']]) ?><?php else : ?><?= __('ohne Bewertung') ?><?php endif; ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>
</ol> </ol>
+1 -7
View File
@@ -195,12 +195,6 @@ $optionsError = $slide->getError('options_text');
'placeholder' => __('z. B. sehr'), 'value' => $settings['max_label'], 'placeholder' => __('z. B. sehr'), 'value' => $settings['max_label'],
]) ?> ]) ?>
</div> </div>
<?= $this->Form->control('settings.allow_skip', [
'type' => 'checkbox',
'label' => __('„Keine Angabe“ erlauben (Teilnehmende können die Frage überspringen)'),
'checked' => (bool)$settings['allow_skip'],
]) ?>
<p class="hint"><?= __('Wer „Keine Angabe“ wählt, zählt als Teilnehmer/in, geht aber nicht in Durchschnitt und Verteilung ein. Die Zahl steht separat dabei.') ?></p>
<?= $this->Form->control('settings.scale_view', [ <?= $this->Form->control('settings.scale_view', [
'type' => 'select', 'type' => 'select',
'label' => __('In der Präsentation zeigen'), 'label' => __('In der Präsentation zeigen'),
@@ -214,7 +208,7 @@ $optionsError = $slide->getError('options_text');
<p class="hint"><?= __('Die Auswertung in der Verwaltung und der PDF-Export enthalten immer beides.') ?></p> <p class="hint"><?= __('Die Auswertung in der Verwaltung und der PDF-Export enthalten immer beides.') ?></p>
<?= $this->Form->control('settings.comments', [ <?= $this->Form->control('settings.comments', [
'type' => 'checkbox', 'type' => 'checkbox',
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'), 'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen oder auch nur einen Kommentar ohne Bewertung abgeben)'),
'checked' => (bool)$settings['comments'], 'checked' => (bool)$settings['comments'],
]) ?> ]) ?>
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden), jeder so lange, wie man zum Lesen braucht: kurze etwa 5 Sekunden, lange bis zu 30 Sekunden. Das Tempo stellst du für die ganze Umfrage in den Einstellungen im Dashboard ein. Bei internem Feedback erst, wenn du die Ergebnisse einblendest.') ?></p> <p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden), jeder so lange, wie man zum Lesen braucht: kurze etwa 5 Sekunden, lange bis zu 30 Sekunden. Das Tempo stellst du für die ganze Umfrage in den Einstellungen im Dashboard ein. Bei internem Feedback erst, wenn du die Ergebnisse einblendest.') ?></p>
@@ -239,29 +239,22 @@ class ParticipateControllerTest extends TestCase
$this->assertFalse(TableRegistry::getTableLocator()->get('Responses')->exists(['text_value' => 'Hack'])); $this->assertFalse(TableRegistry::getTableLocator()->get('Responses')->exists(['text_value' => 'Hack']));
} }
public function testScaleSkipButtonOnlyWithSetting(): void public function testScaleCommentOnlyWithoutRating(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE); $slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
$this->goLive($poll, $slide); $this->goLive($poll, $slide);
$this->cookie('plenario_pid', self::PID); $this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code); $this->get('/p/' . $poll->join_code);
$this->assertResponseNotContains('Keine Angabe'); $this->assertResponseContains('auch nur einen Kommentar');
$this->assertResponseNotContains('required>');
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['allow_skip' => true, 'comments' => true]]);
$this->goLive($poll, $slide);
$this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('name="skip"');
$this->cookie('plenario_pid', self::PID); $this->cookie('plenario_pid', self::PID);
$this->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'skip' => '1']); $this->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'comment' => 'Keine Meinung dazu']);
$this->assertFlashMessage('Danke für deine Antwort!'); $this->assertFlashMessage('Danke für deine Antwort!');
// No rating, so no comment to add afterwards.
$this->cookie('plenario_pid', self::PID); $this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code); $this->get('/p/' . $poll->join_code);
$this->assertResponseContains('Deine Antwort ist angekommen.'); $this->assertResponseContains('Keine Meinung dazu');
$this->assertResponseNotContains('Kommentar hinzufügen');
} }
} }
+26 -15
View File
@@ -71,49 +71,60 @@ class VoteServiceTest extends TestCase
(new VoteService())->submit($poll, $slide, 'p1', ['value' => '4']); (new VoteService())->submit($poll, $slide, 'p1', ['value' => '4']);
} }
public function testScaleSkipCountsAsParticipantButNotInAverage(): void public function testScaleCommentOnlyCountsAsParticipantButNotInAverage(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'allow_skip' => true]]); $slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'comments' => true]]);
$poll = $this->goLive($poll, $slide); $poll = $this->goLive($poll, $slide);
$service = new VoteService(); $service = new VoteService();
$service->submit($poll, $slide, 'p1', ['value' => '4']); $service->submit($poll, $slide, 'p1', ['value' => '4']);
$service->submit($poll, $slide, 'p2', ['skip' => '1']); $service->submit($poll, $slide, 'p2', ['comment' => 'Kann ich nicht beurteilen']);
$results = (new ResultsService())->forSlide($slide); $results = (new ResultsService())->forSlide($slide);
$this->assertSame(2, $results['participants']); $this->assertSame(2, $results['participants']);
$this->assertSame(1, $results['skipped']); $this->assertSame(1, $results['commentOnly']);
$this->assertSame(4.0, (float)$results['average']); $this->assertSame(4.0, (float)$results['average']);
$this->assertSame(1, array_sum(array_column($results['buckets'], 'count'))); $this->assertSame(1, array_sum(array_column($results['buckets'], 'count')));
$this->assertTrue($service->hasSkipped($slide, 'p2')); $this->assertSame(['Kann ich nicht beurteilen'], array_column($results['comments'], 'text'));
$this->assertFalse($service->hasSkipped($slide, 'p1')); $this->assertSame([null], array_column((new ResultsService())->comments($slide), 'value'));
// Only once per person, like any answer. // Only once per person, like any answer.
$this->expectExceptionMessage('bereits abgestimmt'); $this->expectExceptionMessage('bereits abgestimmt');
$service->submit($poll, $slide, 'p2', ['value' => '2']); $service->submit($poll, $slide, 'p2', ['value' => '2']);
} }
public function testScaleSkipNeedsTheSetting(): void public function testScaleWithoutRatingNeedsCommentField(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE); $slide = $this->createSlide($poll, Slide::TYPE_SCALE);
$poll = $this->goLive($poll, $slide); $poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('nicht möglich'); $this->expectExceptionMessage('zwischen 1 und 5');
(new VoteService())->submit($poll, $slide, 'p1', ['skip' => '1']); (new VoteService())->submit($poll, $slide, 'p1', ['comment' => 'Nur Kommentar']);
} }
public function testScaleSkipHasNoComment(): void public function testScaleNeedsRatingOrComment(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['allow_skip' => true, 'comments' => true]]); $slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
$poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('oder schreibe einen Kommentar');
(new VoteService())->submit($poll, $slide, 'p1', ['comment' => ' ']);
}
public function testCommentOnlyAnswerCanBeEditedButNotEmptied(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
$poll = $this->goLive($poll, $slide); $poll = $this->goLive($poll, $slide);
$service = new VoteService(); $service = new VoteService();
$service->submit($poll, $slide, 'p1', ['skip' => '1', 'comment' => 'Ignoriert']); $service->submit($poll, $slide, 'p1', ['comment' => 'Erst']);
$service->editText($poll, $slide, 'p1', ['comment' => 'Dann']);
$this->assertSame('Dann', $service->ownText($slide, 'p1'));
$this->assertNull($service->ownText($slide, 'p1')); $this->expectExceptionMessage('nicht leer sein');
$this->expectExceptionMessage('keinen Kommentar'); $service->editText($poll, $slide, 'p1', ['comment' => '']);
$service->editText($poll, $slide, 'p1', ['comment' => 'Nachtrag']);
} }
public function testMultipleChoiceResults(): void public function testMultipleChoiceResults(): void
-1
View File
@@ -225,7 +225,6 @@ h3 { font-size: 1.05rem; margin-top: 1.6em; }
.button--danger { color: var(--danger); } .button--danger { color: var(--danger); }
.button--danger:hover { border-color: var(--danger); } .button--danger:hover { border-color: var(--danger); }
.button--ghost { border-color: transparent; background: transparent; } .button--ghost { border-color: transparent; background: transparent; }
.button--skip { margin-top: 8px; }
.button--small { padding: 6px 10px; font-size: .85rem; } .button--small { padding: 6px 10px; font-size: .85rem; }
.header-tools { display: flex; align-items: center; gap: 8px; } .header-tools { display: flex; align-items: center; gap: 8px; }
.button--block { width: 100%; padding: 14px; font-size: 1.05rem; } .button--block { width: 100%; padding: 14px; font-size: 1.05rem; }
+10 -7
View File
@@ -616,7 +616,11 @@
'Kommentar ' + (Comments.index + 1) + ' von ' + Comments.items.length; 'Kommentar ' + (Comments.index + 1) + ' von ' + Comments.items.length;
text.textContent = item.text; text.textContent = item.text;
var value = node.querySelector('[data-comment-value]'); var value = node.querySelector('[data-comment-value]');
value.textContent = item.value === null || item.value === undefined ? '' : 'Bewertung: ' + Comments.format(item.value); // With ratings shown, comments sent without one say so (keeps the box at the same height).
var rated = Comments.items.some(function (other) { return other.value !== null && other.value !== undefined; });
value.textContent = item.value === null || item.value === undefined
? (rated ? 'Ohne Bewertung' : '')
: 'Bewertung: ' + Comments.format(item.value);
value.hidden = value.textContent === ''; value.hidden = value.textContent === '';
// Only announce changes the viewer triggered, not every automatic rotation. // Only announce changes the viewer triggered, not every automatic rotation.
node.setAttribute('aria-live', Comments.paused ? 'polite' : 'off'); node.setAttribute('aria-live', Comments.paused ? 'polite' : 'off');
@@ -797,7 +801,7 @@
el('span', { el('span', {
class: 'average__count', class: 'average__count',
text: total + (total === 1 ? ' Bewertung' : ' Bewertungen') text: total + (total === 1 ? ' Bewertung' : ' Bewertungen')
+ (results.skipped ? ' · ' + results.skipped + '× keine Angabe' : '') + (results.commentOnly ? ' · ' + results.commentOnly + '× nur Kommentar' : '')
}) })
]); ]);
}, },
@@ -3334,11 +3338,10 @@
if (event.defaultPrevented) { if (event.defaultPrevented) {
return; // handled via fetch (word cloud) return; // handled via fetch (word cloud)
} }
// All buttons (e.g. "Absenden" and "Keine Angabe"); the pressed one is already part of the request. var button = form.querySelector('button[type=submit], button:not([type])');
var buttons = form.querySelectorAll('button[type=submit], button:not([type])'); if (button) {
setTimeout(function () { setTimeout(function () { button.disabled = true; }, 0);
buttons.forEach(function (button) { button.disabled = true; }); }
}, 0);
}); });
}); });
}); });