better questions

This commit is contained in:
ajuvercr 2020-02-27 22:45:50 +01:00
parent 2ae155b877
commit 2f9b80512d
3 changed files with 15 additions and 21 deletions

7
Rules
View file

@ -7,13 +7,6 @@ compile '/verenigingen/*.md' do
write ext: 'html' write ext: 'html'
end end
compile '/quiz/*.md' do
filter :kramdown
layout '/partials/question.*'
layout '/default.*'
write ext: 'html'
end
compile '/homepage.md' do compile '/homepage.md' do
filter :kramdown filter :kramdown
layout '/homepage.*' layout '/homepage.*'

View file

@ -1,19 +1,19 @@
<h1> <%= item[:vraag] %> </h1> <h1> <%= question[:vraag] %> </h1>
<select id=<%= item[:vraag] %>> <select id="<%= question[:vraag] %>">
<% for a in item[:antwoord] %> <% for a in question[:antwoord] %>
<option value=<%= a[:teskt] %>><%= a[:tekst] %></option> <option value="<%= a[:tekst] %>"><%= a[:tekst] %></option>
<% if a[:vraag] != ""%> <% if a.key?("vraag") %>
<div id=<% a[:vraag]%>> <div id=<%= a[:vraag]%>>
<%= render '/partials/question.*' %> <%= render '/partials/question.*', question: a %>
</div> </div>
<% end % <% end %>
<% end %> <% end %>
</select> </select>
<script> <script>
document.getElementById(<%= item[:vraag]%>).addEventListener('change', (event) => { document.getElementById(<%= item[:vraag]%>).addEventListener('change', (event) => {
var tekst = event.target.value; var tekst = event.target.value;
document.getElementById(<%= item[:vraag]%>) document.getElementById(<%= item[:vraag]%>)
<%= render '/partials/question.*' %> <%= render '/partials/question.*' %>
}) })
</script> </script>
<%= yield %>

View file

@ -1,8 +1,9 @@
<h1>Hallo</h1> <h1>Hallo</h1>
<ul> <ul>
<% @items.find_all("**/quiz/*").each_with_index do |x, i| %> <% @items.find_all("**/quiz/*").each_with_index do |quest, i| %>
<div id="question<%i%>" class="quistion"> <div id="question_<%=i%>" class="question">
<%= render '/partials/question.*', item: x %> <h2> <%= quest[:vraag] %> </h2>
<%= render '/partials/question.*', question: quest %>
</div> </div>
<% end %> <% end %>
</ul> </ul>