Add personal ranking mode to order slides and show image placement only with an image
CI / Deploy / PHP 8.4 (push) Failing after 1m28s
CI / Deploy / PHP 8.5 (push) Failing after 1m31s
CI / Deploy / test (push) Failing after 2s
CI / Deploy / deploy (push) Skipped

Order slides get a "ranking" setting without a correct solution: the stage shows
the live average ranking, participants only get a confirmation. The image
placement question in the slide form is only shown for an existing image or a
chosen file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Sonnet 5.5 committed 2026-11-17 09:15:49 +01:00
1 parent 85627b364d
commit 0aac113f30
15 files changed
+239 -15

No files matched your search

+47
View File
@@ -947,6 +947,31 @@
*/
order: function (results, options) {
var answer = options && options.order ? options.order.answer : null;
if (results.ranking) {
// Personal ranking: no solution, the average of all submitted orders (live, stage only).
if (results.participants === 0) {
return el('div', { class: 'order-results' }, [
el('p', { class: 'quiz-status', text: 'Die Teilnehmenden sortieren nach ihrer persönlichen Einschätzung' }),
el('ul', { class: 'quiz-grid' }, results.items.map(function (item, index) {
return el('li', { class: 'quiz-tile quiz-tile--c' + (index % 6), text: item.label });
}))
]);
}
return el('div', { class: 'order-results order-results--ranking' }, [
el('ol', { class: 'order-solution' }, results.items.map(function (item) {
return el('li', { class: 'bar order-solution__item' }, [
el('div', { class: 'bar__label' }, [
el('span', { class: 'order-solution__pos', text: item.position + '.' }),
document.createTextNode(' ' + item.label)
]),
el('div', { class: 'bar__track' }, [
el('div', { class: 'bar__fill', style: 'width:' + item.score + '%' })
]),
el('div', { class: 'bar__value', text: 'Ø Platz ' + formatNumber(item.average) })
]);
}))
]);
}
if (!results.revealed) {
return el('div', { class: 'order-results' }, [
el('p', { class: 'quiz-status', text: 'Die Teilnehmenden sortieren – aufgelöst wird beim Schließen der Abstimmung' }),
@@ -2281,6 +2306,27 @@
});
}
/**
* Slide image: the placement question only makes sense with an image, i.e. an existing one that is not
* marked for removal, or a newly selected file. Without JavaScript it stays visible.
*/
function initImageFields(box) {
var layout = box.querySelector('[data-image-layout]');
var file = box.querySelector('input[type="file"]');
var remove = box.querySelector('input[name="remove_image"]');
if (!layout || !file) {
return;
}
var hasImage = box.hasAttribute('data-has-image');
function update() {
var removed = !!remove && remove.checked;
layout.hidden = !(file.files && file.files.length > 0) && !(hasImage && !removed);
}
box.addEventListener('change', update);
box.addEventListener('click', update);
update();
}
/** Quiz slide form: add further answer rows (the server renders a few already). */
function initQuizOptions(fieldset) {
var list = fieldset.querySelector('[data-quiz-list]');
@@ -2922,6 +2968,7 @@
root.querySelectorAll('[data-youtube-form]').forEach(initYouTubeForm);
root.querySelectorAll('[data-quiz-options]').forEach(initQuizOptions);
root.querySelectorAll('[data-image-remove]').forEach(initImageRemove);
root.querySelectorAll('[data-image-fields]').forEach(initImageFields);
root.querySelectorAll('[data-sortable]').forEach(initSortable);
root.querySelectorAll('[data-order-options]').forEach(initOrderOptions);
root.querySelectorAll('[data-scale-style]').forEach(initScaleStyle);