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

19 lines
740 B
Plaintext

<% answers = Array(question.answer) %>
<div role="group" aria-labelledby="<%= question.question_id %>">
<div id="<%= question.question_id %>">Check all that apply:</div>
<%= form.collection_check_boxes(:answer_array, question.input_options, :to_s, :to_s, {}, {class: ""}) do | option | %>
<%
option_id = "#{question.question_id}#{sanitize_to_id(option.value)}"
checked = answers.include?(option.value) ? 'checked' : ''
%>
<div>
<%= option.check_box( id: option_id, checked: checked, data: { last: checked } ) %>
<%= option.label( for: option_id, "aria-label" => option_id ) %>
</div>
<% end %>
</div>
<%= render partial: "quiz/answer_errors", locals: {question: question, answer: answer} %>