Add internal feedback and comments to scale slides
- Setting "private": distribution and average are only shown in the
admin evaluation page and CSV export, the stage shows just the count.
- Setting "comments": optional comment field for participants; on public
scales the comments rotate on the results ("Kommentar X von N") with
previous/next/pause controls.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a138425ab0
commit
238797ecfd
15 files changed
+665
-23
No files matched your search
@@ -512,6 +512,28 @@ button.qa-steps__step:hover:not(:disabled) { color: var(--text); border-color: v
|
||||
.answers-page { list-style: none; padding: 0; margin: 0; }
|
||||
.answers-page li { padding: 12px 16px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--surface); white-space: pre-line; overflow-wrap: anywhere; }
|
||||
.answers-page time { display: block; color: var(--muted); font-size: .8rem; margin-top: 4px; }
|
||||
.scale-comment { display: block; margin-top: 16px; font-weight: 600; }
|
||||
.comments { margin-top: 20px; padding: 16px 20px; background: var(--surface-2); border-radius: 14px; }
|
||||
.comments__counter { margin: 0 0 6px; font-size: .85em; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||
.comments__text { margin: 0; font-size: 1.25em; font-weight: 600; white-space: pre-line; overflow-wrap: anywhere; }
|
||||
.comments__text::before { content: '„'; }
|
||||
.comments__text::after { content: '“'; }
|
||||
.comments__value { margin: 6px 0 0; color: var(--muted); font-size: .9em; }
|
||||
.comments__nav { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
|
||||
.comments__button { min-width: 44px; min-height: 44px; }
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.comments__text.is-entering { animation: comment-in .4s ease-out; }
|
||||
}
|
||||
@keyframes comment-in {
|
||||
from { opacity: 0; transform: translateY(6px); }
|
||||
to { opacity: 1; transform: none; }
|
||||
}
|
||||
.scale-average { font-size: 1.2rem; margin: 0 0 1em; }
|
||||
.scale-average strong { font-size: 1.6em; font-variant-numeric: tabular-nums; }
|
||||
.scale-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
|
||||
.scale-table th, .scale-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
|
||||
.scale-table td:last-child { width: 50%; }
|
||||
.scale-table__bar { display: block; height: 6px; min-width: 2px; margin-bottom: 4px; border-radius: 3px; background: var(--c2); }
|
||||
|
||||
/* ---------------------------------------------------------------- presenter */
|
||||
/* Dark by default (beamer); the presenter's own switch can make it light (data-theme="light"). */
|
||||
|
||||
+137
-1
@@ -289,6 +289,122 @@
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------ comments
|
||||
|
||||
/**
|
||||
* Rotating comments of a scale slide. The results are re-rendered on every poll,
|
||||
* so position, pause and timer live here and survive the re-render.
|
||||
*/
|
||||
var Comments = {
|
||||
intervalMs: 8000,
|
||||
key: null,
|
||||
index: 0,
|
||||
paused: false,
|
||||
timer: null,
|
||||
items: [],
|
||||
node: null,
|
||||
|
||||
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) {
|
||||
Comments.key = key;
|
||||
Comments.index = 0;
|
||||
Comments.paused = false;
|
||||
}
|
||||
Comments.items = items;
|
||||
Comments.index = Math.min(Comments.index, items.length - 1);
|
||||
|
||||
var button = function (action, label, text) {
|
||||
return el('button', {
|
||||
type: 'button',
|
||||
class: 'button button--small comments__button',
|
||||
'data-comment-action': action,
|
||||
'aria-label': label,
|
||||
title: label,
|
||||
text: text
|
||||
});
|
||||
};
|
||||
var node = el('section', { class: 'comments', 'data-comments': '', 'aria-label': 'Kommentare' }, [
|
||||
el('p', { class: 'comments__counter', 'data-comment-counter': '' }),
|
||||
el('blockquote', { class: 'comments__text', 'data-comment-text': '' }),
|
||||
el('p', { class: 'comments__value', 'data-comment-value': '' }),
|
||||
items.length < 2 ? null : el('div', { class: 'comments__nav' }, [
|
||||
button('prev', 'Vorheriger Kommentar', '‹'),
|
||||
button('toggle', '', ''),
|
||||
button('next', 'Nächster Kommentar', '›')
|
||||
])
|
||||
]);
|
||||
node.addEventListener('click', function (event) {
|
||||
var target = event.target.closest('[data-comment-action]');
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
var action = target.getAttribute('data-comment-action');
|
||||
if (action === 'toggle') {
|
||||
Comments.paused = !Comments.paused;
|
||||
} else {
|
||||
Comments.step(action === 'next' ? 1 : -1);
|
||||
Comments.restart();
|
||||
}
|
||||
Comments.update(false);
|
||||
});
|
||||
Comments.node = node;
|
||||
Comments.update(false);
|
||||
if (!Comments.timer) {
|
||||
Comments.restart();
|
||||
}
|
||||
return node;
|
||||
},
|
||||
|
||||
step: function (delta) {
|
||||
var n = Comments.items.length;
|
||||
Comments.index = (Comments.index + delta + n) % n;
|
||||
},
|
||||
|
||||
restart: function () {
|
||||
clearInterval(Comments.timer);
|
||||
Comments.timer = setInterval(function () {
|
||||
if (!Comments.node || !document.body.contains(Comments.node)) {
|
||||
// Slide changed: stop until the next comment list is rendered.
|
||||
clearInterval(Comments.timer);
|
||||
Comments.timer = null;
|
||||
return;
|
||||
}
|
||||
if (Comments.paused || Comments.items.length < 2 || document.hidden) {
|
||||
return;
|
||||
}
|
||||
Comments.step(1);
|
||||
Comments.update(true);
|
||||
}, Comments.intervalMs);
|
||||
},
|
||||
|
||||
update: function (animate) {
|
||||
var node = Comments.node;
|
||||
var item = Comments.items[Comments.index];
|
||||
var text = node.querySelector('[data-comment-text]');
|
||||
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;
|
||||
// Only announce changes the viewer triggered, not every automatic rotation.
|
||||
node.setAttribute('aria-live', Comments.paused ? 'polite' : 'off');
|
||||
text.classList.remove('is-entering');
|
||||
if (animate) {
|
||||
void text.offsetWidth; // restart the CSS animation
|
||||
text.classList.add('is-entering');
|
||||
}
|
||||
var toggle = node.querySelector('[data-comment-action="toggle"]');
|
||||
if (toggle) {
|
||||
var label = Comments.paused ? 'Kommentare automatisch weiterblättern' : 'Automatisches Weiterblättern anhalten';
|
||||
toggle.textContent = Comments.paused ? '▶' : '❚❚';
|
||||
toggle.setAttribute('aria-label', label);
|
||||
toggle.setAttribute('title', label);
|
||||
toggle.setAttribute('aria-pressed', Comments.paused ? 'true' : 'false');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------ results
|
||||
|
||||
var Results = {
|
||||
@@ -296,6 +412,9 @@
|
||||
* @param {Object} [options] renderer specific; wordcloud: {mine: [keys], onUpvote: fn(word)|null}
|
||||
*/
|
||||
render: function (container, results, options) {
|
||||
// Keep keyboard focus on controls inside the results (e.g. comment buttons) across re-renders.
|
||||
var active = document.activeElement;
|
||||
var focusKey = active && container.contains(active) ? active.getAttribute('data-comment-action') : null;
|
||||
container.innerHTML = '';
|
||||
if (!results) {
|
||||
return;
|
||||
@@ -313,6 +432,10 @@
|
||||
return;
|
||||
}
|
||||
container.appendChild(renderer(results, options || {}));
|
||||
var refocus = focusKey && container.querySelector('[data-comment-action="' + focusKey + '"]');
|
||||
if (refocus) {
|
||||
refocus.focus();
|
||||
}
|
||||
},
|
||||
|
||||
choice: function (results) {
|
||||
@@ -329,6 +452,15 @@
|
||||
},
|
||||
|
||||
scale: function (results) {
|
||||
if (results.private) {
|
||||
// Internal feedback: the ratings never reach the stage, only the count.
|
||||
var n = results.participants;
|
||||
return el('div', { class: 'private-summary' }, [
|
||||
el('p', { class: 'private-summary__count', text: String(n) }),
|
||||
el('p', { text: (n === 1 ? 'Bewertung' : 'Bewertungen') + ' eingegangen' }),
|
||||
el('p', { class: 'private-summary__hint', text: '🔒 Ergebnis wird nicht öffentlich angezeigt.' })
|
||||
]);
|
||||
}
|
||||
var max = Math.max.apply(null, results.buckets.map(function (b) { return b.count; }).concat([1]));
|
||||
var total = results.buckets.reduce(function (sum, b) { return sum + b.count; }, 0);
|
||||
var hasAverage = results.average !== null;
|
||||
@@ -375,7 +507,8 @@
|
||||
]),
|
||||
gauge
|
||||
]);
|
||||
return el('div', { class: 'scale-results' }, [average, columns, labels]);
|
||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments) : null;
|
||||
return el('div', { class: 'scale-results' }, [average, columns, labels, comments]);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1039,6 +1172,9 @@
|
||||
if (event.target.closest('input, textarea, select')) {
|
||||
return;
|
||||
}
|
||||
if ((event.key === ' ' || event.key === 'Enter') && event.target.closest('[data-comments]')) {
|
||||
return; // activates the focused comment button, not the next slide
|
||||
}
|
||||
if (embedded && ['ArrowRight', 'ArrowLeft', 'PageUp', 'PageDown', ' ', 'p', 'P', 'f', 'F', 'q', 'Q'].indexOf(event.key) >= 0) {
|
||||
return; // slide navigation belongs to the surrounding presentation
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user