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

+11 -23
View File
@@ -179,8 +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.'));
if ($slide->type === Slide::TYPE_SCALE && $row->numeric_value === null && $text === null) {
// Without a rating the comment is the whole answer.
throw new VoteException(__('Ohne Bewertung darf der Kommentar nicht leer sein.'));
}
$row->text_value = $text;
$this->Responses->saveOrFail($row);
@@ -206,22 +207,6 @@ 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.
*
@@ -701,13 +686,16 @@ 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.'));
if (self::stringField($data, 'value') === '' && $slide->hasComments()) {
// Comment only: no rating, but a comment is required (this is not a way to skip).
$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' => null]];
return [['numeric_value' => null, 'text_value' => $comment]];
}
$value = filter_var($data['value'] ?? null, FILTER_VALIDATE_INT);
$min = (int)$slide->setting('scale_min');