<% add_decidim_meta_tags({ title: translated_attribute(survey.title), description: translated_attribute(survey.description), }) %> <%= render partial: "decidim/shared/component_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.survey_answers.each_with_index do |answer, answer_idx| %>
<%= fields_for "survey[survey_answers][#{answer_idx}]", answer do |answer_form| %> <%= render "answer", answer_form: answer_form, answer: answer, answer_idx: answer_idx %> <% 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"), disable: true } %>
<% 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 %>
<%= javascript_include_tag "decidim/surveys/surveys" %>