<%
# Copyright (C) 2011 - 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/>.
%>
<%
  @use_responsive_design = @domain_root_account.feature_enabled?(:responsive_student_grades_page)

  provide :page_title, join_title(t(:page_title, "Grades for %{student}", :student => @presenter.student_name), @context.name)
%>
<%
  whatif_instructions = t("You can view your grades based on What-If scores so that you know how grades will be affected by upcoming or resubmitted assignments. You can test scores for an assignment that already includes a score, or an assignment that has yet to be graded.")

  hidden_text = t("Instructor is working on grades")
%>
<div id="grade-summary-content" style="display: none;">
  <% provide :right_side do %>
    <div id="student-grades-right-content" style="display: none;">
      <% if @exclude_total %>
        <div id="student-grades-final" class="student_assignment final_grade" style="font-size: 1.2em;">
          <%= t('labels.final_grade_hidden', "Calculation of totals has been disabled") %>
        </div>
      <% else %>
        <div class="student_assignment final_grade">
          <%= before_label(:total, "Total") %> <span class="grade"></span>
          <% if @context.grading_standard_enabled? %>
            (<span class="letter_grade" id="final_letter_grade_text">–</span>)
          <% end %>
        </div>
      <% end %>
      <% if @presenter.editable? %>
          <div id="student-grades-whatif" class="show_guess_grades student-grades-revert-guess-button">
            <button type="button" class="btn button-sidebar-wide show_guess_grades_link"> <i class="icon-check-plus"></i> <%= t("Show Saved \"What-If\" Scores") %></button>
          </div>
          <div id="student-grades-revert" class="revert_all_scores student-grades-revert-guess-button">
            <%= t("*NOTE*: This is NOT your official score.") %><br/>
            <button href="#" id="revert-all-to-actual-score" class="btn revert_all_scores_link"><i class="icon-reply-2"></i> <%= t("Revert to Actual Score") %></button>
          </div>
      <% end %>
      <div id="student-grades-show-all" class="show_all_details">
        <button type="button" class="Button" id="show_all_details_button"><%= t("Show All Details") %></button>
      </div>
      <div id="assignments-not-weighted">
        <% if @current_grading_period_id == 0 && @context.weighted_grading_periods? %>
          <%= render :partial => "courses/sidebar_periods_weighting", :object => @presenter.grading_periods %>
        <% else %>
          <%= render :partial => "courses/sidebar_weighting", :object => @presenter.groups %>
        <% end %>
        <% unless @presenter.no_calculations? %>
          <div id="only_consider_graded_assignments_wrapper" class="ic-Form-control ic-Form-control--checkbox">
            <input type="checkbox" id="only_consider_graded_assignments" checked="true"/>
            <label class="ic-Label" for="only_consider_graded_assignments"><%= t('labels.only_graded', "Calculate based only on graded assignments") %></label>
          </div>
        <% end %>
      </div>
      <% if @presenter.editable? %>
        <div id="whatif-score-description">
          <%= whatif_instructions %>
        </div>
      <% end %>
    </div>
  <% end %>

  <div id="print-grades-container" class="ic-Action-header">
    <div class="ic-Action-header__Primary">
      <h1 class="ic-Action-header__Heading">
        <%= t("Grades for %{student}", student: @presenter.student_name) %>
      </h1>
      <% if !@use_responsive_design %>
        <div class="col-xs-6" ></div>
      <% end %>
    </div>

    <div id="print-grades-button-container" class="ic-Action-header__Secondary">
      <a role="button" id="print-grades-button" class="Button print-grades icon-printer" href="javascript:window.print()">
        <%= t("Print Grades") %>
      </a>
    </div>
  </div>

  <div id="GradeSummarySelectMenuGroup"></div>
  <% if @context.feature_enabled?(:student_outcome_gradebook) %>
    <ul id="navpills">
      <li><a href="#assignments"><%= t :assignments, "Assignments" %></a></li>
      <li><a href="#outcomes"><%= t :learning_outcomes, "Learning Mastery" %></a></li>
    </ul>
    <div class="outcome-toggles">
      <a class="btn btn-small icon-collapse"
         title="<%= t :collapse_title, "Collapse" %>"
         disabled='disabled'
         aria-disabled='true'
         aria-controls='groups'
         href="#">
        <span class="screenreader-only"><%= t :collapse, "Collapse all learning mastery outcome groups." %></span>
      </a>
      <a class="btn btn-small icon-expand"
         title="<%= t :expand_title, "Expand" %>"
         aria-controls='groups'
         aria-disabled='false'
         href="#">
        <span class="screenreader-only"><%= t :expand, "Expand all learning mastery outcome groups." %></span>
      </a>
    </div>
    <div id="outcomes"></div>
  <% end %>

  <div id="assignments">
    <span id="aria-announcer" class="hide-text affix" aria-live="polite"></span>
  <table
    id="grades_summary"
    class="<%= 'editable' if @presenter.editable? %> ic-Table ic-Table--hover-row <%= 'ic-Table--grades-summary-table' if @use_responsive_design %>"
  >
    <% if @presenter.editable? %>
      <caption class="screenreader-only"><%= whatif_instructions %></caption>
    <% end %>
    <thead>
      <tr>
        <th scope="col"><%= t('headers.name', "Name") %></th>
        <th scope="col"><%= t('headers.due', "Due") %></th>
        <th scope="col" class="status"><%= t('Status') %></th>
        <th scope="col" class="assignment_score"><%= t('headers.score', "Score") %></th>
        <th scope="col" class="possible"><%= t('headers.out_of', "Out of") %></th>
        <th scope="col"><span class="screenreader-only"><%= t('headers.details', "Details") %></span></th>
        <th scope="col"><span class="screenreader-only"><%= t('headers.submission_progress_status', "Submission Progress Status") %></span></th>
      </tr>
    </thead>
    <% @presenter.assignment_presenters.each do |assignment_presenter| %>
      <%
         submission = assignment_presenter.submission
         assignment = assignment_presenter.assignment
      %>
    <tr class="<%= assignment_presenter.classes %>"
        data-muted="<%= assignment_presenter.hide_grade_from_student? %>"
        id="<%= "submission_" + assignment.id.to_s %>"
        <% if assignment_presenter.excused? %>
          <% excused_label = t "This assignment is excused and will not be considered in the total calculation" %>
          aria-label="<%= excused_label %>"
          title="<%= excused_label %>"
        <% end %>
        >

        <th class="title" scope="row">
          <% if assignment_presenter.is_unread? %>
            <div class="unread-grade">&nbsp;</div>
          <% end %>
          <% if assignment_presenter.show_submission_details? %>
            <a href="<%= context_url(@context, :context_assignment_submission_url, assignment, @presenter.student_id) %>"><%= assignment.title %></a>
          <% else %>
            <%= assignment.title %>
          <% end %>
          <% if assignment_presenter.group %>
            <div class="context"><%= assignment_presenter.group.name %></div>
          <% end %>
        </th>
        <td class="due">
          <% if assignment_presenter.has_no_group_weight?  %>
            <%= datetime_string(assignment.due_at, :due_date) rescue "" %>
          <% end %>
        </td>

        <td class="status" scope="row">
          <% if assignment_presenter.missing? %>
            <span class="submission-missing-pill"></span>
          <% elsif assignment_presenter.late? %>
            <span class="submission-late-pill"></span>
          <% end %>
        </td>

        <td class="assignment_score" title="<%= t(:click_to_change, "Click to test a different score") unless assignment_presenter.unchangeable? %>">
          <div style="position: relative; height: 100%;" class="score_holder">
            <% if !assignment_presenter.upload_status.present?  %>
              <% js_bundle :progress_pill %>
              <span class="assignment_presenter_for_submission" style="display: none;"><%= assignment_presenter.upload_status %></span>
              <span class="react_pill_container"></span>
            <% end %>
            <span class="tooltip">
              <span
                class="grade"
                <% unless assignment_presenter.unchangeable? %>
                  tabindex="0"
                <% end %>
              >
                <span class="tooltip_wrap right" aria-hidden="true">
                  <% if @presenter.editable? || assignment.special_class %>
                    <span class="tooltip_text score_teaser">
                      <% if assignment_presenter.hide_grade_from_student? %>
                        <%= hidden_text %>
                      <% elsif submission.try :pending_review? %>
                        <%= hidden_text %>
                      <% elsif assignment.special_class %>
                        <%= t(:total, "Total") %>
                      <% else %>
                        <%= t(:click_to_change, "Click to test a different score") %>
                      <% end %>
                    </span>
                  <% end %>
                </span>
                <% if assignment_presenter.hide_grade_from_student? %>
                  <i class="icon-off" title="<%= hidden_text %>"></i>
                <% else %>
                  <span class="screenreader-only" role="button">
                    <%= t(:click_to_change, "Click to test a different score") unless assignment_presenter.unchangeable? %>
                  </span>
                  <% if submission.try :pending_review? %>
                    <span class="screenreader-only"><%= hidden_text %></span>
                  <% end %>
                  <%= student_score_display_for(submission, !can_do(@context, @current_user, :manage_grades)) %>
                <% end %>
              </span>
              <% if assignment_presenter.is_letter_graded_or_gpa_scaled? %>
                <span class="score_value">
                  <%= assignment_presenter.display_score %>
                </span>
              <% end %>
            </span>
            <div style="display: none;">
              <!-- Store the original points so we don't need to parse and guess at locale -->
              <span class="original_points">
                <%= assignment_presenter.original_points %>
              </span>
              <!-- Store the original score so that we can retrieve it after any "What-If" calculations -->
              <span class="original_score">
                <%= assignment_presenter.display_score %>
              </span>
              <!-- Store the current score so that it can persist between multiple "What-If" calculations -->
              <span class="what_if_score">
                <%= assignment_presenter.display_score %>
              </span>
              <!-- Load any previously saved "What-If" scores -->
              <span class="student_entered_score">
                <%= submission.student_entered_score rescue "" %>
              </span>
              <span class="submission_status">
                <%= submission.blank? ? 'none' : submission.workflow_state %>
              </span>
              <span class="assignment_group_id"><%= assignment.assignment_group_id rescue "" %></span>
              <span class="assignment_id"><%= assignment.id.to_s %></span>
              <span class="group_weight"><%= assignment.group_weight rescue "" %></span>
              <span class="rules"><%= assignment.rules rescue "" %></span>
            </div>
          </div>
        </td>
        <td class="possible points_possible">
          <%= n(round_if_whole(assignment.points_possible)) %>
        </td>
        <td class="details">
          <% if !assignment.special_class %>
          <a href="#"
              class="toggle_final_grade_info tooltip"
              aria-label="<%= t('This assignment does not count toward the final grade.') %>"
            <% if assignment.omit_from_final_grade? && !assignment_presenter.hide_grade_from_student? %>
                aria-expanded="false"
                aria-controls="final_grade_info_<%= assignment.id %>"
            <% else %>
                aria-hidden='true'
                role='presentation'
                tabindex='-1'
                style='visibility: hidden;'
            <% end %>>
            <span class="tooltip_wrap right">
              <span class="tooltip_text"><%= t("Grade Info") %></span>
            </span>
            <i class="icon-warning standalone-icon"></i>
          </a>
          <a href="#"
            class="toggle_comments_link tooltip"
            aria-label="<%= t('Read comments') %>"
            aria-describedby="comment_count_for_assignment_<%= assignment.id %>"
            <% if assignment_presenter.has_comments? && !assignment_presenter.hide_grade_from_student? %>
              aria-expanded="false"
              aria-controls="comments_thread_<%= assignment.id %>"
              role="button"
            <% else %>
              aria-hidden='true'
              role='presentation'
              tabindex='-1'
              style='visibility: hidden;'
            <% end %>>
            <span class="tooltip_wrap right">
              <span class="tooltip_text" id="comment_count_for_assignment_<%= assignment.id %>">
                <%= t("comment", count: submission&.visible_submission_comments&.size || 0) %>
              </span>
            </span>
            <i class="icon-discussion standalone-icon"></i>
          </a>
          <a href="#"
            class="toggle_score_details_link tooltip"
            aria-label="<%= t('See scoring details') %>"
          <% if assignment_presenter.has_scoring_details? && assignment_presenter.show_distribution_graph? %>
            aria-expanded="false"
            aria-controls="grade_info_<%= assignment.id %>"
          <% else %>
            aria-hidden='true'
            role='presentation'
            tabindex='-1'
            style='visibility: hidden;'
          <% end %>
          >
            <span class="tooltip_wrap right">
              <span class="tooltip_text"><%= t("See scoring details") %></span>
            </span>
            <i class="icon-check-plus standalone-icon"></i>
          </a>
          <a href="#"
            class="toggle_rubric_assessments_link tooltip"
            aria-label="<%= t('See rubric results') %>"
            aria-expanded='false'
            aria-controls="rubric_<%= assignment.id %>"
            tabindex='0'
            style="<%= 'visibility: hidden;' unless assignment_presenter.has_rubric_assessments? %>">
            <span class="tooltip_wrap right">
              <span class="tooltip_text"><%= t("See rubric results") %></span>
            </span>
            <i class="icon-rubric"></i>
          </a>
          <% if assignment_presenter.show_submission_details? %>
            <% if @presenter.turnitin_enabled? || assignment_presenter.originality_report? || assignment_presenter.turnitin %>
              <%
                turnitin = nil
                url = '#'
                anchor_title = t('Similarity score -- more information')
                alt_text = t('See Turnitin results')

                if can_do(submission, @current_user, :view_turnitin_report)
                  turnitin = assignment_presenter.turnitin
                  if assignment_presenter.is_text_entry? && !assignment_presenter.originality_report?
                    url = context_url(@context, :context_assignment_submission_turnitin_report_url, assignment.id, @presenter.student_id, submission.asset_string)
                  elsif assignment_presenter.originality_report? && turnitin
                    asset_string = assignment_presenter.file&.asset_string || assignment_presenter.submission&.asset_string
                    url = polymorphic_url([ @context, assignment, submission, :originality_report], asset_string: asset_string, attempt: submission.attempt)
                    anchor_title = turnitin[:error_message] ? turnitin[:error_message] : t('Originality Report')
                    alt_text = turnitin[:error_message] ? turnitin[:error_message] : t('Originality Report')
                  elsif assignment_presenter.is_online_upload? && assignment_presenter.file
                    asset_string = assignment_presenter.file.asset_string
                    url = context_url(@context, :context_assignment_submission_turnitin_report_url, assignment.id, @presenter.student_id, asset_string)
                  end
                end
              %>
              <% if url && url != '#' %>
                <% if @presenter.show_updated_plagiarism_icons?(turnitin) %>
                  <%=
                    render partial: "shared/originality_score_icon", locals: {
                      hide_score: false,
                      plagiarism_data: turnitin,
                      report_title: anchor_title,
                      report_url: url
                    }
                  %>
                <% else %>
                  <a title="<%= anchor_title %>" href="<%= url %>" style="<%= 'visibility: hidden;' if !turnitin %>" target="_blank" data-tooltip="left">
                    <%= turnitin ? image_tag("turnitin_#{turnitin && turnitin[:state]}_score.png", :alt => alt_text) : image_tag("blank.png", :alt => '') %>
                  </a>
                <% end %>
              <% end %>
            <% end %>
            <% if @presenter.vericite_enabled? && !assignment_presenter.originality_report? %>
              <%
                vericite = nil
                url = '#'
                if submission && submission.can_view_plagiarism_report('vericite', @current_user, session)
                  vericite = assignment_presenter.vericite
                  if assignment_presenter.is_text_entry?
                    url = context_url(@context, :context_assignment_submission_vericite_report_url, assignment.id, @presenter.student_id, submission.asset_string)
                  elsif assignment_presenter.is_online_upload? && assignment_presenter.file
                    asset_string = assignment_presenter.file.asset_string
                    url = context_url(@context, :context_assignment_submission_vericite_report_url, assignment.id, @presenter.student_id, asset_string)
                  end
                end
              %>

              <% if @presenter.show_updated_plagiarism_icons?(vericite) %>
                <%=
                  render partial: "shared/originality_score_icon", locals: {
                    hide_score: false,
                    plagiarism_data: vericite,
                    report_title: t("VeriCite similarity score -- more information"),
                    report_url: url,
                    tooltip_text: t("See VeriCite results")
                  }
                %>
              <% else %>
                <span class="turnitin_score_container" style="<%= 'visibility: hidden;' if !vericite %>">
                  <span class="vericite_score_container_caret <%= vericite && vericite[:state] %>_score"></span>
                  <a title="<%= t('titles.vericite_score', "VeriCite similarity score -- more information") %>" href="<%= url %>" target="_blank" class="tooltip not_external turnitin_similarity_score <%= vericite && vericite[:state] %>_score">
                    <%= vericite && vericite[:similarity_score] %>%
                    <span class="tooltip_wrap right">
                      <span class="tooltip_text"><%= t(:see_vericite_results, "See VeriCite results") %></span>
                    </span>
                  </a>
                </span>
              <% end %>
            <% end %>
          <% end %>
        <% end %>
        </td>
      </tr>
      <%# always add row (even if empty) so javascript references work %>
      <tr id="final_grade_info_<%= assignment.id %>"
          class="comments <%= 'assignment_graded' if assignment_presenter.graded? %>"
          style="display: none;">
        <% if assignment.omit_from_final_grade? %>
          <td colspan="6">
            <table class="score_details_table ic-Table ic-Table--condensed">
              <thead>
                <tr>
                  <th colspan="3"><%= t("Final Grade Info") %></th>
                  <th>
                    <a href="#"
                      data-aria="final_grade_info_<%= assignment.id %>"
                      aria-label="<%= t('Close grade info') %>"
                      class="screenreader-toggle pull-right">
                      <%= t("Close") %>
                    </a>
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td colspan="7"><%= t('This assignment does not count toward the final grade.') %></td>
                </tr>
              </tbody>
            </table>
          </td>
        <% end %>
      </tr>
      <tr id="grade_info_<%= assignment.id %>" class="comments grade_details <%= 'assignment_graded' if assignment_presenter.graded? %>" style="display: none;">
        <% if assignment_presenter.should_display_details? %>
          <td colspan="6" style="padding-bottom: 20px;">
            <% if assignment_presenter.has_grade_distribution? && assignment_presenter.show_distribution_graph? %>
              <table id="score_details_<%= assignment.id %>" class="ic-Table ic-Table--condensed score_details_table">
                <thead>
                  <tr>
                    <th colspan="5">
                      <%= t(:score_details, "Score Details") %>
                    </th>
                    <th>
                      <a href="#" data-aria="grade_info_<%= assignment.id %>" aria-label="<%= t(:close_score_screenreader, 'Close score details') %>" class="screenreader-toggle pull-right"><%= t(:close_score, "Close") %></a>
                    </th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <% if assignment_presenter.viewing_fake_student? %>
                      <td colspan="6">
                        <%= t(:disabled_for_student_view, "Test Student scores are not included in grade statistics.") %>
                      </td>
                    <% else %>
                      <% high, low, mean = assignment_presenter.grade_distribution %>
                      <td>
                        <%= before_label(:mean, "Mean") %>
                        <%= n(round_if_whole(mean)) %>
                      </td>
                      <td>
                        <%= before_label(:high, "High") %>
                        <%= n(round_if_whole(high)) %>
                      </td>
                      <td>
                        <%= before_label(:low, "Low") %>
                        <%= n(round_if_whole(low)) %>
                      </td>
                      <% if assignment_presenter.deduction_present? %>
                        <td>
                            <%= before_label('Score') %>
                            <%= assignment_presenter.display_entered_score %>
                        </td>
                        <td>
                          <%= before_label('Late Penalty') %>
                          <span class="error">
                            <%= assignment_presenter.display_points_deducted %>
                          </span>
                        </td>
                      <% end %>
                      <td colspan="<%= assignment_presenter.deduction_present? ? 1 : 3 %>">
                        <% graph = assignment_presenter.graph %>
                        <div style="cursor: pointer; float: <%= direction('right') %>; height: 30px; margin-<%= direction('left') %>: 20px; width: 160px; position: relative; margin-<%= direction('right') %>: 30px;" aria-hidden="true" title="<%= graph.title %>">
                          <div class="grade-summary-graph-component" style="height: 10px; margin: 5px 0px; border-width: 2px; border-<%= direction('right') %>-width: 0;">&nbsp;</div>
                          <div class="grade-summary-graph-component" style="width: <%= graph.low_width %>px; height: 0px; margin-top: 10px; border-bottom-width: 2px;">&nbsp;</div>
                          <div class="grade-summary-graph-component" style="left: <%= graph.high_left %>px; width: <%= graph.high_width %>px; height: 0px; margin-top: 10px; border-bottom-width: 2px;">&nbsp;</div>
                          <div class="grade-summary-graph-component" style="left: <%= graph.low_width %>px; width: <%= graph.mean_low_width %>px; height: 20px; border-width: 2px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; border-<%= direction('right') %>-width: 0; background: #fff;">&nbsp;</div>
                          <div class="grade-summary-graph-component" style="left: <%= graph.mean_left%>px; width: <%= graph.mean_high_width%>px; height: 20px; border-width: 2px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; background: #fff;">&nbsp;</div>
                          <div class="grade-summary-graph-component" style="left: <%= graph.max_left %>px; height: 10px; margin: 5px 0px; border-width: 2px; border-<%= direction('left') %>-width: 0;">&nbsp;</div>
                          <% if submission && submission.score %>
                            <div class="grade-summary-graph-component" style="top: 5px; height: 10px; width: 10px; left: <%= graph.score_left %>px; border: 2px solid #248; background: #abd; border-radius: 3px;" title="<%= before_label(:your_score, "Your Score") %>
                              <%= t(:submission_score, "*%{score}* out of %{possible}", :wrapper => '\1', :score => n(submission.score), :possible => n(round_if_whole(assignment.points_possible))) %>">&nbsp;
                            </div>
                          <% end %>
                        </div>
                      </td>
                    <% end %>
                  </tr>
                </tbody>
              </table>
            <% end %>
          </tr>
      <tr id="comments_thread_<%= assignment.id %>" class="comments comments_thread <%= 'assignment_graded' if assignment_presenter.graded? %>" style="display: none;">
        <td colspan="6">
          <% if !assignment_presenter.hide_grade_from_student? && assignment_presenter.has_comments? %>
              <table class="score_details_table ic-Table ic-Table--condensed">
                <thead>
                  <tr>
                    <th><%= t(:comments, "Comments") %></th>
                    <th>
                      <a href="#" data-aria="comments_thread_<%= assignment.id %>" aria-label="<%= t(:close_comments_label, 'Close comments') %>" class="screenreader-toggle pull-right"><%= t(:close_comments, "Close") %></a>
                    </th>
                  </tr>
                </thead>
                <tbody>
                  <% assignment_presenter.comments.each do |comment| %>
                    <tr>
                      <td>
                      <% if comment.media_comment_id && comment.media_comment_type %>
                        <div class="comment_media">
                          <%= t(:media_comment, "This is a media comment,") %><br/>
                          <a href="#" class="play_comment_link <%= comment.media_comment_type %>_comment"><%= t('links.click_to_view', "click here to view") %></a>
                          <span class="media_comment_id" style="display: none;"><%= comment.media_comment_id %></span>
                          <div class="media_comment_content"></div>
                        </div>
                      <% else %>
                        <span style="white-space: pre-wrap;"><%= comment.comment %></span>
                      <% end %>
                      <div style="text-align: <%= direction('right') %>; font-size: 0.8em; margin-<%= direction('right') %>: 10px; clear: both;">
                        <% comment.attachments.each do |attachment| %>
                          <div>
                            <a href="<%= context_url(@context, :context_assignment_submission_url, submission.assignment_id, submission.user_id, :download => attachment.id, :comment_id => comment.id) %>"><%= image_tag "file.png", :style => "height: 12px;", :alt => "" %><%= t('links.download', "Download %{attachment}", :attachment => attachment.display_name) %></a>
                          </div>
                        <% end %>
                      </div>
                    </td>
                    <td>
                      <%= comment_author_name_for(comment) %>,
                      <%= datetime_string(comment.created_at) %>
                    </td>
                  <% end %>
                </tr>
              </tbody>
            </table>
          <% end %>
          <% end %>
        </td>
      </tr>
      <tr id="rubric_<%= assignment.id %>" class="rubric_assessments <%= 'assignment_graded' if submission && submission.grade %>" style="display: none;">
        <% if assignment_presenter.has_rubric_assessments? %>
          <td colspan="6">
            <% assignment_presenter.rubric_assessments.each do |assessment| %>
              <div class="assessor" style="text-align: <%= direction('right') %>; margin-bottom: 5px">
                <% if assignment.anonymous_peer_reviews %>
                  <%= t("Anonymous User") %>
                <% else %>
                  <%= t("Assessment by %{name}", :name => assessment.assessor_name) %>
                <% end %>
              </div>
              <div class="rubric-toggle"><a href="#" data-aria="rubric_<%= assignment.id %>" class="screenreader-toggle pull-left"><%= t(:close_rubric, 'Close Rubric') %></a></div>
              <% if @domain_root_account.feature_enabled?(:non_scoring_rubrics)%>
                <div
                  class="react_rubric_container rubric <%= "for_grading" if assessment.rubric_association.try(:use_for_grading) %>"
                  id="<%= assessment.rubric ? "rubric_#{assessment.rubric&.id}" : "default_rubric" %>"
                  data-rubric-id="<%= assessment.rubric ? assessment.rubric.id : "default" %>"
                  data-rubric-assessment-id="<%= assessment ? assessment.id : "none" %>"
                  tabindex="0"
                >
              <% else %>
                <%= render :partial => "shared/rubric", :object => assessment.rubric, :locals => { :assessment => assessment } %>
              <% end %>
              </div>
            <% end %>
          </td>
        <% end %>
      </tr>
    <% end %>
  </table>
  </div>
  <% if @presenter.hidden_submissions? %>
    <small><i class="icon-off" role="presentation"></i><%= t(:student_mute_legend, "Your instructor is working on grades. While your instructor is working on grades, grade and comment information is unavailable.") %></small>
  <% end %>
  <div id="total_groups_weight" style="display: none;"><%= @presenter.total_weight %></div>
  <%= render :partial => "shared/rubric_criterion_dialog" %>
  <input type="text" style="width: 40px; display: none;" id="grade_entry" title="<%= t('titles.enter_score', "Enter a score to test") %>"/>
  <a href="#" id="revert_score_template" class="revert_score_link" title="<%= t('titles.revert_score', "Revert to original score") %>"><i class="icon-reply-2"></i></a>
  <a href="<%= context_url(@context, :context_assignment_submission_url, "{{ assignment_id }}", @presenter.student_id) %>" class="update_submission_url" style="display: none;">&nbsp;</a>
</div>
