<%
# 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/>.
%>

<% rubric_summary_criterion ||= nil; criterion = rubric_summary_criterion || nil; assessing ||= false; brief ||= false; assessment_rating ||= nil %>
<% @empty_rating ||= [OpenObject.new(:id => "blank", :description => t(:full_marks, "Full Marks"), :points => 5), OpenObject.new(:id => "blank_2", :description => t(:no_marks, "No Marks"), :points => 0)] %>
<tr id="criterion_<%= criterion ? criterion.id : "blank" %>" class="criterion <%= "blank" unless criterion %> criterion_<%= criterion ? criterion.id : "blank" %> <%= 'ignore_criterion_for_scoring' if criterion && criterion.ignore_for_scoring %> <%= 'learning_outcome_criterion' if criterion && criterion.learning_outcome_id %>">
  <td class="criterion_description">
    <% if criterion && criterion.learning_outcome_id.present? %>
      <i class="learning_outcome_flag icon-outcomes" aria-hidden="true"></i>
      <span class="screenreader-only"><%= t("This criterion is linked to a Learning Outcome") %></span>
    <% end %>
    <span class="description_title"><%= criterion ? CanvasTextHelper.truncate_text(criterion.description, :max_length => 50) : t('defaults.description', "Description of criterion") %></span>
    <span class="learning_outcome_id" style="display: none;"><%= criterion.learning_outcome_id rescue nbsp %></span>
    <span class="criterion_id" style="display: none;"><%= criterion && criterion.id %></span>
    <div class="long_description_holder editing <%= 'empty' if !criterion || !criterion.long_description || criterion.long_description.empty? %>">
      <a href="#" class="long_description_link"><%= t 'links.view_longer_description', "view longer description" %></a>
      <textarea aria-label="<%= t 'labels.long_description', "Long Description" %>" class="long_description" style="display: none;"><%= h((criterion.long_description rescue '')) %></textarea>
    </div>
  </td>
  <td class="points_form">
      <div class="ratings">
      <% ratings = criterion ? criterion.ratings : @empty_rating %>
      <% ratings.each_index do |idx| %>
        <% rating = ratings[idx]; rating.edge = (idx == 0 || idx == ratings.length - 1) %>
        <div class="rating_holder"><span id="rating_<%= rating.id %>" class="rating <%= "edge_rating" if rating.edge %>"><%= rating.description %></span></div>
      <% end %>
      </div>
      <div class="rating description" style="<%= hidden unless criterion %>"><%= assessment_rating ? assessment_rating.description : "" %></div>
      <% comments = assessment_rating.comments if assessment_rating && assessment_rating.comments_enabled %>
      <a
        href="#"
        class="rating_comments_dialog_link"
        title="<%= t 'titles.full_comments', "Click to see full comments" %>"
        style="margin-top: 5px;"
      ><span class="rating rating_custom"><%= comments || "" %></span></a>
      <div class="displaying">
        <span class="nobr x_out_of_x">
          <% ot(:out_of_points, "%{points}/%{total} pts", :points => capture { %>
            <span class="criterion_points" style="<%= hidden if brief %>"><%= assessing ? (assessment_rating ? I18n.n(assessment_rating.points) : "") : (criterion ? I18n.n(criterion.points) : I18n.n(5)) %></span><% }, :total => capture { %>
            <span class="criterion_points_possible"><%= criterion ? I18n.n(criterion.points) : I18n.n(5) %></span><% }) %>
        </span>
      </div>
      <div class="ignoring">
        <span class="x_out_of_x"> -- </span>
      </div>
  </td>
</tr>
