28 lines
1.1 KiB
Plaintext
28 lines
1.1 KiB
Plaintext
<%
|
|
answers = question.answer.nil? ? [] : Array(question.answer['options'])
|
|
other_value = question.answer.nil? ? '' : question.answer['other']
|
|
|
|
question.input_options.each do | option |
|
|
option_id = "#{option.parameterize}_#{question.to_i}"
|
|
checkbox_html = {class: "", id: option_id, data: { last: answers.include?(option) ? 'checked' : '' } }
|
|
%>
|
|
<div class="">
|
|
<%= check_box_tag('answer[answer_hash][options][]', option, answers.include?(option), checkbox_html) %>
|
|
<%= label_tag(option_id, option) %>
|
|
</div>
|
|
<%
|
|
end %>
|
|
|
|
<div class="">
|
|
<%
|
|
option_id = "other_#{question.to_i}"
|
|
checkbox_html = {class: "", id: option_id, data: { last: answers.include?('other') ? 'checked' : '' } }
|
|
text_html = {class: "", id: "text_#{option_id}", data: { last: other_value }}
|
|
%>
|
|
<%= check_box_tag('answer[answer_hash][options][]', 'other', answers.include?('other'), checkbox_html) %>
|
|
<%= label_tag(option_id, 'Other') %>
|
|
<%= text_field_tag 'answer[answer_hash][other]', other_value, text_html %>
|
|
</div>
|
|
|
|
<%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %>
|