%
# 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 .
%>
<% provide :page_title, @context.name %>
<% @can_manage = can_do(@context, @current_user, :manage) %>
<% @module_dnd_FF = @domain_root_account.feature_enabled?(:module_dnd) %>
<% @can_create_announcements = @context.announcements.temp_record.grants_right?(@current_user, session, :create) %>
<% if can_do(@context, @current_user, :change_course_state) && (@context.unpublished? || @context.unpublishable?) %>
<%= t('headers.course_status', %{Course Status}) %>
<%= form_for @context, html: {id: "course_status_form"} do |f| %>
<% if @context.created? || @context.claimed? %>
<%= t('#buttons.unpublished', %{Unpublished}) %>
<%= t('#buttons.publish', %{Publish}) %>
<% else %>
<%= t('#buttons.unpublish', %{Unpublish}) %>
<%= t('#buttons.published', %{Published}) %>
<% end %>
<% end %>
<% end %>
<% if @module_dnd_FF && can_do(@context, @current_user, :manage_content) %>
<% end %>
<% if @can_manage || @can_create_announcements || @course_home_view != 'feed' || @course_home_sub_navigation_tools.present? %>
<%= external_tools_menu_items(@course_home_sub_navigation_tools, {link_class: "btn button-sidebar-wide course-home-sub-navigation-lti", settings_key: :course_home_sub_navigation}) %>
<% if @can_manage %>
<% end %>
<% if @course_home_view != 'feed' %>
<% end %>
<% if @can_manage && !@domain_root_account.try(:feature_enabled?, :new_user_tutorial) %>
<% js_bundle :course_wizard %>
<% css_bundle :course_wizard %>
<% end %>
<% if @can_create_announcements %>
<% end %>
<% if can_do(@context, @current_user, :use_student_view) && !@context.feature_enabled?(:easy_student_view) %>
<%= link_to course_student_view_path(@context), :method => :post, :class => 'btn button-sidebar-wide' do %>
<%= t('links.student_view', 'Student View') %>
<% end %>
<% end %>
<% course_custom_links.each do |link| %>
<% end %>
<% end %>
<% if @context.available? && @context.self_enrollment_enabled? && @context.open_enrollment && (!@context_enrollment || !@context_enrollment.active?) %>
<% elsif @context_enrollment && @context_enrollment.self_enrolled && @context_enrollment.active? %>
<%= t('headings.confirm_unenroll', %{Confirm Unenrollment}) %>
<%= t('details.confirm_unenroll', %{Are you sure you want to unenroll in this course? You will no longer be able to see the course roster or communicate directly with the teachers, and you will no longer see course events in your stream and as notifications.}) %>
<% end %>
<% if @context_enrollment&.student? %>
<% end %>
<% if @context_enrollment %>
<% end %>
<%= render :partial => 'to_do_list', :locals => {:contexts => [@context], :show_legacy_todo_list => !@context_enrollment&.student?} %>
<%= render :partial => "group_list", :locals => {:group_list => @user_groups} %>
<%= nbsp unless @current_user %>
<% if @course_home_view == 'assignments' %>
<%= render :partial => 'assignments/assignments_list_right_side', :locals => {:course_home => true} %>
<% elsif @course_home_view == 'syllabus' %>
<%= render :partial => 'assignments/syllabus_right_side', :locals => {:course_home => true} %>
<% elsif !@context_enrollment&.student? %>
<% locals = {:title => t("Coming Up"), :contexts_to_link_to => @context, :upcoming => true, :period => :one_week} %>
<% if @current_user %>
<% cache([@current_user, safe_cache_key(@contexts), 'course_upcoming_events' ].cache_key) do %>
<%
events = @current_user.upcoming_events(:contexts => @contexts)
assignments = events.select{|e| e.is_a?(Assignment)}
@current_user_submissions = Submission.where(:assignment_id => assignments, :user_id => @current_user).to_a if assignments.any?
%>
<%= render :partial => "shared/event_list", :object => events, :locals => locals %>
<% end %>
<% else %>
<%= render :partial => "shared/event_list", :object => [], :locals => locals %>
<% end %>
<% end %>
<% if @show_recent_feedback %>
<%= render :partial => "shared/event_list", :object => @recent_feedback, :locals => {:title => t('titles.recent_feedback', "Recent Feedback"), :contexts_to_link_to => @context, :is_recent_feedback => true} %>
<% end %>
<% end %>
<% if @pending_enrollment %>
<%= render :partial => 'shared/dashboard_invitation', :object => @pending_enrollment %>
<% end %>
<% if @context.show_announcements_on_home_page? %>
<% if @course_home_view == 'wiki' %>
<% elsif @course_home_view == 'modules' %>
<%= render :partial => 'context_modules/content_next', :locals => {:course_home => true} %>
<% elsif @course_home_view == 'assignments' %>
<% elsif @course_home_view == 'syllabus' %>
<%= render :partial => 'assignments/syllabus_content', :locals => {:course_home => true} %>
<% else %>
<%= render :partial => 'shared/dashboard_messages' %>
<%= render :partial => 'shared/recent_activity' %>
<% end %>
<% if @context.public_license? %>