Add "Keine Angabe" to scales and an "Enthaltung" shortcut for choice slides
Scales and star ratings get an optional "Keine Angabe" answer (setting allow_skip). It counts as taking part but stays out of the average and the distribution; the number is shown separately on stage, in the evaluation and in the PDF. The choice form gets a button that appends an "Enthaltung" option. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1b48ce7852
commit
d6432911ed
14 files changed
+195
-11
No files matched your search
+50
-5
@@ -794,7 +794,11 @@
|
||||
el('span', { class: 'average__of', text: ofText })
|
||||
]),
|
||||
visual,
|
||||
el('span', { class: 'average__count', text: total + (total === 1 ? ' Bewertung' : ' Bewertungen') })
|
||||
el('span', {
|
||||
class: 'average__count',
|
||||
text: total + (total === 1 ? ' Bewertung' : ' Bewertungen')
|
||||
+ (results.skipped ? ' · ' + results.skipped + '× keine Angabe' : '')
|
||||
})
|
||||
]);
|
||||
},
|
||||
|
||||
@@ -2841,6 +2845,45 @@
|
||||
update();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ quick option (choice form)
|
||||
|
||||
/**
|
||||
* Button that appends a ready-made option (e.g. "Enthaltung") to the option textarea.
|
||||
* Idempotent: an existing line with the same text is not added again; the maximum is respected.
|
||||
*/
|
||||
function initAddOption(button) {
|
||||
var area = document.getElementById(button.getAttribute('data-add-option-target'));
|
||||
if (!area) {
|
||||
return;
|
||||
}
|
||||
var label = button.getAttribute('data-add-option');
|
||||
var max = parseInt(button.getAttribute('data-add-option-max'), 10) || 20;
|
||||
|
||||
function lines() {
|
||||
return area.value.split(/\r?\n/).map(function (line) { return line.trim(); }).filter(Boolean);
|
||||
}
|
||||
|
||||
function update() {
|
||||
var current = lines();
|
||||
var present = current.some(function (line) { return line.toLowerCase() === label.toLowerCase(); });
|
||||
button.disabled = present || current.length >= max;
|
||||
}
|
||||
|
||||
button.hidden = false;
|
||||
button.addEventListener('click', function () {
|
||||
var current = lines();
|
||||
if (button.disabled) {
|
||||
return;
|
||||
}
|
||||
current.push(label);
|
||||
area.value = current.join('\n');
|
||||
update();
|
||||
area.focus();
|
||||
});
|
||||
area.addEventListener('input', update);
|
||||
update();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ theme switch
|
||||
|
||||
var THEME_ICONS = { auto: '◐', light: '☀', dark: '☾' };
|
||||
@@ -3163,6 +3206,7 @@
|
||||
root.querySelectorAll('[data-sortable]').forEach(initSortable);
|
||||
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
|
||||
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);
|
||||
root.querySelectorAll('[data-add-option]').forEach(initAddOption);
|
||||
}
|
||||
|
||||
// Flash messages: click hides them (delegated, no inline handlers because of the CSP).
|
||||
@@ -3290,10 +3334,11 @@
|
||||
if (event.defaultPrevented) {
|
||||
return; // handled via fetch (word cloud)
|
||||
}
|
||||
var button = form.querySelector('button[type=submit], button:not([type])');
|
||||
if (button) {
|
||||
setTimeout(function () { button.disabled = true; }, 0);
|
||||
}
|
||||
// All buttons (e.g. "Absenden" and "Keine Angabe"); the pressed one is already part of the request.
|
||||
var buttons = form.querySelectorAll('button[type=submit], button:not([type])');
|
||||
setTimeout(function () {
|
||||
buttons.forEach(function (button) { button.disabled = true; });
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user