do cool shit, like live update things
This commit is contained in:
parent
2c16ff8198
commit
2e08734467
4 changed files with 41 additions and 10 deletions
1
layouts/partials/group_small.erb
Normal file
1
layouts/partials/group_small.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<%= link_to group[:titel], group %>
|
|
@ -62,7 +62,7 @@
|
||||||
// Update results
|
// Update results
|
||||||
save_answers(selected.flatMap(e => question_results[e] || []));
|
save_answers(selected.flatMap(e => question_results[e] || []));
|
||||||
del_answers(last_answered.flatMap(e => question_results[e] || []));
|
del_answers(last_answered.flatMap(e => question_results[e] || []));
|
||||||
print_answers();
|
finish_answers();
|
||||||
|
|
||||||
// Make possible sub question visible
|
// Make possible sub question visible
|
||||||
const quests = selected.flatMap(e => sub_questions[e] || []);
|
const quests = selected.flatMap(e => sub_questions[e] || []);
|
||||||
|
|
|
@ -1,7 +1,31 @@
|
||||||
|
|
||||||
|
<div style="display: flex">
|
||||||
|
<div style="width: 70vw;">
|
||||||
|
<% @items.find_all("/quiz/*").each_with_index do |quest, i| %>
|
||||||
|
<div id="question_<%=i%>" class="question">
|
||||||
|
<%= render '/partials/question.*', question: quest %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="width: 28vw;" style="display: flex; flex-direction: column;">
|
||||||
|
<% all_groups().each do |group| %>
|
||||||
|
<div id="d_<%= group[:id] %>" style="display: none;">
|
||||||
|
<%= render '/partials/group_small.*', group: group %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const _groups = {};
|
||||||
|
<% all_groups().each do |group| %>
|
||||||
|
_groups["d_<%= group[:id] %>"] = document.getElementById("d_<%= group[:id] %>");
|
||||||
|
<% end %>
|
||||||
const _save_answers = {};
|
const _save_answers = {};
|
||||||
|
|
||||||
|
console.log(_groups);
|
||||||
|
|
||||||
function save_answers(vers) {
|
function save_answers(vers) {
|
||||||
for (let ver of vers) {
|
for (let ver of vers) {
|
||||||
if (_save_answers[ver]) {
|
if (_save_answers[ver]) {
|
||||||
|
@ -16,10 +40,18 @@
|
||||||
for (let ver of vers) {
|
for (let ver of vers) {
|
||||||
_save_answers[ver] -= 1;
|
_save_answers[ver] -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function print_answers() {
|
function finish_answers() {
|
||||||
|
for (let ver in _save_answers) {
|
||||||
|
console.log(ver);
|
||||||
|
if (_save_answers[ver] == 0) {
|
||||||
|
_groups["d_"+ver].style.display = "none";
|
||||||
|
} else {
|
||||||
|
_groups["d_"+ver].style.display = "block";
|
||||||
|
_groups["d_"+ver].style.order = -1 * _save_answers[ver];
|
||||||
|
}
|
||||||
|
}
|
||||||
console.log(_save_answers);
|
console.log(_save_answers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,9 +71,4 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% @items.find_all("/quiz/*").each_with_index do |quest, i| %>
|
|
||||||
<div id="question_<%=i%>" class="question">
|
|
||||||
<%= render '/partials/question.*', question: quest %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
|
|
|
@ -11,4 +11,7 @@ module VerenigingenHelper
|
||||||
def konvents
|
def konvents
|
||||||
@items.find_all("**/verenigingen/*").map{|x| x[:konvent]}.uniq.compact
|
@items.find_all("**/verenigingen/*").map{|x| x[:konvent]}.uniq.compact
|
||||||
end
|
end
|
||||||
|
def all_groups
|
||||||
|
@items.find_all("**/verenigingen/*") + @items.find_all("**/konventen/*")
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue