Add internal feedback and comments to choice slides
Same options as for scales: "private" shows only the number of votes on the stage, "comments" adds an optional comment field whose comments rotate in the presentation, "comment_ratings" shows the chosen answer(s) next to each comment. With multiple choice the comment is stored on the participant's first row. Settings and participant fields are shared elements for scale and choice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3e09906830
commit
547b564e32
18 files changed
+485
-108
No files matched your search
+35
-10
@@ -303,8 +303,14 @@
|
||||
timer: null,
|
||||
items: [],
|
||||
node: null,
|
||||
valuePrefix: '',
|
||||
|
||||
render: function (items) {
|
||||
/**
|
||||
* @param {Array} items [{id, text, value|null}]
|
||||
* @param {string} valuePrefix e.g. 'Bewertung: ' or 'Antwort: '
|
||||
*/
|
||||
render: function (items, valuePrefix) {
|
||||
Comments.valuePrefix = valuePrefix;
|
||||
// A different first comment means a different slide (or a reset): start over.
|
||||
var key = String(items[0].id);
|
||||
if (key !== Comments.key) {
|
||||
@@ -387,7 +393,7 @@
|
||||
'Kommentar ' + (Comments.index + 1) + ' von ' + Comments.items.length;
|
||||
text.textContent = item.text;
|
||||
var value = node.querySelector('[data-comment-value]');
|
||||
value.textContent = item.value === null || item.value === undefined ? '' : 'Bewertung: ' + item.value;
|
||||
value.textContent = item.value === null || item.value === undefined ? '' : Comments.valuePrefix + item.value;
|
||||
value.hidden = value.textContent === '';
|
||||
// Only announce changes the viewer triggered, not every automatic rotation.
|
||||
node.setAttribute('aria-live', Comments.paused ? 'polite' : 'off');
|
||||
@@ -409,6 +415,24 @@
|
||||
|
||||
// ------------------------------------------------------------------ results
|
||||
|
||||
/**
|
||||
* Anonymous/internal feedback: only the number of answers reaches the stage.
|
||||
*/
|
||||
function privateSummary(n, singular, plural) {
|
||||
return el('div', { class: 'private-summary' }, [
|
||||
el('p', { class: 'private-summary__count', text: String(n) }),
|
||||
el('p', { text: (n === 1 ? singular : plural) + ' eingegangen' }),
|
||||
el('p', { class: 'private-summary__hint', text: '🔒 Ergebnis wird nicht öffentlich angezeigt.' })
|
||||
]);
|
||||
}
|
||||
|
||||
function withComments(node, results, valuePrefix) {
|
||||
if (!results.comments || !results.comments.length) {
|
||||
return node;
|
||||
}
|
||||
return el('div', {}, [node, Comments.render(results.comments, valuePrefix)]);
|
||||
}
|
||||
|
||||
var Results = {
|
||||
/**
|
||||
* @param {Object} [options] renderer specific; wordcloud: {mine: [keys], onUpvote: fn(word)|null}
|
||||
@@ -441,6 +465,13 @@
|
||||
},
|
||||
|
||||
choice: function (results) {
|
||||
if (results.private) {
|
||||
return privateSummary(results.participants, 'Stimme', 'Stimmen');
|
||||
}
|
||||
return withComments(Results.choiceBars(results), results, 'Antwort: ');
|
||||
},
|
||||
|
||||
choiceBars: function (results) {
|
||||
var max = Math.max.apply(null, results.options.map(function (o) { return o.count; }).concat([1]));
|
||||
return el('div', { class: 'bars' }, results.options.map(function (option, index) {
|
||||
return el('div', { class: 'bar bar--c' + (index % 6) }, [
|
||||
@@ -455,13 +486,7 @@
|
||||
|
||||
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.' })
|
||||
]);
|
||||
return privateSummary(results.participants, 'Bewertung', 'Bewertungen');
|
||||
}
|
||||
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);
|
||||
@@ -509,7 +534,7 @@
|
||||
]),
|
||||
gauge
|
||||
]);
|
||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments) : null;
|
||||
var comments = results.comments && results.comments.length ? Comments.render(results.comments, 'Bewertung: ') : null;
|
||||
return el('div', { class: 'scale-results' }, [average, columns, labels, comments]);
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user