From e6f52a0449960383ad0f0b4904a89418d8f7da33 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Wed, 11 Nov 2026 11:40:24 +0100 Subject: [PATCH] Show a progress bar until the next scale comment Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 8 ++++++-- webroot/js/plenario.js | 42 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1c963ca..e51b98a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -60,7 +60,7 @@ src/ AdminController Dashboard, Settings, Present, State-JSON, Control, QR, PDF-Export, Token rotieren, Zurücksetzen, Löschen SlidesController Folien-CRUD, Antworten offener Fragen bzw. Skala-Auswertung (`answers`), Sortieren (Drag & Drop/Pfeiltasten via `reorder`, JSON; erfordert JS), Antworten zurücksetzen, YouTube-Link prüfen (`youtubeCheck`, JSON) - ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen; anonymes Cookie plenario_pid + ParticipateController /p/{code}: Ansicht, State-JSON, Abstimmen, eigenen Skala-Kommentar bearbeiten; anonymes Cookie plenario_pid EmbedController /e/{key}/{id}: eine Folie zum Einbetten (z. B. Canva), activate/heartbeat/pause/control ErrorController Fehlerseiten (Templates unter templates/Error, Layout `error`) Mailer/ PollMailer (adminLink, recovery; `sendSafely()` loggt Transportfehler statt zu werfen), Transport/FileTransport (lokal) @@ -216,8 +216,12 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures `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: `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, + 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, wenn der Presenter die Ergebnisse einblendet. + Teilnehmende können ihren eigenen Kommentar ändern, ergänzen oder leeren, solange die Abstimmung offen ist + (`participate:comment` → `VoteService::editComment()`, gleiche Vorbedingungen wie `submit()`, in der Folien-Sperre); + die Bewertung selbst bleibt unveränderlich. - **PDF-Export** (`/admin/{token}/export.pdf`, `admin:export`, `ReportService` + `PdfView`, Dompdf): Ergebnisse aller interaktiven Folien (Inhaltsfolien/YouTube fehlen). Standard ist die Fassung **ohne interne Inhalte**: private Folien diff --git a/webroot/js/plenario.js b/webroot/js/plenario.js index 652058d..c8d97ec 100644 --- a/webroot/js/plenario.js +++ b/webroot/js/plenario.js @@ -303,6 +303,9 @@ timer: null, items: [], node: null, + // Countdown of the comment shown (drives the progress bar across re-renders). + startedAt: 0, + duration: 0, // Time per comment: enough to read it on the stage, within sensible bounds. BASE_MS: 2500, @@ -338,6 +341,10 @@ el('p', { class: 'comments__counter', 'data-comment-counter': '' }), el('blockquote', { class: 'comments__text', 'data-comment-text': '' }), el('p', { class: 'comments__value', 'data-comment-value': '' }), + // Time left until the next comment; decorative, the counter carries the information. + items.length < 2 ? null : el('div', { class: 'comments__progress', 'data-comment-progress': '', 'aria-hidden': 'true' }, [ + el('div', { class: 'comments__progress-fill' }) + ]), items.length < 2 ? null : el('div', { class: 'comments__nav' }, [ button('prev', 'Vorheriger Kommentar', '‹'), button('toggle', '', ''), @@ -360,10 +367,10 @@ Comments.update(false); }); Comments.node = node; - Comments.update(false); if (!Comments.timer) { Comments.restart(); } + Comments.update(false); return node; }, @@ -388,18 +395,44 @@ /** (Re)start the countdown for the comment currently shown. */ restart: function () { clearTimeout(Comments.timer); + Comments.startedAt = Date.now(); + Comments.duration = Comments.delay(Comments.items[Comments.index]); Comments.timer = setTimeout(function () { if (!Comments.node || !document.body.contains(Comments.node)) { // Slide changed: stop until the next comment list is rendered. Comments.timer = null; return; } - if (!Comments.paused && Comments.items.length > 1 && !document.hidden) { + var advance = !Comments.paused && Comments.items.length > 1 && !document.hidden; + if (advance) { Comments.step(1); - Comments.update(true); } Comments.restart(); - }, Comments.delay(Comments.items[Comments.index])); + if (advance) { + Comments.update(true); + } else { + Comments.progress(); + } + }, Comments.duration); + }, + + /** + * Fills the progress bar over the remaining time of the current comment. + * Picks up where it was after a re-render (negative animation delay); hidden while paused. + */ + progress: function () { + var bar = Comments.node && Comments.node.querySelector('[data-comment-progress]'); + if (!bar) { + return; + } + var fill = bar.firstChild; + bar.hidden = Comments.paused; + fill.style.animation = 'none'; + void fill.offsetWidth; // restart the CSS animation + if (!Comments.paused) { + var elapsed = Math.min(Date.now() - Comments.startedAt, Comments.duration); + fill.style.animation = 'comment-progress ' + Comments.duration + 'ms linear -' + elapsed + 'ms forwards'; + } }, update: function (animate) { @@ -427,6 +460,7 @@ toggle.setAttribute('title', label); toggle.setAttribute('aria-pressed', Comments.paused ? 'true' : 'false'); } + Comments.progress(); } };