Add "Keine Angabe" to scales and an "Enthaltung" shortcut for choice slides
CI / Deploy / PHP 8.5 (push) Successful in 1m38s
CI / Deploy / PHP 8.4 (push) Successful in 1m39s
CI / Deploy / test (push) Successful in 2s
CI / Deploy / deploy (push) Skipped

Scales and star ratings get an optional "Keine Angabe" answer (setting
allow_skip). It counts as taking part but stays out of the average and
the distribution; the number is shown separately on stage, in the
evaluation and in the PDF. The choice form gets a button that appends an
"Enthaltung" option.

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

No files matched your search

+5 -2
View File
@@ -93,11 +93,14 @@ class ParticipateController extends AppController
$slide = $poll->is_active ? $stateService->currentSlide($poll) : null;
$participantHash = $this->participantHash($poll);
$state = $stateService->forParticipant($poll, $participantHash, $slide);
$voteService = new VoteService();
$ownText = $slide !== null && VoteService::hasEditableText($slide) && $state['hasResponded']
? (new VoteService())->ownText($slide, $participantHash)
? $voteService->ownText($slide, $participantHash)
: 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'));
$this->set(compact('poll', 'slide', 'state', 'participantHash', 'ownText', 'skipped'));
$this->setPollInterval();
}
+2 -1
View File
@@ -123,6 +123,7 @@ class Slide extends Entity
// 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
// allow_skip: participants may answer "Keine Angabe" (row without numeric_value, not part of the average)
// (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
// scale_view: parts of the result shown in the presentation (presenter/embed, SCALE_VIEWS);
@@ -130,7 +131,7 @@ class Slide extends Entity
self::TYPE_SCALE => [
'style' => self::SCALE_NUMBERS,
'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false,
'comments' => false, 'comment_ratings' => false,
'comments' => false, 'comment_ratings' => false, 'allow_skip' => false,
'scale_view' => self::SCALE_VIEW_BOTH,
'time_limit' => 0,
],
+1
View File
@@ -177,6 +177,7 @@ class SlidesTable extends Table
$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);
$settings['allow_skip'] = filter_var($input['allow_skip'] ?? false, FILTER_VALIDATE_BOOLEAN);
$view = $input['scale_view'] ?? null;
$settings['scale_view'] = in_array($view, Slide::SCALE_VIEWS, true) ? $view : Slide::SCALE_VIEW_BOTH;
break;
+9 -1
View File
@@ -21,6 +21,7 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* - open: 'answers' => [['text', 'created']] newest first, 'private' (bool);
* - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null,
* '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);
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
* 'value' is null unless the setting comment_ratings is on;
* 'view' (both|average|chart): parts shown in the presentation (setting scale_view,
@@ -486,6 +487,7 @@ class ResultsService
if (isset($results['buckets'])) {
$results['buckets'] = [];
$results['average'] = null;
$results['skipped'] = 0;
$results['comments'] = [];
}
@@ -530,7 +532,7 @@ class ResultsService
* Distribution and average of a scale.
*
* @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}
* @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}
*/
public function scaleResults(Slide $slide): array
{
@@ -545,6 +547,11 @@ class ResultsService
->combine('numeric_value', 'n')
->toArray();
// "Keine Angabe": taking part without a rating, never part of the average or the distribution
$skipped = $slide->setting('allow_skip')
? $this->Responses->find()->where(['slide_id' => $slide->id, 'numeric_value IS' => null])->count()
: 0;
$total = 0;
$sum = 0;
foreach ($counts as $value => $count) {
@@ -569,6 +576,7 @@ class ResultsService
'minLabel' => (string)$slide->setting('min_label'),
'maxLabel' => (string)$slide->setting('max_label'),
'stars' => $slide->isStarRating(),
'skipped' => $skipped,
];
}
}
+27
View File
@@ -179,6 +179,9 @@ class VoteService
default => __('Bitte gib zuerst deine Bewertung ab.'),
});
}
if ($slide->type === Slide::TYPE_SCALE && $row->numeric_value === null) {
throw new VoteException(__('Zu „Keine Angabe“ gibt es keinen Kommentar.'));
}
$row->text_value = $text;
$this->Responses->saveOrFail($row);
});
@@ -203,6 +206,22 @@ class VoteService
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.
*
@@ -682,6 +701,14 @@ class VoteService
*/
protected function scaleRows(Slide $slide, array $data): array
{
if (self::stringField($data, 'skip') === '1') {
if (!$slide->setting('allow_skip')) {
throw new VoteException(__('„Keine Angabe“ ist bei dieser Frage nicht möglich.'));
}
// Counts as taking part, but has no rating and no comment.
return [['numeric_value' => null, 'text_value' => null]];
}
$value = filter_var($data['value'] ?? null, FILTER_VALIDATE_INT);
$min = (int)$slide->setting('scale_min');
$max = (int)$slide->setting('scale_max');