From 8d128095ed22777c65592278f4698cacfb26c994 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Mon, 9 Nov 2026 14:18:01 +0100 Subject: [PATCH] Drop the comment interval setting Comments on the stage are always timed by their length now, so the selectable interval and results.commentInterval are gone. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 5 ++- src/Model/Entity/Slide.php | 18 ++-------- src/Model/Table/SlidesTable.php | 4 --- src/Service/ResultsService.php | 2 -- templates/Slides/form.php | 17 +--------- .../TestCase/Controller/ScaleCommentsTest.php | 29 ++++------------ webroot/js/plenario.js | 34 ++++++------------- 7 files changed, 23 insertions(+), 86 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index d1e3e56..7297d88 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -200,9 +200,8 @@ 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 sie nie: Skalen liefern ihnen grundsätzlich keine `results`, siehe `PollStateService::forParticipant()`) - (älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch (Sekunden pro Kommentar = Setting `comment_interval`, Auswahl -`Slide::COMMENT_INTERVALS`, im State als `results.commentInterval`; Standard `Slide::COMMENT_INTERVAL_AUTO` (0) = Lesezeit je nach -Textlänge, `Comments.delay()`: 2,5 s + 15 Zeichen/s, 5–30 s; Vor/Zurück/Fortsetzen geben dem Kommentar wieder die volle Zeit; „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 (Anzeigedauer nur nach Textlänge, bewusst ohne Setting: +`Comments.delay()` = 2,5 s + 15 Zeichen/s, 5–30 s; Vor/Zurück/Fortsetzen geben dem Kommentar wieder die volle Zeit; „Kommentar X von N“, vor/zurück/Pause, Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback erscheinen sie erst, wenn der Presenter die Ergebnisse einblendet. diff --git a/src/Model/Entity/Slide.php b/src/Model/Entity/Slide.php index fe7e7ec..a72d00d 100644 --- a/src/Model/Entity/Slide.php +++ b/src/Model/Entity/Slide.php @@ -55,20 +55,6 @@ class Slide extends Entity */ public const QUIZ_TIME_LIMITS = [0, 10, 15, 20, 30, 45, 60, 90, 120, 180, 300]; - /** - * Comment interval "automatic": the presentation derives the time per comment - * from its length (reading speed), see `Comments.delay()` in plenario.js. - */ - public const COMMENT_INTERVAL_AUTO = 0; - - /** - * Selectable seconds per comment when the comments of a scale rotate in the presentation - * (COMMENT_INTERVAL_AUTO = depending on the length of each comment). - * - * @var list - */ - public const COMMENT_INTERVALS = [self::COMMENT_INTERVAL_AUTO, 3, 5, 8, 10, 15, 20, 30, 45, 60]; - /** * Q&A stages, see qaStage(): participants submit questions, then upvote * them, then the presenter discusses them one by one (most upvoted first). @@ -101,10 +87,10 @@ 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 - // comment_interval: seconds per comment while they rotate (one of COMMENT_INTERVALS, 0 = by length) + // (time per comment depends on its length, see Comments.delay() in plenario.js) self::TYPE_SCALE => [ 'scale_min' => 1, 'scale_max' => 5, 'min_label' => '', 'max_label' => '', 'private' => false, - 'comments' => false, 'comment_ratings' => false, 'comment_interval' => self::COMMENT_INTERVAL_AUTO, + '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 6d223d3..54d9cb0 100644 --- a/src/Model/Table/SlidesTable.php +++ b/src/Model/Table/SlidesTable.php @@ -159,10 +159,6 @@ class SlidesTable extends Table $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); - $interval = (int)($input['comment_interval'] ?? $settings['comment_interval']); - if (in_array($interval, Slide::COMMENT_INTERVALS, true)) { - $settings['comment_interval'] = $interval; - } 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 8816cc8..f72f3eb 100644 --- a/src/Service/ResultsService.php +++ b/src/Service/ResultsService.php @@ -22,7 +22,6 @@ use Cake\ORM\Locator\LocatorAwareTrait; * '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: participants never get results of scale slides, see PollStateService); - * 'commentInterval' => int seconds per comment while they rotate, 0 = depending on its length; * open/scale with 'private' (anonymous/internal feedback): contents are included for the * presenter/embed, which start with the results hidden and may show them on demand; * participants never get results of these slides, the public PDF strips them (withoutContents()) @@ -326,7 +325,6 @@ class ResultsService return $this->scaleResults($slide) + [ 'private' => $slide->isPrivate(), 'comments' => $comments, - 'commentInterval' => (int)$slide->setting('comment_interval'), ]; } diff --git a/templates/Slides/form.php b/templates/Slides/form.php index 3e0f1e3..6d91f93 100644 --- a/templates/Slides/form.php +++ b/templates/Slides/form.php @@ -171,22 +171,7 @@ $optionsError = $slide->getError('options_text'); 'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'), 'checked' => (bool)$settings['comments'], ]) ?> -

- Form->control('settings.comment_interval', [ - 'type' => 'select', - 'options' => array_combine( - \App\Model\Entity\Slide::COMMENT_INTERVALS, - array_map( - fn(int $s) => $s === \App\Model\Entity\Slide::COMMENT_INTERVAL_AUTO - ? __('automatisch (je nach Länge des Kommentars)') - : __n('{0} Sekunde', '{0} Sekunden', $s, $s), - \App\Model\Entity\Slide::COMMENT_INTERVALS, - ), - ), - 'label' => __('Nächster Kommentar nach'), - 'value' => $settings['comment_interval'], - ]) ?> -

+

Form->control('settings.comment_ratings', [ 'type' => 'checkbox', 'label' => __('Bewertung beim Kommentar in der Präsentation anzeigen'), diff --git a/tests/TestCase/Controller/ScaleCommentsTest.php b/tests/TestCase/Controller/ScaleCommentsTest.php index da97773..af62f10 100644 --- a/tests/TestCase/Controller/ScaleCommentsTest.php +++ b/tests/TestCase/Controller/ScaleCommentsTest.php @@ -154,33 +154,18 @@ class ScaleCommentsTest extends TestCase $this->assertSame([4, 3], array_column($this->presenterResults($token)['comments'], 'value')); } - public function testCommentIntervalIsConfigurable(): void + public function testCommentIntervalIsNotConfigurable(): void { - $auto = Slide::COMMENT_INTERVAL_AUTO; - $this->assertSame($auto, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, [])['comment_interval']); - $this->assertSame(15, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '15'])['comment_interval']); - $this->assertSame($auto, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '0'])['comment_interval']); - $this->assertSame($auto, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '7'])['comment_interval']); - $this->assertSame($auto, SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '-1'])['comment_interval']); - - [, $token] = $this->scaleWithComments(['comment_interval' => 20]); - $this->assertSame(20, $this->presenterResults($token)['commentInterval']); + // The presentation times each comment by its length; there is no setting for it. + $settings = SlidesTable::sanitizeSettings(Slide::TYPE_SCALE, ['comment_interval' => '15']); + $this->assertArrayNotHasKey('comment_interval', $settings); [, $token] = $this->scaleWithComments(); - $this->assertSame($auto, $this->presenterResults($token)['commentInterval']); + $this->assertArrayNotHasKey('commentInterval', $this->presenterResults($token)); - $this->get("/admin/$token"); - $this->assertResponseOk(); - } - - public function testFormShowsCommentInterval(): void - { - [, $token] = $this->createPoll(); $this->get("/admin/$token/slides/add?type=scale"); - - $this->assertResponseContains('name="settings[comment_interval]"'); - $this->assertResponseContains('15 Sekunden'); - $this->assertResponseContains('automatisch (je nach Länge des Kommentars)'); + $this->assertResponseOk(); + $this->assertResponseNotContains('comment_interval'); } public function testParticipantsNeverSeeComments(): void diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index f1f4380..214f873 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -297,7 +297,6 @@ * so position, pause and timer live here and survive the re-render. */ var Comments = { - seconds: 0, key: null, index: 0, paused: false, @@ -305,17 +304,16 @@ items: [], node: null, - // Automatic interval: time to read the comment on the stage, within sensible bounds. - AUTO_BASE_MS: 2500, - AUTO_CHARS_PER_SECOND: 15, - AUTO_MIN_MS: 5000, - AUTO_MAX_MS: 30000, + // Time per comment: enough to read it on the stage, within sensible bounds. + BASE_MS: 2500, + CHARS_PER_SECOND: 15, + MIN_MS: 5000, + MAX_MS: 30000, /** * @param {Array} items comments, oldest first - * @param {number} [seconds] time per comment (slide setting), 0 = depending on its length */ - render: function (items, seconds) { + render: function (items) { // A different first comment means a different slide (or a reset): start over. var key = String(items[0].id); if (key !== Comments.key) { @@ -323,13 +321,6 @@ Comments.index = 0; Comments.paused = false; } - seconds = seconds > 0 ? seconds : 0; - if (seconds !== Comments.seconds) { - // Setting changed (or another slide): apply it right away. - Comments.seconds = seconds; - clearTimeout(Comments.timer); - Comments.timer = null; - } Comments.items = items; Comments.index = Math.min(Comments.index, items.length - 1); @@ -382,19 +373,16 @@ }, /** - * How long a comment stays on the stage: the fixed setting, or (automatic) - * a base time plus reading time for its length, between AUTO_MIN_MS and AUTO_MAX_MS. + * How long a comment stays on the stage: a base time plus reading time + * for its length, between MIN_MS and MAX_MS. * * @param {Object} item comment * @return {number} milliseconds */ delay: function (item) { - if (Comments.seconds > 0) { - return Comments.seconds * 1000; - } var length = item && item.text ? Array.from(item.text).length : 0; - var ms = Comments.AUTO_BASE_MS + length / Comments.AUTO_CHARS_PER_SECOND * 1000; - return Math.round(Math.min(Comments.AUTO_MAX_MS, Math.max(Comments.AUTO_MIN_MS, ms))); + var ms = Comments.BASE_MS + length / Comments.CHARS_PER_SECOND * 1000; + return Math.round(Math.min(Comments.MAX_MS, Math.max(Comments.MIN_MS, ms))); }, /** (Re)start the countdown for the comment currently shown. */ @@ -553,7 +541,7 @@ ]), gauge ]); - var comments = results.comments && results.comments.length ? Comments.render(results.comments, results.commentInterval) : null; + var comments = results.comments && results.comments.length ? Comments.render(results.comments) : null; return el('div', { class: 'scale-results' }, [average, columns, labels, comments]); }, -- 2.54.1