skill-assessment-app/app/views/quiz/_radio.html.erb
2017-06-05 11:30:35 -05:00

16 lines
588 B
Plaintext

<% answer_string = answer.try(:answer) || answer %>
<%= form.collection_radio_buttons(:answer, question.input_options, :to_s, :to_s, {}, {class: ""}) do | option | %>
<%
option_id = "#{question.question_id}#{sanitize_to_id(option.value)}"
checked = answer_string == option.value ? 'checked' : ''
%>
<div class="">
<%= option.radio_button( id: option_id, checked: checked, data: { last: checked } ) %>
<%= option.label(for: option_id) %>
</div>
<% end %>
<%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %>