better reset questions

This commit is contained in:
ajuvercr 2020-09-14 22:54:14 +02:00
parent bb1e2723e5
commit 1f64907f9c
2 changed files with 14 additions and 1 deletions

View file

@ -20,7 +20,7 @@
</form>
<% question[:antwoorden].sort_by{ |x| x[:tekst] }.each_with_index do |answer, idx|%>
<% if answer[:vraag] %>
<div id='<%= number+"#"+idx.to_s %>' style="display:none;">
<div id='<%= number+"#"+idx.to_s %>' class="question_wrapper" style="display:none;">
<%= render '/partials/question.*', question: answer, number: number+"."+idx.to_s %>
</div>
<% end %>

View file

@ -77,6 +77,19 @@
state.answers = {};
// Hide all subquestions
for(let form of [...document.querySelectorAll(`[id^="${state.question.index - 1}#"]`)]) {
form.style.display = "none";
// The vraag2 -> politiek -> Vlaamse en nationale politiek div wasn't set to none, because of the more complicated id.
form.querySelectorAll(".question_wrapper").forEach(e => e.style.display = "none");
}
// Set checked to false for everything in this question
for(let form of [...document.querySelectorAll(`[id^="${state.question.index - 1}"][id$="form"]`)]) {
[...form.elements].filter(e => e.nodeName == "INPUT").forEach(e => e.checked = false);
}
save_state();
showCorrectElements();
}