2016-08-31 16:59:25 -05:00
|
|
|
<%
|
2017-04-17 16:40:08 -05:00
|
|
|
answer_string = question.answer.nil? ? '' : Array(question.answer['options']).first
|
2016-08-31 16:59:25 -05:00
|
|
|
other_value = question.answer.nil? ? '' : question.answer['other']
|
|
|
|
|
|
|
|
question.input_options.each do | option |
|
|
|
|
option_id = "#{option.parameterize}_#{question.to_i}"
|
2017-03-20 10:57:50 -05:00
|
|
|
radio_html = {class: "", id: option_id, data: {last: (answer_string == option) ? 'checked' : '' }}
|
2016-08-31 16:59:25 -05:00
|
|
|
%>
|
2017-03-20 10:57:50 -05:00
|
|
|
<div class="">
|
2017-04-17 16:40:08 -05:00
|
|
|
<%= radio_button_tag('answer[answer_hash][options][]', option, (answer_string == option), radio_html) %>
|
2016-08-31 16:59:25 -05:00
|
|
|
<%= label_tag(option_id, option) %>
|
|
|
|
</div>
|
|
|
|
<%
|
|
|
|
end %>
|
|
|
|
|
2017-03-20 10:57:50 -05:00
|
|
|
<div class="">
|
2016-08-31 16:59:25 -05:00
|
|
|
<%
|
|
|
|
option_id = "other_#{question.to_i}"
|
2017-03-20 10:57:50 -05:00
|
|
|
radio_html = {class: "", id: option_id, data: { last: answer_string }}
|
|
|
|
text_html = {class: "", id: "text_#{option_id}", data: { last: other_value }}
|
2016-08-31 16:59:25 -05:00
|
|
|
%>
|
2017-04-17 16:40:08 -05:00
|
|
|
<%= radio_button_tag('answer[answer_hash][options][]', 'other', (answer_string == 'other'), radio_html) %>
|
2016-08-31 16:59:25 -05:00
|
|
|
<%= label_tag option_id, 'Other' %>
|
2016-09-02 17:51:35 -05:00
|
|
|
<%= text_field_tag 'answer[answer_hash][other]', other_value, text_html %>
|
2016-08-31 16:59:25 -05:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %>
|