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'], ]) ?>

+ Form->control('settings.comment_ratings', [ + 'type' => 'checkbox', + 'label' => __('Bewertung beim Kommentar in der Präsentation anzeigen'), + 'checked' => (bool)$settings['comment_ratings'], + ]) ?> 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 ', 'Zu lang'], array_column($results['comments'], 'text')); - $this->assertSame([4, 3], array_column($results['comments'], 'value')); + $this->assertSame([null, null], array_column($results['comments'], 'value')); + } + + public function testRatingsNextToCommentsAreOptional(): void + { + $this->assertTrue(SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_ratings' => '1'])['comment_ratings']); + $this->assertFalse(SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, [])['comment_ratings']); + + [, $token] = $this->scaleWithComments(['comment_ratings' => true]); + + $this->assertSame([4, 3], array_column($this->presenterResults($token)['comments'], 'value')); } public function testParticipantsNeverSeeComments(): void diff --git a/webroot/css/plenario.css b/webroot/css/plenario.css index ae67aa1..f8b407d 100644 --- a/webroot/css/plenario.css +++ b/webroot/css/plenario.css @@ -579,11 +579,12 @@ body.present { .stage--closed .stage__type::after { content: " · Abstimmung geschlossen"; color: var(--muted); } .stage .bar__track { height: 1.1em; } .stage .columns { height: 34vh; } -.stage .average { padding: 2vh 2.5vw; gap: 2vh 4vw; background: rgba(var(--tint), .06); } -.stage .average__value strong { font-size: clamp(4rem, 9vw, 8rem); } -.stage .average__of { font-size: clamp(1.6rem, 3vw, 2.8rem); } -.stage .average__label, .stage .average__count, .stage .average__ends { font-size: clamp(.9rem, 1.4vw, 1.3rem); } -.stage .average__track { height: 1em; box-shadow: none; background: linear-gradient(90deg, var(--surface-2), var(--c1)); } +.stage .average { padding: 1vh 2vw; gap: 1vh 3vw; margin-bottom: 1.5vh; background: rgba(var(--tint), .06); } +.stage .average__value strong { font-size: clamp(2.6rem, 5vw, 4.5rem); } +.stage .average__of { font-size: clamp(1.2rem, 2vw, 1.8rem); } +.stage .average__label, .stage .average__count, .stage .average__ends { font-size: clamp(.85rem, 1.2vw, 1.1rem); } +.stage .average__track { height: .7em; box-shadow: none; background: linear-gradient(90deg, var(--surface-2), var(--c1)); } +.stage .average__ends { margin-top: 4px; } .stage .cloud { font-size: clamp(1.4rem, 2.6vw, 2.6rem); } .stage .answers { columns: 340px; } .stage .quiz-timer { font-size: clamp(3rem, 7vw, 6rem); } diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index 0c79b29..37b44ba 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -386,7 +386,9 @@ node.querySelector('[data-comment-counter]').textContent = 'Kommentar ' + (Comments.index + 1) + ' von ' + Comments.items.length; text.textContent = item.text; - node.querySelector('[data-comment-value]').textContent = 'Bewertung: ' + item.value; + var value = node.querySelector('[data-comment-value]'); + value.textContent = item.value === null || item.value === undefined ? '' : 'Bewertung: ' + item.value; + value.hidden = value.textContent === ''; // Only announce changes the viewer triggered, not every automatic rotation. node.setAttribute('aria-live', Comments.paused ? 'polite' : 'off'); text.classList.remove('is-entering');