diff --git a/AGENTS.md b/AGENTS.md index ca553c0..8fbaa4a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -175,7 +175,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures - **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value` in derselben Zeile wie `numeric_value` (ohne Setting wird es ignoriert). Öffentliche Skalen liefern im Presenter-/Embed-State `results.comments` (Teilnehmende bekommen immer `[]`, `PollStateService::participantResults()`) - (älteste zuerst, je `id`, `text`, `value`); `Comments` in `plenario.js` blättert sie automatisch durch („Kommentar X von N“, + (älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch („Kommentar X von N“, vor/zurück/Pause, Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback bleibt `comments` leer, lesbar nur in der Auswertung (`ResultsService::comments()`) und im CSV-Export. diff --git a/src/Model/Entity/Slide.php b/src/Model/Entity/Slide.php index 4f86872..af61d4a 100644 --- a/src/Model/Entity/Slide.php +++ b/src/Model/Entity/Slide.php @@ -85,9 +85,11 @@ class Slide extends Entity // private: anonymous feedback, answers only visible in the admin area (never on the stage) self::TYPE_OPEN => ['private' => false], // private: internal feedback, ratings only visible in the admin area (never on the stage) - // comments: optional comment field, comments rotate on the results (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 self::TYPE_SCALE => [ - 'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false, 'comments' => false, + 'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false, + 'comments' => false, 'comment_ratings' => false, ], self::TYPE_CONTENT => [], // time_limit in seconds, 0 = no limit (presenter ends the quiz) diff --git a/src/Model/Table/SlidesTable.php b/src/Model/Table/SlidesTable.php index 3ccce2e..756b7f5 100644 --- a/src/Model/Table/SlidesTable.php +++ b/src/Model/Table/SlidesTable.php @@ -158,6 +158,7 @@ class SlidesTable extends Table $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); + $settings['comment_ratings'] = filter_var($input['comment_ratings'] ?? false, FILTER_VALIDATE_BOOLEAN); break; case Slide::TYPE_QUIZ: $limit = (int)($input['time_limit'] ?? $settings['time_limit']); diff --git a/src/Service/ResultsService.php b/src/Service/ResultsService.php index 005a74e..414334e 100644 --- a/src/Service/ResultsService.php +++ b/src/Service/ResultsService.php @@ -20,7 +20,8 @@ use Cake\ORM\Locator\LocatorAwareTrait; * private (anonymous feedback): 'answers' is always empty, texts only via answers() * - scale: 'buckets' => [['value', 'count', 'percent']], 'average' => float|null, * 'min', 'max', 'minLabel', 'maxLabel', 'private' (bool); - * 'comments' => [['id', 'text', 'value']] 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; * presentation only, emptied for participants in PollStateService); * private (internal feedback): 'buckets' and 'comments' are always empty and 'average' null, * ratings and comments only via scaleResults() / comments() @@ -313,10 +314,17 @@ class ResultsService protected function scale(Slide $slide): array { if (!$slide->isPrivate()) { - return $this->scaleResults($slide) + [ - 'private' => false, - 'comments' => $slide->hasComments() ? $this->comments($slide, self::MAX_ANSWERS) : [], - ]; + $showRatings = (bool)$slide->setting('comment_ratings'); + $comments = []; + foreach ($slide->hasComments() ? $this->comments($slide, self::MAX_ANSWERS) : [] as $comment) { + $comments[] = [ + 'id' => $comment['id'], + 'text' => $comment['text'], + 'value' => $showRatings ? $comment['value'] : null, + ]; + } + + return $this->scaleResults($slide) + ['private' => false, 'comments' => $comments]; } return [ diff --git a/templates/Slides/form.php b/templates/Slides/form.php index 4f7903a..cd65a0e 100644 --- a/templates/Slides/form.php +++ b/templates/Slides/form.php @@ -172,6 +172,11 @@ $optionsError = $slide->getError('options_text'); 'checked' => (bool)$settings['comments'], ]) ?>
= __('Die Kommentare laufen in der Präsentation nacheinander durch (nicht bei den Teilnehmenden). Bei internem Feedback siehst du sie nur in der Auswertung.') ?>
+ = $this->Form->control('settings.comment_ratings', [ + 'type' => 'checkbox', + 'label' => __('Bewertung beim Kommentar in der Präsentation anzeigen'), + 'checked' => (bool)$settings['comment_ratings'], + ]) ?> = $this->Form->control('settings.private', [ 'type' => 'checkbox', 'label' => __('Internes Feedback: Ergebnis nicht öffentlich anzeigen'), diff --git a/tests/TestCase/Controller/ScaleCommentsTest.php b/tests/TestCase/Controller/ScaleCommentsTest.php index c0ec1fa..a56daeb 100644 --- a/tests/TestCase/Controller/ScaleCommentsTest.php +++ b/tests/TestCase/Controller/ScaleCommentsTest.php @@ -141,7 +141,17 @@ class ScaleCommentsTest extends TestCase $this->assertSame(3, $results['participants']); $this->assertEqualsWithDelta(3.0, $results['average'], 0.001); $this->assertSame(['Sehr