<%# locals: { f, question, answer } %> <% options = question.question_options.by_number %> <% if question.question_format.checkbox? %> <%= f.label(:question_option_ids, raw(question.text), class: 'control-label') %> <% options.each do |op| %> <div class="checkbox"> <label> <%= f.check_box(:question_option_ids, { multiple: true, checked: answer.has_question_option(op.id) || (answer.question_options.empty? && op.is_default?) }, op.id, nil) %> <%= raw op.text %> </label> </div> <% end %> <% elsif question.question_format.radiobuttons? %> <%= f.label(:question_option_ids, raw(question.text), class: 'control-label') %> <% options.each do |op| %> <div class="radio"> <label> <%= f.radio_button :question_option_ids, op.id, { checked: answer.has_question_option(op.id) || (answer.question_options.empty? && op.is_default?), id: "answer_option_ids_#{op.id}" } %> <%= raw op.text %> </label> </div> <% end %> <% elsif question.question_format.dropdown? || question.question_format.multiselectbox? %> <% options_html = "" options.each do |op| options_html += answer.has_question_option(op.id) || (answer.question_options.empty? && op.is_default?) ? "<option value=#{op.id} selected=\"selected\">#{op.text}</option>" : "<option value=#{op.id}>#{op.text}</option>" end %> <%= f.label(:question_option_ids, raw(question.text), class: 'control-label') %> <%= select_tag('answer[question_option_ids]', raw(options_html), { multiple: question.question_format.multiselectbox?, include_blank: question.question_format.dropdown?, class: 'form-control' }) %> <% end %> <div class="form-group"> <% if question.option_comment_display %><!-- Comment text area for option_based questions --> <% text = question.question_format.rda_metadata? ? answer.answer_hash['text'] : answer.text %> <%= label_tag('answer[text]', _('Additional Information'), class: 'control-label') %> <%= text_area_tag('answer[text]', text, id: "answer-text-#{question.id}", class: "form-control tinymce_answer") %> <% end %> </div>