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

<% if @assignment.title.nil? %>
  <% provide :page_title, t("Create Assignment") %>
<% else %>
  <% provide :page_title, t("Edit Assignment") %>
<% end %>
<% provide :right_side, render(:partial => 'shared/wiki_sidebar') %>

<%
  js_env :assignment_attempts_enabled => @context.feature_enabled?(:assignment_attempts)
  css_bundle :assignments, :assignments_edit, :conditional_release_editor, :tinymce
  js_bundle :assignment_edit
%>

<% if @assignment.omit_from_final_grade %>
  <div class="alert alert-info omit-from-final-warning">
    <%= t("This assignment does not count toward the final grade.") %>
  </div>
<% end %>

<div id="edit_assignment_header" class="<%= 'no-line' if @assignment.quiz_lti? %> header-bar"></div>

<%= render "shared/select_content_dialog", :only => [:external_tools], lti_app_placements: [Lti::ResourcePlacement::ASSIGNMENT_SELECTION, Lti::ResourcePlacement::RESOURCE_SELECTION] %>
<div id="edit_letter_grades_form" style="display: none;">
  <%= render partial: "shared/grading_standard", object: @assignment.grading_standard_or_default, locals: {read_only: false} %>
  <a href="<%= context_url(@context, :context_grading_standards_url) %>" style="display: none;" class="create_grading_standard_url">&nbsp;</a>
  <a href="<%= context_url(@context, :context_grading_standard_url, "{{ id }}") %>" style="display: none;" id="update_grading_standard_url">&nbsp;</a>
</div>

<% if @assignment.quiz_lti? && @assignment.persisted? %>
  <div class="ic-Label header-bar">
  <%= t 'links.add_rubric', "Rubric" %>
  </div>
  <% if can_do(@assignment, @current_user, :update) %>
    <div class="content-box">
      <a
        href="<%= context_url(@context, :context_rubrics_url) %>"
        class="add_rubric_link Button icon-plus"
        style="<%= hidden if @assignment.rubric_association %>"
      >
        <span aria-hidden="true"><%= t 'links.add_rubric', "Rubric" %></span>
        <span class="screenreader-only"><%= t('Add Rubric') %></span>
      </a>
    </div>
  <% end %>
  <%= render partial: "shared/rubrics_component" %>
<% end %>
