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

+4 -4
View File
@@ -43,12 +43,12 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
<p class="scale-average">
<?= __('Durchschnitt') ?>:
<strong><?= h($this->Number->format((float)$scale['average'], ['places' => 1, 'precision' => 1, 'locale' => 'de_DE'])) ?></strong>
<span class="muted">/ <?= (int)$scale['max'] ?></span>
<span class="muted"><?= $slide->isStarRating() ? __('von {0} Sternen', (int)$scale['max']) : '/ ' . (int)$scale['max'] ?></span>
</p>
<table class="scale-table">
<caption class="sr-only"><?= __('Verteilung der Bewertungen') ?></caption>
<thead>
<tr><th scope="col"><?= __('Wert') ?></th><th scope="col"><?= __('Anzahl') ?></th><th scope="col"><?= __('Anteil') ?></th></tr>
<tr><th scope="col"><?= $slide->isStarRating() ? __('Sterne') : __('Wert') ?></th><th scope="col"><?= __('Anzahl') ?></th><th scope="col"><?= __('Anteil') ?></th></tr>
</thead>
<tbody>
<?php foreach ($scale['buckets'] as $i => $bucket) :
@@ -58,7 +58,7 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
default => '',
}; ?>
<tr>
<th scope="row"><?= (int)$bucket['value'] ?><?php if ($label !== '') : ?> <span class="muted">(<?= h($label) ?>)</span><?php endif; ?></th>
<th scope="row"><?= $this->element('rating', ['slide' => $slide, 'value' => (int)$bucket['value']]) ?><?php if ($label !== '') : ?> <span class="muted">(<?= h($label) ?>)</span><?php endif; ?></th>
<td><?= (int)$bucket['count'] ?></td>
<td>
<span class="scale-table__bar" style="width: <?= (float)$bucket['percent'] ?>%" aria-hidden="true"></span>
@@ -79,7 +79,7 @@ $count = $scale !== null ? array_sum(array_column($scale['buckets'], 'count')) :
$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>
<time datetime="<?= h($comment['created']) ?>"><?= __('Bewertung') ?> <?= $this->element('rating', ['slide' => $slide, 'value' => (int)$comment['value']]) ?> · <?= h($created->i18nFormat('dd.MM.yyyy, HH:mm')) ?></time>
</li>
<?php endforeach; ?>
</ol>
+12 -1
View File
@@ -148,14 +148,25 @@ $optionsError = $slide->getError('options_text');
'checked' => (bool)$settings['allow_downvotes'],
]) ?>
<?php elseif ($slide->type === 'scale') : ?>
<?php $stars = $settings['style'] === \App\Model\Entity\Slide::SCALE_STARS; ?>
<fieldset class="scale-style" data-scale-style>
<legend><?= __('Darstellung') ?></legend>
<?= $this->Form->radio('settings.style', [
['value' => \App\Model\Entity\Slide::SCALE_NUMBERS, 'text' => __('Zahlen (z. B. 1 bis 10)')],
['value' => \App\Model\Entity\Slide::SCALE_STARS, 'text' => __('Sterne (wie bei einer Produktbewertung)')],
], ['value' => $settings['style']]) ?>
</fieldset>
<div class="grid grid--2 grid--tight">
<?= $this->Form->control('settings.scale_min', [
'type' => 'select', 'options' => [0 => '0', 1 => '1'],
'label' => __('Von'), 'value' => $settings['scale_min'],
'templateVars' => ['attrs' => $stars ? ' hidden' : ''],
'templates' => ['inputContainer' => '<div class="input {{type}}{{required}}" data-scale-min{{attrs}}>{{content}}</div>'],
]) ?>
<?= $this->Form->control('settings.scale_max', [
'type' => 'select', 'options' => array_combine(range(2, 10), range(2, 10)),
'label' => __('Bis'), 'value' => $settings['scale_max'],
'label' => $stars ? __('Anzahl Sterne') : __('Bis'), 'value' => $settings['scale_max'],
'data-label-numbers' => __('Bis'), 'data-label-stars' => __('Anzahl Sterne'),
]) ?>
<?= $this->Form->control('settings.min_label', [
'label' => __('Beschriftung links (optional)'), 'maxlength' => 60,