<%
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<tr class="<%= 'kept' if kept %>">
  <th scope="row" class="ic-Table--header-row">
    <% if kept %>
      <%= t 'kept', 'KEPT' %>
    <% elsif version.version_number == @submission.version_number %>
      <%= t 'latest', 'LATEST' %>
    <% end %>
  </th>
  <td>
    <a href="<%= course_quiz_history_path(@context, @quiz, version: version.version_number)%>">
      <%= t 'attempt_number', 'Attempt %{att_no}', :att_no => index %>
    </a>
  </td>
  <td>
    <%= duration_in_minutes((version.finished_at || version.end_at || version.started_at) - version.started_at) %>
  </td>

  <% if submission_has_regrade?(@submission) && version.score_before_regrade.present? %>
    <td>
      <%= score_out_of_points_possible(version.score_before_regrade, params[:preview] ? version.points_possible_at_submission_time : @quiz.points_possible) %>
      <%= '*' if version.pending_review? %>
    </td>
    <td class="regraded">
      <%= score_out_of_points_possible(version.score, params[:preview] ? version.points_possible_at_submission_time : @quiz.points_possible) %>
      <%= '*' if version.pending_review? %>
    </td>

  <% elsif submission_has_regrade?(@submission) %>
    <td>
      <%= score_out_of_points_possible(version.score, params[:preview] ? version.points_possible_at_submission_time : @quiz.points_possible) %>
      <%= '*' if version.pending_review? %>
    </td>
    <td class="regraded">-</td>

  <% else %>
    <td>
      <%= score_out_of_points_possible(version.score, params[:preview] ? version.points_possible_at_submission_time : @quiz.points_possible) %>
      <%= '*' if version.pending_review? %>
    </td>
  <% end %>
</tr>
