app/views/admin/surveys/_survey_question.html.haml
.panel.panel-default
.panel-heading
= render partial: 'admin/surveys/survey_question_title', locals: { survey_question: survey_question, question_index: question_index }
.panel-body
- if survey_question.boolean?
%input{ type: 'hidden', name: "survey_submission[#{survey_question.id}][]" }
%label
%input{ type: 'radio', name: "survey_submission[#{survey_question.id}][]", value: 'Yes', checked: survey_reply.text == 'Yes',required: survey_question.mandatory }
Yes
%br
%label
%input{ type: 'radio', name: "survey_submission[#{survey_question.id}][]", value: 'No', checked: survey_reply.text == 'No' }
No
- elsif survey_question.choice?
%input{ type: 'hidden', name: "survey_submission[#{survey_question.id}][]" }
- possible_answers = survey_question.possible_answers.split(',').map(&:strip)
- possible_answers.each.with_index(1) do |answer, answer_index|
- if survey_question.single_choice?
%label
%input{ type: 'radio', name: "survey_submission[#{survey_question.id}][]", value: answer, checked: (survey_reply.text == answer if survey_reply.text), required: survey_question.mandatory }
= answer
%br
- else
%label
= check_box_tag "survey_submission[#{survey_question.id}][]", answer, (survey_reply.text.include? answer if survey_reply.text), id: dom_id(survey_reply), required: survey_question.mandatory
= answer
%br
- elsif survey_question.string?
%input.form-control{ name: "survey_submission[#{survey_question.id}][]", value: survey_reply.text, required: survey_question.mandatory }
- elsif survey_question.text?
= text_area_tag "survey_submission[#{survey_question.id}][]", survey_reply.text, rows: 4, class: 'form-control', required: survey_question.mandatory
- elsif survey_question.datetime?
.form-group
.input-group
.input-group-addon
%span.fa-solid.fa-calendar
%input.form-control{ type: 'datetime-local', readonly: 'readonly', name: "survey_submission[#{survey_question.id}][]", value: survey_reply.text, required: survey_question.mandatory }
- elsif survey_question.numeric?
%input.form-control{ type: 'number', name: "survey_submission[#{survey_question.id}][]", value: survey_reply.text, required: survey_question.mandatory }