<%
  content_for :title, "Summary - Skills Assessment"
  content_for :footer_title, "Skills Assessment"
  content_for :progress, @status.progress.to_s
  content_for_javascript_once 'summary-edit' do
    javascript_include_tag "summary-edit"
  end
%>

<h1>Almost done!</h1>
<p>
  Now's the time to review your answers and go back and change any, if you need to.
  Once you're done, hit the button at the bottom of the page to submit your answers.
</p>

<hr>

<% @quiz.each do |question| %>
  <%= form_for(:answer, remote: true, url: post_answer_path(answer_id: question.answer_id), html:{class: ""}) do |form| %>
    <h2><%= question.question %></h2>

    <% if question.attachment.present? %>
      <figure>
        <%= image_tag question.attachment %>
      </figure>
    <% end %>

    <fieldset disabled>
      <%= render partial: question.input_type, locals: {question: question, form: form, answer: question.answer} %>
    </fieldset>

    <ul class="summary-question-controls">
      <li><%= link_to('Edit', question_path(question.question_id)) %></li>
      <li><button>Save</button></li>
      <li><button>Cancel</button></li>
    </ul>

    <%= hidden_field_tag 'answer[question_id]', question.question_id %>
    <%= hidden_field_tag 'answer[answer_id]', question.answer_id %>
    <%= hidden_field_tag 'submit', true %>
  <% end %>
<% end %>


<%= form_tag post_summary_path, id: 'summary-submit', class: "" do %>
  <% unless @status.can_submit %>
    <div class="error">Sorry, you must answer all questions before you can submit.</div>
  <% end %>
  <%= submit_tag "Submit all answers", {class: "", disabled: !@status.can_submit } %>
<% end %>
