<% add_decidim_meta_tags({ title: translated_attribute(survey.title), description: translated_attribute(survey.description), }) %> <%= render partial: "decidim/shared/feature_announcement" %>

<%= translated_attribute survey.title %>

<%= decidim_sanitize translated_attribute survey.description %>
<% if current_settings.allow_answers? %> <% if current_user %> <% if survey.answered_by?(current_user) %>
<%= t('.survey_answered.title') %>

<%= t('.survey_answered.body') %>

<% else %>
<%= decidim_form_for(@form, url: answer_survey_path(survey), method: :post, html: { class: "form answer-survey" }) do |form| %> <% @form.answers.each_with_index do |answer, answer_idx| %>
<% field_id = "survey_#{survey.id}_question_#{answer.question.id}_answer_body" %> <%= label_tag field_id , "#{answer_idx + 1}. #{translated_attribute(answer.question.body)} #{'*' if answer.question.mandatory?}" %> <% case answer.question.question_type %> <% when "short_answer" %> <%= text_field_tag "survey[answers][#{answer_idx}][body][]", answer.body.try(:first), id: field_id, class: "#{'is-invalid-input' unless answer.errors.empty?}" %> <% when "long_answer" %> <%= text_area_tag "survey[answers][#{answer_idx}][body][]", answer.body.try(:first), id: field_id, class: "#{'is-invalid-input' unless answer.errors.empty?}", rows: 10 %> <% when "single_option" %>
<% answer.question.answer_options.each_with_index do |answer_option, idx| %> <%= label_tag "#{field_id}_option_#{idx}" do %> <%= radio_button_tag "survey[answers][#{answer_idx}][body][]", translated_attribute(answer_option["body"]), answer.body.try(:include?, translated_attribute(answer_option["body"])), id: "#{field_id}_option_#{idx}" %> <%= translated_attribute(answer_option["body"]) %> <% end %> <% end %>
<% when "multiple_option" %>
<% answer.question.answer_options.each_with_index do |answer_option, idx| %> <%= label_tag "#{field_id}_option_#{idx}" do %> <%= check_box_tag "survey[answers][#{answer_idx}][body][]", translated_attribute(answer_option["body"]), answer.body.try(:include?, translated_attribute(answer_option["body"])), id: "#{field_id}_option_#{idx}" %> <%= translated_attribute(answer_option["body"]) %> <% end %> <% end %>
<% end %> <%= hidden_field_tag "survey[answers][#{answer_idx}][question_id]", answer.question.id %> <% answer.errors.full_messages.each do |msg| %> <%= content_tag :small, msg, class: "form-error is-visible" %> <% end %>
<% end %>
<%= form.check_box :tos_agreement, label: t(".tos_agreement"), id: "survey_tos_agreement" %>
<%= decidim_sanitize translated_attribute survey.tos %>
<%= form.submit t(".submit"), class: "button", data: { confirm: t('.are_you_sure') } %>
<% end %>
<% end %> <% else %>
<%= t('.answer_survey.title') %>

<%= t('.answer_survey.anonymous_user_message', sign_in_link: decidim.new_user_session_path, sign_up_link: decidim.new_user_registration_path).html_safe %>

<% end %> <% else %>
<%= t('.survey_closed.title') %>

<%= t('.survey_closed.body') %>

<% end %>