fix quiz multiple choice behavior
This commit is contained in:
parent
69a5ac0a99
commit
677af15b00
1 changed files with 4 additions and 2 deletions
|
@ -63,6 +63,9 @@
|
||||||
})();
|
})();
|
||||||
<%else%>
|
<%else%>
|
||||||
{
|
{
|
||||||
|
// If false and the this question changes, all children should loose `checked`
|
||||||
|
// This might not actually work when questions are infinitely deep
|
||||||
|
const multiple_allowed = <%= question[:type] == "meerkeuze" %>;
|
||||||
// Reference back to the last selected option
|
// Reference back to the last selected option
|
||||||
// This way we can 'deselect' the question results
|
// This way we can 'deselect' the question results
|
||||||
let last_answered = [];
|
let last_answered = [];
|
||||||
|
@ -87,8 +90,7 @@
|
||||||
// When a parent is changed, it should notify it's last_answered child that it is changed
|
// When a parent is changed, it should notify it's last_answered child that it is changed
|
||||||
// Notice the replace, we move from an answer to a subquestion
|
// Notice the replace, we move from an answer to a subquestion
|
||||||
const sub = document.getElementById(la.replace("#", ".")+"_form");
|
const sub = document.getElementById(la.replace("#", ".")+"_form");
|
||||||
if (sub) {
|
if (sub && !multiple_allowed) {
|
||||||
|
|
||||||
[...sub.elements].filter(e => e.nodeName == "INPUT").forEach(e => e.checked = false);
|
[...sub.elements].filter(e => e.nodeName == "INPUT").forEach(e => e.checked = false);
|
||||||
|
|
||||||
sub.dispatchEvent(new Event('change'));
|
sub.dispatchEvent(new Event('change'));
|
||||||
|
|
Loading…
Reference in a new issue