<% add_decidim_meta_tags({ title: translated_attribute(questionnaire.title), description: translated_attribute(questionnaire.description), }) %> <% columns = allow_answers? && visitor_can_answer? && @form.responses.map(&:question).any?(&:matrix?) ? 9 : 6 %> <%= render partial: "decidim/shared/component_announcement" if current_component.manifest_name == "surveys" %>

<%= translated_attribute questionnaire.title %>

<%= decidim_sanitize_editor translated_attribute questionnaire.description %>
<% unless questionnaire_for.try(:component)&.try(:published?) %>

<%= t(".questionnaire_not_published.body") %>

<% end %> <% if allow_answers? %> <% if visitor_can_answer? %> <% if visitor_already_answered? %>

<%= t(".questionnaire_answered.title") %>

<%= t(".questionnaire_answered.body") %>

<% else %>
<% unless current_participatory_space.can_participate?(current_user) %>

<%= t(".questionnaire_for_private_users.title") %>

<%= t(".questionnaire_for_private_users.body") %>

<% end %> <%= decidim_form_for(@form, url: update_url, method: :post, html: { multipart: true, class: "form answer-questionnaire" }, data: { "safe-path" => form_path }) do |form| %> <%= form_required_explanation %> <%= invisible_captcha %> <% answer_idx = 0 %> <% cleaned_answer_idx = 0 %> <% @form.responses_by_step.each_with_index do |step_answers, step_index| %>
" data-toggler=".hide"> <% if @form.total_steps > 1 %>

<%= t(".current_step", step: step_index + 1) %> <%= t(".of_total_steps", total_steps: @form.total_steps) %>

<% end %> <% step_answers.each do |answer| %>
<% answer.question.display_conditions.each do |display_condition| %> <%= content_tag :div, nil, class: "display-condition", data: display_condition.to_html_data %> <% end %> <%= fields_for "questionnaire[responses][#{answer_idx}]", answer do |answer_form| %> <%= render( "decidim/forms/questionnaires/answer", answer_form: answer_form, answer: answer, answer_idx: answer_idx, cleaned_answer_idx: cleaned_answer_idx, disabled: !current_participatory_space.can_participate?(current_user) ) %> <% end %>
<% if !(answer.question.separator? || answer.question.title_and_description?) %> <% cleaned_answer_idx += 1 %> <% end %> <% answer_idx += 1 %> <% end %> <% if step_index + 1 == @form.total_steps %> <% if show_represent_user_group? %>
<%= cell("decidim/represent_user_group", form) %>
<% end %> <% if show_public_participation? %>
<%= cell("decidim/public_participation", form) %>
<% end %>
<%= form.check_box :tos_agreement, label: t(".tos_agreement"), id: "questionnaire_tos_agreement", disabled: !current_participatory_space.can_participate?(current_user) %>
<%= decidim_sanitize_editor translated_attribute questionnaire.tos %>
<% end %> <%= cell( "decidim/forms/step_navigation", step_index, total_steps: @form.total_steps, button_disabled: !current_participatory_space.can_participate?(current_user), form: form ) %>
<% end %> <% end %>
<% end %> <% else %>

<%= t(".answer_questionnaire.title") %>

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

    <%= cell("decidim/forms/question_readonly", collection: @questionnaire.questions.not_conditioned) %>
<% end %> <% else %>

<%= t(".questionnaire_closed.title") %>

<%= t(".questionnaire_closed.body") %>

<% end %>
<%= javascript_pack_tag "decidim_forms" %>