Finish remaining question types
This commit is contained in:
parent
0d54f756d8
commit
5bd1e821f7
20 changed files with 431 additions and 8 deletions
22
app/views/questions/_acrostic_form.html.erb
Normal file
22
app/views/questions/_acrostic_form.html.erb
Normal file
|
@ -0,0 +1,22 @@
|
|||
<% max_position = question.data.map { |c| c["position"] }.max %>
|
||||
<% index = -1 %>
|
||||
<div class="acrostic-puzzle"
|
||||
data-behaviour="question_acrostic"
|
||||
data-submit-url="<%= answer_question_url(question.id) %>"
|
||||
>
|
||||
<% question.data.each.with_index do |constraints, i| %>
|
||||
<div class="acrostic-row">
|
||||
<span class="acrostic-number"><%= i + 1 %></span>
|
||||
<% (max_position - constraints["position"]).times do %>
|
||||
<span class="acrostic-offset"></span>
|
||||
<% end %>
|
||||
<% (constraints["position"] - 1).times do %>
|
||||
<%= render partial: "questions/acrostic_input", locals: {on_column: false, index: (index += 1), answer_data: question.answer&.data} %>
|
||||
<% end %>
|
||||
<%= render partial: "questions/acrostic_input", locals: {on_column: true, index: (index += 1), answer_data: question.answer&.data} %>
|
||||
<% (constraints["length"] - constraints["position"]).times do %>
|
||||
<%= render partial: "questions/acrostic_input", locals: {on_column: false, index: (index += 1), answer_data: question.answer&.data} %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
6
app/views/questions/_acrostic_input.html.erb
Normal file
6
app/views/questions/_acrostic_input.html.erb
Normal file
|
@ -0,0 +1,6 @@
|
|||
<%= tag.input class: {"acrostic-input": true, "acrostic-column": on_column},
|
||||
data: {index: index},
|
||||
value: answer_data&.then { |it| it[index] },
|
||||
type: "text",
|
||||
autocomplete: "off"
|
||||
%>
|
3
app/views/questions/_acrostic_show.html.erb
Normal file
3
app/views/questions/_acrostic_show.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<% question.text.lines.each.with_index do |q, i| %>
|
||||
<p><strong><%= i + 1 %>.</strong> <%= q %></p>
|
||||
<% end %>
|
11
app/views/questions/_connections_form.html.erb
Normal file
11
app/views/questions/_connections_form.html.erb
Normal file
|
@ -0,0 +1,11 @@
|
|||
<div
|
||||
class="connections-grid"
|
||||
data-behaviour="connections_answer"
|
||||
data-submit-url="<%= answer_question_url(question.id) %>"
|
||||
>
|
||||
<% answers = question.data.each.with_index.to_a %>
|
||||
<% answers = reorder_with_indices(answers, question.answer.data) if question.answer.present? %>
|
||||
<% answers.each do |a, i| %>
|
||||
<span class="connections-element" data-id="<%= i %>"><%= a %></span>
|
||||
<% end %>
|
||||
</div>
|
15
app/views/questions/_lyrics_form.html.erb
Normal file
15
app/views/questions/_lyrics_form.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<% index = -1 %>
|
||||
<div data-behaviour="lyrics_answer"
|
||||
data-submit-url="<%= answer_question_url(question.id) %>"
|
||||
>
|
||||
<% question.data.lines.each do |l| %>
|
||||
<% parts = l.split "{}", -1 %>
|
||||
<p>
|
||||
<%= render partial: "questions/lyrics_given_part", locals: {text: parts[0]} %>
|
||||
<% parts[1..].each do |text| %>
|
||||
<%= render partial: "questions/lyrics_input", locals: {index: (index += 1), answer_data: question.answer&.data} %>
|
||||
<%= render partial: "questions/lyrics_given_part", locals: {text: text} %>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
3
app/views/questions/_lyrics_given_part.html.erb
Normal file
3
app/views/questions/_lyrics_given_part.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<% if text.present? %>
|
||||
<span><%= text %></span>
|
||||
<% end %>
|
6
app/views/questions/_lyrics_input.html.erb
Normal file
6
app/views/questions/_lyrics_input.html.erb
Normal file
|
@ -0,0 +1,6 @@
|
|||
<%= tag.input class: "lyrics-input",
|
||||
data: {index: index},
|
||||
value: answer_data&.then { |it| it[index] },
|
||||
type: "text",
|
||||
autocomplete: "off"
|
||||
%>
|
|
@ -5,8 +5,8 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div data-behaviour="politicians_answer"
|
||||
data-submit-url="<%= answer_question_url(question.id) %>"
|
||||
>
|
||||
data-submit-url="<%= answer_question_url(question.id) %>"
|
||||
>
|
||||
<% answers = question.data["right"].each.with_index.to_a %>
|
||||
<% answers = reorder_with_indices(answers, question.answer.data) if question.answer.present? %>
|
||||
<% answers.each do |a, i| %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue