diff --git a/docs/slide-types.md b/docs/slide-types.md index a1117fa..214b97a 100644 --- a/docs/slide-types.md +++ b/docs/slide-types.md @@ -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`, 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. -- **Nur Kommentar ohne Bewertung** (Skala/Sterne mit Setting `comments`): 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), +- **Nur Kommentar ohne Bewertung** (Skala/Sterne, Setting `comment_only` zusätzlich zu `comments`, `Slide::hasCommentOnly()`; im Formular ein Dropdown + `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. `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 diff --git a/src/Model/Entity/Slide.php b/src/Model/Entity/Slide.php index f5d241e..634e913 100644 --- a/src/Model/Entity/Slide.php +++ b/src/Model/Entity/Slide.php @@ -123,7 +123,7 @@ class Slide extends Entity // 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) // 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) // 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); @@ -131,7 +131,7 @@ class Slide extends Entity self::TYPE_SCALE => [ 'style' => self::SCALE_NUMBERS, '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, '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'); } + /** + * 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. * diff --git a/src/Model/Table/SlidesTable.php b/src/Model/Table/SlidesTable.php index c45bc25..d725f09 100644 --- a/src/Model/Table/SlidesTable.php +++ b/src/Model/Table/SlidesTable.php @@ -175,7 +175,14 @@ class SlidesTable extends Table $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['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); $view = $input['scale_view'] ?? null; $settings['scale_view'] = in_array($view, Slide::SCALE_VIEWS, true) ? $view : Slide::SCALE_VIEW_BOTH; diff --git a/src/Service/VoteService.php b/src/Service/VoteService.php index 5aaa9e2..5a64543 100644 --- a/src/Service/VoteService.php +++ b/src/Service/VoteService.php @@ -686,7 +686,7 @@ class VoteService */ 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 = self::comment($data); if ($comment === null) { diff --git a/templates/Participate/view.php b/templates/Participate/view.php index c0836ec..6f26767 100644 --- a/templates/Participate/view.php +++ b/templates/Participate/view.php @@ -309,7 +309,7 @@ $countdown = function (?int $remaining): string {
isPrivate() ? ' aria-describedby="private-hint"' : '' ?>> @@ -319,7 +319,7 @@ $countdown = function (?int $remaining): string {
isPrivate() ? ' aria-describedby="private-hint"' : '' ?>> setting('scale_min'); $v <= $maxValue; $v++) : ?> @@ -331,7 +331,9 @@ $countdown = function (?int $remaining): string {
hasComments()) : ?> -

+ hasCommentOnly()) : ?> +

+ diff --git a/templates/Slides/form.php b/templates/Slides/form.php index cc092ff..20fd66c 100644 --- a/templates/Slides/form.php +++ b/templates/Slides/form.php @@ -206,10 +206,15 @@ $optionsError = $slide->getError('options_text'); 'value' => $settings['scale_view'], ]) ?>

- Form->control('settings.comments', [ - 'type' => 'checkbox', - 'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen oder auch nur einen Kommentar ohne Bewertung abgeben)'), - 'checked' => (bool)$settings['comments'], + Form->control('settings.comment_mode', [ + 'type' => 'select', + 'label' => __('Kommentarfeld'), + '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'), ]) ?>

Form->control('settings.comment_ratings', [ diff --git a/tests/TestCase/Controller/ParticipateControllerTest.php b/tests/TestCase/Controller/ParticipateControllerTest.php index fef21cb..8fdc5af 100644 --- a/tests/TestCase/Controller/ParticipateControllerTest.php +++ b/tests/TestCase/Controller/ParticipateControllerTest.php @@ -246,6 +246,12 @@ class ParticipateControllerTest extends TestCase $this->goLive($poll, $slide); $this->cookie('plenario_pid', self::PID); $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->assertResponseNotContains('required>'); diff --git a/tests/TestCase/Service/VoteServiceTest.php b/tests/TestCase/Service/VoteServiceTest.php index aa8e270..7a4ec51 100644 --- a/tests/TestCase/Service/VoteServiceTest.php +++ b/tests/TestCase/Service/VoteServiceTest.php @@ -74,7 +74,7 @@ class VoteServiceTest extends TestCase public function testScaleCommentOnlyCountsAsParticipantButNotInAverage(): void { [$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); $service = new VoteService(); $service->submit($poll, $slide, 'p1', ['value' => '4']); @@ -93,10 +93,10 @@ class VoteServiceTest extends TestCase $service->submit($poll, $slide, 'p2', ['value' => '2']); } - public function testScaleWithoutRatingNeedsCommentField(): void + public function testScaleWithoutRatingNeedsCommentOnlySetting(): void { [$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); $this->expectExceptionMessage('zwischen 1 und 5'); @@ -106,7 +106,7 @@ class VoteServiceTest extends TestCase public function testScaleNeedsRatingOrComment(): void { [$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); $this->expectExceptionMessage('oder schreibe einen Kommentar'); @@ -116,7 +116,7 @@ class VoteServiceTest extends TestCase public function testCommentOnlyAnswerCanBeEditedButNotEmptied(): void { [$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); $service = new VoteService(); $service->submit($poll, $slide, 'p1', ['comment' => 'Erst']);