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

+7
View File
@@ -146,6 +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()`
speichert eine Zeile **ohne** `numeric_value` und ohne Kommentar: zählt als Teilnahme (einmal pro Person, `countParticipants`), geht aber nicht in
Verteilung und Durchschnitt ein. `ResultsService::scaleResults()` liefert die Zahl separat als `skipped` (Bühne: „· N× keine Angabe“ unter der
Bewertungszahl, Auswertung, PDF); private Folien strippen sie wie den Rest (`withoutContents()`). Ein Kommentar nachträglich geht nicht
(`editText()` lehnt ab, `VoteService::hasSkipped()` blendet das Formular aus). Tests: `VoteServiceTest`, `ParticipateControllerTest`.
- **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.
- **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage - **Antwort nachträglich bearbeiten** (gegen Tippfehler, `VoteService::hasEditableText()`): Antwort einer offenen Frage
(darf nicht leer werden) bzw. Kommentar einer Skala (ändern, ergänzen, leeren; die Bewertung bleibt unveränderlich), (darf nicht leer werden) bzw. Kommentar einer Skala (ändern, ergänzen, leeren; die Bewertung bleibt unveränderlich),
nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie
+5 -2
View File
@@ -93,11 +93,14 @@ 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']
? (new VoteService())->ownText($slide, $participantHash) ? $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')); $this->set(compact('poll', 'slide', 'state', 'participantHash', 'ownText', 'skipped'));
$this->setPollInterval(); $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) // 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)
// (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);
@@ -130,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, 'comments' => false, 'comment_ratings' => false, 'allow_skip' => false,
'scale_view' => self::SCALE_VIEW_BOTH, 'scale_view' => self::SCALE_VIEW_BOTH,
'time_limit' => 0, '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['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;
+9 -1
View File
@@ -21,6 +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);
* '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,
@@ -486,6 +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['comments'] = []; $results['comments'] = [];
} }
@@ -530,7 +532,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} * @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 public function scaleResults(Slide $slide): array
{ {
@@ -545,6 +547,11 @@ 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
$skipped = $slide->setting('allow_skip')
? $this->Responses->find()->where(['slide_id' => $slide->id, 'numeric_value IS' => null])->count()
: 0;
$total = 0; $total = 0;
$sum = 0; $sum = 0;
foreach ($counts as $value => $count) { foreach ($counts as $value => $count) {
@@ -569,6 +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,
]; ];
} }
} }
+27
View File
@@ -179,6 +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) {
throw new VoteException(__('Zu „Keine Angabe“ gibt es keinen Kommentar.'));
}
$row->text_value = $text; $row->text_value = $text;
$this->Responses->saveOrFail($row); $this->Responses->saveOrFail($row);
}); });
@@ -203,6 +206,22 @@ 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.
* *
@@ -682,6 +701,14 @@ 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 (!$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); $value = filter_var($data['value'] ?? null, FILTER_VALIDATE_INT);
$min = (int)$slide->setting('scale_min'); $min = (int)$slide->setting('scale_min');
$max = (int)$slide->setting('scale_max'); $max = (int)$slide->setting('scale_max');
+3
View File
@@ -205,6 +205,9 @@ $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'])) : ?>
· <span class="muted"><?= __('{0}× „Keine Angabe“ (nicht im Durchschnitt)', (int)$r['skipped']) ?></span>
<?php endif; ?>
</p> </p>
<table> <table>
<thead><tr><th><?= !empty($r['stars']) ? __('Sterne') : __('Wert') ?></th><th class="num"><?= __('Anzahl') ?></th><th class="num"><?= __('Anteil') ?></th><th></th></tr></thead> <thead><tr><th><?= !empty($r['stars']) ? __('Sterne') : __('Wert') ?></th><th class="num"><?= __('Anzahl') ?></th><th class="num"><?= __('Anteil') ?></th><th></th></tr></thead>
+8 -1
View File
@@ -9,6 +9,7 @@
* @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;
@@ -241,7 +242,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()) : <?php if (VoteService::hasEditableText($slide) && $slide->isVotingOpen() && !$skipped) :
$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>
@@ -342,6 +343,12 @@ $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; ?>
+1 -1
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) ?></p> <p class="muted"><?= __n('{0} Bewertung', '{0} Bewertungen', $count, $count) ?><?php if (!empty($scale['skipped'])) : ?> · <?= __('{0}× „Keine Angabe“', (int)$scale['skipped']) ?><?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 : ?>
+10
View File
@@ -122,6 +122,10 @@ $optionsError = $slide->getError('options_text');
<div class="input textarea<?= $optionsError ? ' error' : '' ?>"> <div class="input textarea<?= $optionsError ? ' error' : '' ?>">
<label for="options-text"><?= __('Antwortoptionen (eine pro Zeile, max. 20)') ?></label> <label for="options-text"><?= __('Antwortoptionen (eine pro Zeile, max. 20)') ?></label>
<textarea id="options-text" name="options_text" rows="6" required><?= h($optionsText) ?></textarea> <textarea id="options-text" name="options_text" rows="6" required><?= h($optionsText) ?></textarea>
<?php // Shortcut for formal votes; needs JavaScript, so it stays hidden without it. ?>
<button type="button" class="button button--small button--ghost" hidden
data-add-option="<?= h(__('Enthaltung')) ?>" data-add-option-target="options-text"
data-add-option-max="20">+ <?= __('Option „Enthaltung“ hinzufügen') ?></button>
<?php if ($optionsError) : ?> <?php if ($optionsError) : ?>
<div class="error-message"><?= h(implode(' ', (array)$optionsError)) ?></div> <div class="error-message"><?= h(implode(' ', (array)$optionsError)) ?></div>
<?php endif; ?> <?php endif; ?>
@@ -191,6 +195,12 @@ $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'),
@@ -238,4 +238,30 @@ class ParticipateControllerTest extends TestCase
$this->assertFlashMessage('Diese Antwort kann nicht mehr geändert werden.'); $this->assertFlashMessage('Diese Antwort kann nicht mehr geändert werden.');
$this->assertFalse(TableRegistry::getTableLocator()->get('Responses')->exists(['text_value' => 'Hack'])); $this->assertFalse(TableRegistry::getTableLocator()->get('Responses')->exists(['text_value' => 'Hack']));
} }
public function testScaleSkipButtonOnlyWithSetting(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE);
$this->goLive($poll, $slide);
$this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code);
$this->assertResponseNotContains('Keine Angabe');
$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->post("/p/{$poll->join_code}/vote", ['slide_id' => $slide->id, 'skip' => '1']);
$this->assertFlashMessage('Danke für deine Antwort!');
// No rating, so no comment to add afterwards.
$this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('Deine Antwort ist angekommen.');
$this->assertResponseNotContains('Kommentar hinzufügen');
}
} }
@@ -71,6 +71,51 @@ class VoteServiceTest extends TestCase
(new VoteService())->submit($poll, $slide, 'p1', ['value' => '4']); (new VoteService())->submit($poll, $slide, 'p1', ['value' => '4']);
} }
public function testScaleSkipCountsAsParticipantButNotInAverage(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'allow_skip' => true]]);
$poll = $this->goLive($poll, $slide);
$service = new VoteService();
$service->submit($poll, $slide, 'p1', ['value' => '4']);
$service->submit($poll, $slide, 'p2', ['skip' => '1']);
$results = (new ResultsService())->forSlide($slide);
$this->assertSame(2, $results['participants']);
$this->assertSame(1, $results['skipped']);
$this->assertSame(4.0, (float)$results['average']);
$this->assertSame(1, array_sum(array_column($results['buckets'], 'count')));
$this->assertTrue($service->hasSkipped($slide, 'p2'));
$this->assertFalse($service->hasSkipped($slide, 'p1'));
// Only once per person, like any answer.
$this->expectExceptionMessage('bereits abgestimmt');
$service->submit($poll, $slide, 'p2', ['value' => '2']);
}
public function testScaleSkipNeedsTheSetting(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE);
$poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('nicht möglich');
(new VoteService())->submit($poll, $slide, 'p1', ['skip' => '1']);
}
public function testScaleSkipHasNoComment(): void
{
[$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['allow_skip' => true, 'comments' => true]]);
$poll = $this->goLive($poll, $slide);
$service = new VoteService();
$service->submit($poll, $slide, 'p1', ['skip' => '1', 'comment' => 'Ignoriert']);
$this->assertNull($service->ownText($slide, 'p1'));
$this->expectExceptionMessage('keinen Kommentar');
$service->editText($poll, $slide, 'p1', ['comment' => 'Nachtrag']);
}
public function testMultipleChoiceResults(): void public function testMultipleChoiceResults(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
+1
View File
@@ -225,6 +225,7 @@ 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; }
+50 -5
View File
@@ -794,7 +794,11 @@
el('span', { class: 'average__of', text: ofText }) el('span', { class: 'average__of', text: ofText })
]), ]),
visual, visual,
el('span', { class: 'average__count', text: total + (total === 1 ? ' Bewertung' : ' Bewertungen') }) el('span', {
class: 'average__count',
text: total + (total === 1 ? ' Bewertung' : ' Bewertungen')
+ (results.skipped ? ' · ' + results.skipped + '× keine Angabe' : '')
})
]); ]);
}, },
@@ -2841,6 +2845,45 @@
update(); update();
} }
// ------------------------------------------------------------------ quick option (choice form)
/**
* Button that appends a ready-made option (e.g. "Enthaltung") to the option textarea.
* Idempotent: an existing line with the same text is not added again; the maximum is respected.
*/
function initAddOption(button) {
var area = document.getElementById(button.getAttribute('data-add-option-target'));
if (!area) {
return;
}
var label = button.getAttribute('data-add-option');
var max = parseInt(button.getAttribute('data-add-option-max'), 10) || 20;
function lines() {
return area.value.split(/\r?\n/).map(function (line) { return line.trim(); }).filter(Boolean);
}
function update() {
var current = lines();
var present = current.some(function (line) { return line.toLowerCase() === label.toLowerCase(); });
button.disabled = present || current.length >= max;
}
button.hidden = false;
button.addEventListener('click', function () {
var current = lines();
if (button.disabled) {
return;
}
current.push(label);
area.value = current.join('\n');
update();
area.focus();
});
area.addEventListener('input', update);
update();
}
// ------------------------------------------------------------------ theme switch // ------------------------------------------------------------------ theme switch
var THEME_ICONS = { auto: '◐', light: '☀', dark: '☾' }; var THEME_ICONS = { auto: '◐', light: '☀', dark: '☾' };
@@ -3163,6 +3206,7 @@
root.querySelectorAll('[data-sortable]').forEach(initSortable); root.querySelectorAll('[data-sortable]').forEach(initSortable);
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions); root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle); root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
root.querySelectorAll('[data-add-option]').forEach(initAddOption);
} }
// Flash messages: click hides them (delegated, no inline handlers because of the CSP). // Flash messages: click hides them (delegated, no inline handlers because of the CSP).
@@ -3290,10 +3334,11 @@
if (event.defaultPrevented) { if (event.defaultPrevented) {
return; // handled via fetch (word cloud) return; // handled via fetch (word cloud)
} }
var button = form.querySelector('button[type=submit], button:not([type])'); // All buttons (e.g. "Absenden" and "Keine Angabe"); the pressed one is already part of the request.
if (button) { var buttons = form.querySelectorAll('button[type=submit], button:not([type])');
setTimeout(function () { button.disabled = true; }, 0); setTimeout(function () {
} buttons.forEach(function (button) { button.disabled = true; });
}, 0);
}); });
}); });
}); });