Make "comment without rating" a choice in a comment dropdown #125

Merged
gnilebein merged 1 commits from feature/scale-no-answer into main 2026-11-21 13:09:44 +01:00
8 changed files with 49 additions and 18 deletions

No files matched your search

+3 -2
View File
@@ -146,8 +146,9 @@ 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.
- **Nur Kommentar ohne Bewertung** (Skala/Sterne mit Setting `comments`): die Bewertung ist dann nicht mehr Pflicht (die Radios sind nicht `required`), - **Nur Kommentar ohne Bewertung** (Skala/Sterne, Setting `comment_only` zusätzlich zu `comments`, `Slide::hasCommentOnly()`; im Formular ein Dropdown
ein nicht leerer Kommentar genügt. `VoteService::scaleRows()` speichert eine Zeile **ohne** `numeric_value`: zählt als Teilnahme (einmal pro Person), `comment_mode`: kein Kommentarfeld | Kommentar optional, Bewertung Pflicht | auch Kommentar ohne Bewertung genügt, `SlidesTable::sanitizeSettings()` übersetzt es in
`comments`/`comment_only`): die Bewertung ist dann nicht mehr Pflicht (die Radios sind nicht `required`), ein nicht leerer Kommentar genügt. `VoteService::scaleRows()` speichert eine Zeile **ohne** `numeric_value`: zählt als Teilnahme (einmal pro Person),
geht aber nicht in Verteilung und Durchschnitt ein. Weder Bewertung noch Kommentar = Fehler, es gibt keinen leeren „Überspringen“-Knopf. geht aber nicht in Verteilung und Durchschnitt ein. Weder Bewertung noch Kommentar = Fehler, es gibt keinen leeren „Überspringen“-Knopf.
`ResultsService::scaleResults()` liefert die Zahl als `commentOnly` (Bühne: „· N× nur Kommentar“, Auswertung, PDF; private Folien strippen sie `ResultsService::scaleResults()` liefert die Zahl als `commentOnly` (Bühne: „· N× nur Kommentar“, Auswertung, PDF; private Folien strippen sie
mit `withoutContents()`). Der Kommentar läuft wie die anderen durch, `value` ist `null` (mit `comment_ratings` zeigt die Bühne „Ohne Bewertung“, damit mit `withoutContents()`). Der Kommentar läuft wie die anderen durch, `value` ist `null` (mit `comment_ratings` zeigt die Bühne „Ohne Bewertung“, damit
+12 -2
View File
@@ -123,7 +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
// with comments, participants may also send only a comment (row without numeric_value, not part of the average) // comment_only: with comments, a comment alone is enough (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);
@@ -131,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_only' => false, 'comment_ratings' => false,
'scale_view' => self::SCALE_VIEW_BOTH, 'scale_view' => self::SCALE_VIEW_BOTH,
'time_limit' => 0, 'time_limit' => 0,
], ],
@@ -636,6 +636,16 @@ class Slide extends Entity
return in_array($this->type, [self::TYPE_CHOICE, self::TYPE_SCALE], true) && (bool)$this->setting('comments'); return in_array($this->type, [self::TYPE_CHOICE, self::TYPE_SCALE], true) && (bool)$this->setting('comments');
} }
/**
* Scale with a comment field where a comment alone is enough (the rating is optional).
*
* @return bool
*/
public function hasCommentOnly(): bool
{
return $this->type === self::TYPE_SCALE && $this->hasComments() && (bool)$this->setting('comment_only');
}
/** /**
* Scale shown as a star rating (1 to scale_max stars) instead of numbered steps. * Scale shown as a star rating (1 to scale_max stars) instead of numbered steps.
* *
+8 -1
View File
@@ -175,7 +175,14 @@ class SlidesTable extends Table
$settings['min_label'] = mb_substr(trim((string)($input['min_label'] ?? '')), 0, 60); $settings['min_label'] = mb_substr(trim((string)($input['min_label'] ?? '')), 0, 60);
$settings['max_label'] = mb_substr(trim((string)($input['max_label'] ?? '')), 0, 60); $settings['max_label'] = mb_substr(trim((string)($input['max_label'] ?? '')), 0, 60);
$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); // Form: one dropdown (off|rating|only); the plain flags `comments`/`comment_only` stay accepted
$mode = $input['comment_mode'] ?? match (true) {
!filter_var($input['comments'] ?? false, FILTER_VALIDATE_BOOLEAN) => 'off',
filter_var($input['comment_only'] ?? false, FILTER_VALIDATE_BOOLEAN) => 'only',
default => 'rating',
};
$settings['comments'] = in_array($mode, ['rating', 'only'], true);
$settings['comment_only'] = $mode === 'only';
$settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN); $settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? 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;
+1 -1
View File
@@ -686,7 +686,7 @@ class VoteService
*/ */
protected function scaleRows(Slide $slide, array $data): array protected function scaleRows(Slide $slide, array $data): array
{ {
if (self::stringField($data, 'value') === '' && $slide->hasComments()) { if (self::stringField($data, 'value') === '' && $slide->hasCommentOnly()) {
// Comment only: no rating, but a comment is required (this is not a way to skip). // Comment only: no rating, but a comment is required (this is not a way to skip).
$comment = self::comment($data); $comment = self::comment($data);
if ($comment === null) { if ($comment === null) {
+5 -3
View File
@@ -309,7 +309,7 @@ $countdown = function (?int $remaining): string {
<div class="stars<?= $maxValue > 6 ? ' stars--many' : '' ?>" role="radiogroup" aria-label="<?= __('Bewertung in Sternen') ?>"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>> <div class="stars<?= $maxValue > 6 ? ' stars--many' : '' ?>" role="radiogroup" aria-label="<?= __('Bewertung in Sternen') ?>"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
<?php for ($v = 1; $v <= $maxValue; $v++) : ?> <?php for ($v = 1; $v <= $maxValue; $v++) : ?>
<label class="stars__star"> <label class="stars__star">
<input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasComments() ? '' : 'required' ?>> <input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasCommentOnly() ? '' : 'required' ?>>
<span class="stars__icon" aria-hidden="true">★</span> <span class="stars__icon" aria-hidden="true">★</span>
<span class="sr-only"><?= __('{0} von {1} Sternen', $v, $maxValue) ?></span> <span class="sr-only"><?= __('{0} von {1} Sternen', $v, $maxValue) ?></span>
</label> </label>
@@ -319,7 +319,7 @@ $countdown = function (?int $remaining): string {
<div class="scale"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>> <div class="scale"<?= $slide->isPrivate() ? ' aria-describedby="private-hint"' : '' ?>>
<?php for ($v = (int)$slide->setting('scale_min'); $v <= $maxValue; $v++) : ?> <?php for ($v = (int)$slide->setting('scale_min'); $v <= $maxValue; $v++) : ?>
<label class="scale__step"> <label class="scale__step">
<input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasComments() ? '' : 'required' ?>> <input type="radio" name="value" value="<?= $v ?>" <?= $slide->hasCommentOnly() ? '' : 'required' ?>>
<span><?= $v ?></span> <span><?= $v ?></span>
</label> </label>
<?php endfor; ?> <?php endfor; ?>
@@ -331,7 +331,9 @@ $countdown = function (?int $remaining): string {
</div> </div>
<?php if ($slide->hasComments()) : ?> <?php if ($slide->hasComments()) : ?>
<label class="scale-comment" for="scale-comment"><?= __('Kommentar (optional)') ?></label> <label class="scale-comment" for="scale-comment"><?= __('Kommentar (optional)') ?></label>
<p class="hint"><?= __('Du kannst auch nur einen Kommentar abgeben, ohne zu bewerten.') ?></p> <?php if ($slide->hasCommentOnly()) : ?>
<p class="hint"><?= __('Du kannst auch nur einen Kommentar abgeben, ohne zu bewerten.') ?></p>
<?php endif; ?>
<textarea id="scale-comment" name="comment" rows="3" maxlength="500" <textarea id="scale-comment" name="comment" rows="3" maxlength="500"
placeholder="<?= __('Möchtest du deine Bewertung begründen?') ?>"></textarea> placeholder="<?= __('Möchtest du deine Bewertung begründen?') ?>"></textarea>
<?php endif; ?> <?php endif; ?>
+9 -4
View File
@@ -206,10 +206,15 @@ $optionsError = $slide->getError('options_text');
'value' => $settings['scale_view'], 'value' => $settings['scale_view'],
]) ?> ]) ?>
<p class="hint"><?= __('Die Auswertung in der Verwaltung und der PDF-Export enthalten immer beides.') ?></p> <p class="hint"><?= __('Die Auswertung in der Verwaltung und der PDF-Export enthalten immer beides.') ?></p>
<?= $this->Form->control('settings.comments', [ <?= $this->Form->control('settings.comment_mode', [
'type' => 'checkbox', 'type' => 'select',
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen oder auch nur einen Kommentar ohne Bewertung abgeben)'), 'label' => __('Kommentarfeld'),
'checked' => (bool)$settings['comments'], 'options' => [
'off' => __('Kein Kommentarfeld'),
'rating' => __('Kommentar optional, die Bewertung ist Pflicht'),
'only' => __('Kommentar optional, auch ein Kommentar ohne Bewertung genügt'),
],
'value' => empty($settings['comments']) ? 'off' : (empty($settings['comment_only']) ? 'rating' : 'only'),
]) ?> ]) ?>
<p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden), jeder so lange, wie man zum Lesen braucht: kurze etwa 5 Sekunden, lange bis zu 30 Sekunden. Das Tempo stellst du für die ganze Umfrage in den Einstellungen im Dashboard ein. Bei internem Feedback erst, wenn du die Ergebnisse einblendest.') ?></p> <p class="hint"><?= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden), jeder so lange, wie man zum Lesen braucht: kurze etwa 5 Sekunden, lange bis zu 30 Sekunden. Das Tempo stellst du für die ganze Umfrage in den Einstellungen im Dashboard ein. Bei internem Feedback erst, wenn du die Ergebnisse einblendest.') ?></p>
<?= $this->Form->control('settings.comment_ratings', [ <?= $this->Form->control('settings.comment_ratings', [
@@ -246,6 +246,12 @@ class ParticipateControllerTest extends TestCase
$this->goLive($poll, $slide); $this->goLive($poll, $slide);
$this->cookie('plenario_pid', self::PID); $this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code); $this->get('/p/' . $poll->join_code);
$this->assertResponseNotContains('auch nur einen Kommentar');
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true, 'comment_only' => true]]);
$this->goLive($poll, $slide);
$this->cookie('plenario_pid', self::PID);
$this->get('/p/' . $poll->join_code);
$this->assertResponseContains('auch nur einen Kommentar'); $this->assertResponseContains('auch nur einen Kommentar');
$this->assertResponseNotContains('required>'); $this->assertResponseNotContains('required>');
+5 -5
View File
@@ -74,7 +74,7 @@ class VoteServiceTest extends TestCase
public function testScaleCommentOnlyCountsAsParticipantButNotInAverage(): void public function testScaleCommentOnlyCountsAsParticipantButNotInAverage(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'comments' => true]]); $slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['scale_min' => 1, 'scale_max' => 5, 'comments' => true, 'comment_only' => true]]);
$poll = $this->goLive($poll, $slide); $poll = $this->goLive($poll, $slide);
$service = new VoteService(); $service = new VoteService();
$service->submit($poll, $slide, 'p1', ['value' => '4']); $service->submit($poll, $slide, 'p1', ['value' => '4']);
@@ -93,10 +93,10 @@ class VoteServiceTest extends TestCase
$service->submit($poll, $slide, 'p2', ['value' => '2']); $service->submit($poll, $slide, 'p2', ['value' => '2']);
} }
public function testScaleWithoutRatingNeedsCommentField(): void public function testScaleWithoutRatingNeedsCommentOnlySetting(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE); $slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]);
$poll = $this->goLive($poll, $slide); $poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('zwischen 1 und 5'); $this->expectExceptionMessage('zwischen 1 und 5');
@@ -106,7 +106,7 @@ class VoteServiceTest extends TestCase
public function testScaleNeedsRatingOrComment(): void public function testScaleNeedsRatingOrComment(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]); $slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true, 'comment_only' => true]]);
$poll = $this->goLive($poll, $slide); $poll = $this->goLive($poll, $slide);
$this->expectExceptionMessage('oder schreibe einen Kommentar'); $this->expectExceptionMessage('oder schreibe einen Kommentar');
@@ -116,7 +116,7 @@ class VoteServiceTest extends TestCase
public function testCommentOnlyAnswerCanBeEditedButNotEmptied(): void public function testCommentOnlyAnswerCanBeEditedButNotEmptied(): void
{ {
[$poll] = $this->createPoll(); [$poll] = $this->createPoll();
$slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true]]); $slide = $this->createSlide($poll, Slide::TYPE_SCALE, ['settings' => ['comments' => true, 'comment_only' => true]]);
$poll = $this->goLive($poll, $slide); $poll = $this->goLive($poll, $slide);
$service = new VoteService(); $service = new VoteService();
$service->submit($poll, $slide, 'p1', ['comment' => 'Erst']); $service->submit($poll, $slide, 'p1', ['comment' => 'Erst']);