Add a star rating style to scale slides

Scales can now be shown as stars (1 to n) instead of numbered steps:
participants tap stars, the stage shows the average as partly filled
stars and the distribution as bars from most to fewest stars, and the
evaluation page and PDF export print ratings as stars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 12:46:33 +01:00
1 parent 1ee870d67c
commit c1f9be2eef
14 files changed
+400 -31

No files matched your search

+3 -2
View File
@@ -18,7 +18,7 @@ use Cake\ORM\Locator\LocatorAwareTrait;
* weight follows count)
* - open: 'answers' => [['text', 'created']] newest first, 'private' (bool);
* - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null,
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool);
* 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool), 'stars' (bool: star rating, min = 1);
* 'comments' => [['id', 'text', 'value' (int|null)]] oldest first (only with the comment field, else [];
* 'value' is null unless the setting comment_ratings is on;
* presentation only: participants never get results of scale slides, see PollStateService);
@@ -394,7 +394,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}
* @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}
*/
public function scaleResults(Slide $slide): array
{
@@ -432,6 +432,7 @@ class ResultsService
'max' => $max,
'minLabel' => (string)$slide->setting('min_label'),
'maxLabel' => (string)$slide->setting('max_label'),
'stars' => $slide->isStarRating(),
];
}
}
+3 -1
View File
@@ -665,7 +665,9 @@ class VoteService
$min = (int)$slide->setting('scale_min');
$max = (int)$slide->setting('scale_max');
if ($value === false || $value < $min || $value > $max) {
throw new VoteException(__('Bitte wähle einen Wert zwischen {0} und {1}.', $min, $max));
throw new VoteException($slide->isStarRating()
? __('Bitte vergib zwischen {0} und {1} Sternen.', $min, $max)
: __('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.
return [['numeric_value' => $value, 'text_value' => $slide->hasComments() ? self::comment($data) : null]];