Let each poll speed up or slow down the scale comments
CI / Deploy / test (push) Successful in 1m12s
CI / Deploy / deploy (push) Skipped

A new poll setting (polls.comment_speed, 50-200 %) scales the display
time of the rotating scale comments in the presentation and embed; the
duration still follows the text length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 12:51:08 +01:00
1 parent c1f9be2eef
commit 166cb475c6
10 files changed
+100 -6

No files matched your search

+4 -3
View File
@@ -93,7 +93,7 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
`join_code` (6 Zeichen, ohne 0/O/1/I/L), `current_slide_id`, `is_active`, `join_code` (6 Zeichen, ohne 0/O/1/I/L), `current_slide_id`, `is_active`,
`last_admin_access` (höchstens alle 10 min aktualisiert, Grundlage für ein künftiges Aufräumen alter Umfragen), `last_admin_access` (höchstens alle 10 min aktualisiert, Grundlage für ein künftiges Aufräumen alter Umfragen),
`embed_key` (Einbett-Schlüssel), `embed_seen_at` (letztes Lebenszeichen der eingebetteten Live-Folie), `embed_key` (Einbett-Schlüssel), `embed_seen_at` (letztes Lebenszeichen der eingebetteten Live-Folie),
`paused_slide_id` (Folie vor der Pause) `paused_slide_id` (Folie vor der Pause), `comment_speed` (Tempo der Skala-Kommentare in Prozent, Standard 100)
- `slides`: `type` (`choice|wordcloud|open|scale|content|quiz|youtube|qa|order`), `question`, `description`, `position`, - `slides`: `type` (`choice|wordcloud|open|scale|content|quiz|youtube|qa|order`), `question`, `description`, `position`,
`settings` (JSON, je Typ siehe `Slide::DEFAULT_SETTINGS`), `is_voting_open`, `settings` (JSON, je Typ siehe `Slide::DEFAULT_SETTINGS`), `is_voting_open`,
`voting_started_at` / `voting_ends_at` (nur Quiz: Start und Deadline, `null` = manuell beenden), `voting_started_at` / `voting_ends_at` (nur Quiz: Start und Deadline, `null` = manuell beenden),
@@ -221,8 +221,9 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures
- **Skala-Kommentare** (Setting `comments`, `Slide::hasComments()`): optionales Feld `comment`, gespeichert als `text_value` - **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 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()`) `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 (Anzeigedauer nur nach Textlänge, bewusst ohne Setting: (älteste zuerst, je `id`, `text`, `value` – `value` nur mit Setting `comment_ratings`, sonst `null`); `Comments` in `plenario.js` blättert sie automatisch durch (Anzeigedauer nach Textlänge, kein Setting pro Folie:
`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“, `Comments.delay()` = 2,5 s + 15 Zeichen/s, 5–30 s, geteilt durch das Tempo der Umfrage `polls.comment_speed` (Prozent aus
`Poll::COMMENT_SPEEDS`, im State `poll.commentSpeed` als Faktor, Dashboard → „Einstellungen“); Vor/Zurück/Fortsetzen geben dem Kommentar wieder die volle Zeit; „Kommentar X von N“,
vor/zurück/Pause, Laufbalken bis zum Wechsel (`Comments.progress()`, setzt nach dem Neu-Rendern per negativem vor/zurück/Pause, Laufbalken bis zum Wechsel (`Comments.progress()`, setzt nach dem Neu-Rendern per negativem
`animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback erscheinen sie erst, `animation-delay` fort, bei Pause unsichtbar), Zustand übersteht das Neu-Rendern beim Polling). Bei internem Feedback erscheinen sie erst,
wenn der Presenter die Ergebnisse einblendet. wenn der Presenter die Ergebnisse einblendet.
@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
use Migrations\BaseMigration;
/**
* Speed of the rotating scale comments in the presentation, per poll in percent
* (100 = normal, below = slower, above = faster), see Poll::COMMENT_SPEEDS.
*/
class AddCommentSpeedToPolls extends BaseMigration
{
/**
* @return void
*/
public function up(): void
{
$table = $this->table('polls');
if (!$table->hasColumn('comment_speed')) {
$table->addColumn('comment_speed', 'integer', [
'null' => false,
'default' => 100,
'after' => 'is_active',
])->update();
}
}
/**
* @return void
*/
public function down(): void
{
$table = $this->table('polls');
if ($table->hasColumn('comment_speed')) {
$table->removeColumn('comment_speed')->update();
}
}
}
+1 -1
View File
@@ -69,7 +69,7 @@ class AdminController extends AdminAppController
{ {
$this->request->allowMethod(['post']); $this->request->allowMethod(['post']);
$this->Polls->patchEntity($this->poll, (array)$this->request->getData(), [ $this->Polls->patchEntity($this->poll, (array)$this->request->getData(), [
'fields' => ['title', 'is_active'], 'fields' => ['title', 'is_active', 'comment_speed'],
]); ]);
if ($this->Polls->save($this->poll)) { if ($this->Polls->save($this->poll)) {
$this->Flash->success(__('Einstellungen gespeichert.')); $this->Flash->success(__('Einstellungen gespeichert.'));
+10
View File
@@ -18,6 +18,7 @@ use Cake\ORM\Entity;
* @property \Cake\I18n\DateTime|null $embed_seen_at * @property \Cake\I18n\DateTime|null $embed_seen_at
* @property int|null $paused_slide_id * @property int|null $paused_slide_id
* @property bool $is_active * @property bool $is_active
* @property int $comment_speed Speed of rotating scale comments in percent, see COMMENT_SPEEDS
* @property \Cake\I18n\DateTime|null $last_admin_access * @property \Cake\I18n\DateTime|null $last_admin_access
* @property \Cake\I18n\DateTime $created * @property \Cake\I18n\DateTime $created
* @property \Cake\I18n\DateTime $modified * @property \Cake\I18n\DateTime $modified
@@ -25,6 +26,14 @@ use Cake\ORM\Entity;
*/ */
class Poll extends Entity class Poll extends Entity
{ {
/**
* Selectable speeds of the rotating scale comments in percent: 100 = normal,
* below = each comment stays longer, above = shorter (see Comments.delay() in plenario.js).
*
* @var list<int>
*/
public const COMMENT_SPEEDS = [50, 75, 100, 125, 150, 200];
/** /**
* Only harmless fields are mass assignable. Tokens, join code and the * Only harmless fields are mass assignable. Tokens, join code and the
* current slide are always set explicitly in code. * current slide are always set explicitly in code.
@@ -35,6 +44,7 @@ class Poll extends Entity
'title' => true, 'title' => true,
'email' => true, 'email' => true,
'is_active' => true, 'is_active' => true,
'comment_speed' => true,
]; ];
/** /**
+4
View File
@@ -74,6 +74,10 @@ class PollsTable extends Table
$validator->boolean('is_active'); $validator->boolean('is_active');
$validator
->integer('comment_speed')
->inList('comment_speed', Poll::COMMENT_SPEEDS, __('Bitte wähle eine der angebotenen Geschwindigkeiten.'));
return $validator; return $validator;
} }
+2
View File
@@ -361,6 +361,8 @@ class PollStateService
'joinCodeFormatted' => $poll->formattedJoinCode(), 'joinCodeFormatted' => $poll->formattedJoinCode(),
'isActive' => $poll->is_active, 'isActive' => $poll->is_active,
'isPaused' => $poll->isPaused(), 'isPaused' => $poll->isPaused(),
// Factor for the rotating scale comments on stage (1 = normal, 2 = twice as fast)
'commentSpeed' => ($poll->comment_speed ?? 100) / 100,
]; ];
} }
+14
View File
@@ -228,6 +228,20 @@ $hasInternal = array_filter($slides, fn($slide) => $slide->isInteractive() && $s
'type' => 'checkbox', 'type' => 'checkbox',
'label' => __('Umfrage ist aktiv (Teilnehmende können abstimmen)'), 'label' => __('Umfrage ist aktiv (Teilnehmende können abstimmen)'),
]) ?> ]) ?>
<?= $this->Form->control('comment_speed', [
'type' => 'select',
'label' => __('Tempo der Kommentare in der Präsentation'),
'options' => [
50 => __('Viel langsamer (doppelt so lange)'),
75 => __('Langsamer'),
100 => __('Normal'),
125 => __('Schneller'),
150 => __('Deutlich schneller'),
200 => __('Sehr schnell (halb so lange)'),
],
'aria-describedby' => 'comment-speed-hint',
]) ?>
<p class="hint" id="comment-speed-hint"><?= __('Gilt für die Kommentare von Skala-Folien, die nacheinander durchlaufen. Die Anzeigedauer richtet sich weiter nach der Textlänge und wird mit diesem Faktor verkürzt oder verlängert.') ?></p>
<?= $this->Form->button(__('Speichern'), ['class' => 'button']) ?> <?= $this->Form->button(__('Speichern'), ['class' => 'button']) ?>
<?= $this->Form->end() ?> <?= $this->Form->end() ?>
</section> </section>
+1 -1
View File
@@ -182,7 +182,7 @@ $optionsError = $slide->getError('options_text');
'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'), 'label' => __('Kommentarfeld anzeigen (Teilnehmende können ihre Bewertung optional begründen)'),
'checked' => (bool)$settings['comments'], 'checked' => (bool)$settings['comments'],
]) ?> ]) ?>
<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. 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', [
'type' => 'checkbox', 'type' => 'checkbox',
'label' => __('Bewertung beim Kommentar in der Präsentation anzeigen'), 'label' => __('Bewertung beim Kommentar in der Präsentation anzeigen'),
@@ -62,6 +62,27 @@ class AdminControllerTest extends TestCase
$this->assertSame('Neu', $this->pollsTable()->get($poll->id)->title); $this->assertSame('Neu', $this->pollsTable()->get($poll->id)->title);
} }
public function testCommentSpeedIsSavedAndSentToThePresenter(): void
{
[$poll, $token] = $this->createPoll();
$this->get("/admin/$token/state");
$this->assertEquals(1, json_decode((string)$this->_response->getBody(), true)['poll']['commentSpeed']);
$this->post("/admin/$token/settings", ['title' => 'Testumfrage', 'is_active' => '1', 'comment_speed' => '150']);
$this->assertSame(150, $this->pollsTable()->get($poll->id)->comment_speed);
$this->get("/admin/$token/state");
$this->assertEquals(1.5, json_decode((string)$this->_response->getBody(), true)['poll']['commentSpeed']);
}
public function testInvalidCommentSpeedIsRejected(): void
{
[$poll, $token] = $this->createPoll();
$this->post("/admin/$token/settings", ['title' => 'Testumfrage', 'is_active' => '1', 'comment_speed' => '1000']);
$this->assertSame(100, $this->pollsTable()->get($poll->id)->comment_speed);
}
public function testTokenOfOtherPollCannotAccessSlides(): void public function testTokenOfOtherPollCannotAccessSlides(): void
{ {
[$pollA] = $this->createPoll('A'); [$pollA] = $this->createPoll('A');
+6 -1
View File
@@ -303,6 +303,8 @@
timer: null, timer: null,
items: [], items: [],
format: String, format: String,
// Speed factor of the poll (state.poll.commentSpeed): 2 = half the time per comment.
speed: 1,
node: null, node: null,
// Countdown of the comment shown (drives the progress bar across re-renders). // Countdown of the comment shown (drives the progress bar across re-renders).
startedAt: 0, startedAt: 0,
@@ -392,7 +394,9 @@
delay: function (item) { delay: function (item) {
var length = item && item.text ? Array.from(item.text).length : 0; var length = item && item.text ? Array.from(item.text).length : 0;
var ms = Comments.BASE_MS + length / Comments.CHARS_PER_SECOND * 1000; 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))); // The poll's speed factor scales the bounds too, so short comments change as well.
var speed = Comments.speed > 0 ? Comments.speed : 1;
return Math.round(Math.min(Comments.MAX_MS, Math.max(Comments.MIN_MS, ms)) / speed);
}, },
/** (Re)start the countdown for the comment currently shown. */ /** (Re)start the countdown for the comment currently shown. */
@@ -1238,6 +1242,7 @@
container.appendChild(Results.privateSummary(state.results)); container.appendChild(Results.privateSummary(state.results));
return; return;
} }
Comments.speed = state.poll && state.poll.commentSpeed;
Results.render(container, slide && slide.isInteractive ? state.results : null, { Results.render(container, slide && slide.isInteractive ? state.results : null, {
onStage: function (stage) { control('stage', { stage: stage }); }, onStage: function (stage) { control('stage', { stage: stage }); },
onQuestion: function (step) { control('question', { step: step }); } onQuestion: function (step) { control('question', { step: step }); }