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

<% provide :page_title, t(:page_title, "Rubrics") %>
<% add_crumb t('#crumbs.rubrics', "Rubrics") %>
<% provide :right_side do %>
  <a href="<%= context_url(@context, :context_rubrics_url) %>" class="btn button-sidebar-wide add_rubric_link">
    <i class="icon-add"></i>
    <%= t('buttons.add_rubric', 'Add Rubric') %>
  </a>
<% end %>

<% js_bundle :edit_rubric %>
<% css_bundle :learning_outcomes %>

<h1><%= t 'headings.user_rubrics', 'User Rubrics' %></h1>
<a href="<%= context_url(@context, :context_rubrics_url) %>" id="add_rubric_url" style="display: none;">&nbsp;</a>
<div id="rubrics" class="raw_listing">
  <ul>
  <% @rubrics.each do |rubric| %>
    <li>
      <a href="<%= context_url(rubric.context, :context_rubric_url, rubric.id) %>" class="title"><%= rubric.title %></a>
      <span class="links">
        <% if can_do(rubric, @current_user, :update) %>
          <a href="<%= context_url(rubric.context, :context_rubric_url, rubric.id) %>#edit" class="no-hover"><%= image_tag "edit.png", :alt => t('Edit') %></a>
        <% end %>
        <% if rubric.context == @context %>
          <a href="<%= context_url(@context, :context_rubric_url, rubric.id) %>" class="delete_rubric_link no-hover" title="<%= t('delete_rubric', 'Delete Rubric') %>"><%= image_tag "delete.png", :alt => t('Delete Rubric') %></a>
        <% elsif can_do(rubric, @current_user, :delete) %>
          <a href="<%= context_url(@context, :context_rubric_url, rubric.id) %>" class="delete_rubric_link no-hover remove_link" title="<%= t('remove_rubric', 'Remove this Rubric from my list') %>"><%= image_tag "delete_circle.png", :alt => t('Remove this Rubric from my list') %></a>
        <% end %>
      </span>
      <span class="details">
        <%= t({:one => "1 criterion", :other => "%{count} criteria"}, :count => rubric.criteria.length) %><br/>
        <%= t('points_possible', {:one => "1 point possible", :other => "%{count} points possible"}, :count => round_if_whole(rubric.points_possible)) %>
      </span>
    </li>
  <% end %>
  </ul>
  <div style="display: none;" id="rubric_parameters">
    <input type="hidden" name="rubric_association[association_type]" value="<%= @context.class.to_s %>"/>
    <input type="hidden" name="rubric_association[association_id]" value="<%= @context.id %>"/>
    <input type="hidden" name="rubric_association[purpose]" value="bookmark"/>
  </div>
  <span class="current_user_id" style="display: none;"><%= @current_user.id %></span>
  <a href="<%= context_url(@context, :context_rubrics_url) %>" class="add_rubric_association_url" style="display: none;">&nbsp;</a>
</div>
<%= render :partial => "shared/find_outcome", :locals => {:context => @domain_root_account} %>
<%= render :partial => "shared/rubric", :object => nil %>
<%= render :partial => "shared/rubric_criterion_dialog" %>
