<commit_before><% 
  content_for :page_title, "Course Details: #{@context.name}"
  jammit_css :course_details
  jammit_js :course_details
  @active_tab = "settings"
  
  enrollment_hashes  = {} 
  ['StudentEnrollment', 'TeacherEnrollment', 'TaEnrollment', 'ObserverEnrollment'].each do |type|
    enrollment_hashes[type] = {} 
    list = @context.detailed_enrollments.select{|e| e.type == type && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue 'a' }
    if type == 'StudentEnrollment' && @context.visibility_limited_to_course_sections?(@current_user)
      user_ids = @context.students_visible_to(@current_user).map(&:id)
      list = list.select{|e| user_ids.include?(e.user_id) }
    end
    list.each{|e| enrollment_hashes[type][e.user] ||= []; enrollment_hashes[type][e.user] << e }
  end
  can_rename_course = can_do(@context.account, @current_user, :manage_courses) || !@context.root_account.settings[:prevent_course_renaming_by_teachers]
  students = enrollment_hashes['StudentEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'StudentEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  teachers = enrollment_hashes['TeacherEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'TeacherEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  tas = enrollment_hashes['TaEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'TaEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  observers = enrollment_hashes['ObserverEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'ObserverEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  has_multiple_sections = @context.course_sections.active.count > 1

  publishing_enabled = PluginSetting.settings_for_plugin('grade_export')[:enabled] == 'true'
%>
<% content_for :right_side do %>

  <div class="rs-margin-lr rs-margin-top">
    <% if can_do(@context, @current_user, :manage) %>
      <a href="<%= context_url(@context, :context_statistics_url) %>" class="button button-sidebar-wide"><%= image_tag "graph.png" %> Course Statistics</a>
      <a href="<%= calendar_url_for(@context) %>" class="button button-sidebar-wide"><%= image_tag "calendar_icon.png" %> Course Calendar</a>
    <% end %>
    
    <% if can_do(@context, @current_user, :update) %>
        <a href="<%= context_url(@context, :context_confirm_action_url, :event => 'conclude') %>" class="delete_course_link button button-sidebar-wide"><%= image_tag "delete.png" %>End this Course</a>
        <a href="<%= context_url(@context, :context_start_copy_url) %>" class="button button-sidebar-wide"><%= image_tag "file_multiple.png" %>Copy this Course</a>
        <a href="<%= context_url(@context, :context_imports_url) %>" class="button button-sidebar-wide"><%= image_tag "file_multiple.png" %>Import Content into this Course</a>
        <!--<a href="<%= context_url(@context, :course_content_exports_url) %>" class="button button-sidebar-wide"><%= image_tag "file_multiple.png" %>Export this Course</a>-->
    <% end %>
    <table class="summary" style="margin-top: 20px;">
      <thead>
      <tr>
        <th colspan="2">Current Users</th>
      </tr>
      </thead>
      <tr>
        <td>Students:</td>
        <td class="student_count"><%= students.empty? ? "None" : students.length %></td>
      </tr>
      <tr>
        <td>Teachers:</td>
        <td class="teacher_count"><%= teachers.empty? ? "None" : teachers.length %></td>
      </tr>
      <tr>
        <td>TA's:</td>
        <td class="ta_count"><%= tas.empty? ? "None" : tas.length %></td>
      </tr>
      <tr>
        <td>Observers:</td>
        <td class="observer_count"><%= observers.empty? ? "None" : observers.length %></td>
      </tr>
    </table>
  </div>
<% end %>

<div id="course_details_tabs" style="display:none;">
  <ul>
    <li><a href="#tab-details">Course Details</a></li>
    <li><a href="#tab-sections">Sections</a></li>
    <li><a href="#tab-users" id="tab-users-link">Users</a></li>
    <li><a href="#tab-navigation">Navigation</a></li>
    <li><a href="#tab-tools" id="tab-tols-link">External Tools</a></li>
    <% if publishing_enabled %>
      <li><a href="#tab-grade-publishing" id="tab-grade-publishing-link">Grade Publishing</a></li>
    <% end %>
  </ul>
  <div id="tab-details">
    <h2>Course Details</h2>
    <% form_for @context, :html => {:id => "course_form"} do |f| %>
    <table class="formtable">
      <tr>
        <td style="vertical-align: top; width: 10%;"><%= f.label :name, "Name:" %></td>
        <td style="width: 40%; vertical-align: top;" class="nobr">
          <% if can_rename_course %>
            <%= f.text_field :name, :class => "course_form", :style => "width: 150px;" %>
          <% else %>
            <span class="course_form name"><%= @context.name %></span>
          <% end %>
          <span class="course_info name"><%= @context.name %></span>
        </td>
        <% if feature_and_service_enabled?(:twitter) %>
          <td class="hashtag_form" style="<%= hidden unless @context.hashtag && @context.hashtag != "" %> vertical-align: top;"><%= f.label :hashtag, "Hashtag:" %></td>
          <td class="hashtag_form" style="<%= hidden unless @context.hashtag && @context.hashtag != "" %> width: 60%;">
            <%= f.text_field :hashtag, :class => "course_form" %>
            <span class="course_info" id="course_hashtag"><%= @context.hashtag %></span>
            <div style="font-size: 0.8em;" id="hashtag_options"><span class="course_form">
              <%= f.check_box :show_public_context_messages %>
              <%= f.label :show_public_context_messages, "collect public messages for this hashtag" %>
            </span></div>
          </td>
        <% end %>
      </tr>
      <tr>
        <td style="width: 10%; white-space: nowrap;"><%= f.label :course_code, "Course Code:" %></td>
        <td class="nobr">
          <% if can_rename_course %>
            <span class="course_form"><%= f.text_field :course_code, :style => "width: 100px;" %></span>
          <% else %>
            <span class="course_form course_code"><%= @context.course_code %></span>
          <% end %>
          <span class="course_info course_code"><%= @context.course_code %></span>
        </td>
        <% if feature_and_service_enabled?(:twitter) %>
          <td colspan="2" style=" display: none; padding-left: 10px;"><span class="course_form" style="font-size: 0.8em;">
            <a href="#" class="hashtag_dialog_link help"> What's a hashtag?</a>
            <div id="hashtag_dialog" style="display: none; font-size: 0.8em;">
              <%= image_tag "twitter.png", :style => "float: left; margin: 10px;" %>
              <p>Hashtags are special phrases that let people consistently mention the same
              idea (like a course) on web sites like Twitter.  For example, the message "I like #instructure" is
              using the hashtag "instructure".</p>
              <p>Hashtags should consist of letters, numbers, dashes and underscores (no spaces).  The 
              hashtag should be unique, easily recognizable, and short.  Short hashtags are better
              since sites like Twitter limit the number of letters per message.</p>
              <p>Examples:<br/>
              <table style="margin-left: 20px;"><tr>
                <td>too general:</td>
                <td><b> #biology</b></td>
              </tr><tr>
                <td>too long:</td>
                <td><b> #san-fransisco-university-biology-100</b></td>
              </tr><tr>
                <td>much better:</td>
                <td><b> #usu-bio100</b></td>
              </tr></table>
              </p>
              <div class="button-container">
                <button type="button" class="close_dialog_button button">Cool, Thanks</button>
              </div>
            </div>
          </span>
          </td>
        <% end %>
      <% if @context.sis_source_id %>
        </tr><tr>
          <td><%= f.label :sis_source_id, "SIS ID:" %></td>
          <td><%= @context.sis_source_id %></td>
      <% end %>
      <% if current_user_is_site_admin? %>
        </tr><tr>
          <td><%= f.label :root_account_id, "Root Account:" %></td>
          <td><%= @context.root_account.name %></td>
      <% end %>
      </tr><tr>
        <td><%= f.label :account_id, "Department:" %></td>
        <td>
          <span class="course_form">
            <% if can_do(@context.root_account, @current_user, :manage) %>
              <% if @context.root_account.all_accounts.count > 500 %>
                <a href="<%= context_url(@context.root_account, :context_sub_accounts_url, :format => :json) %>" id="course_account_id_url" style="display: none;">&nbsp;</a>
                <input type="hidden" name="course[account_id]" id="course_account_id" value="<%= @context.account_id %>"/>
                <input type="text" name="account[name]" id="course_account_id_lookup" value="<%= @context.account.name %>" style="width: 150px;"/>
              <% else %>
                <select name="course[account_id]" id="course_account_id">
                  <%= render :partial => "shared/account_options", :locals => {:account => @context.root_account} %>
                </select>
              <% end %>
            <% else %>
              <%= @context.account.name %>
            <% end %>
          </span>
          <span class="course_info account_name"><%= @context.account.name %></span>
        </td>
      </tr><tr>
        <td><%= f.label :enrollment_term_id, "Term:" %></td>
        <td>
          <span class="course_form">
            <% if can_do(@context.root_account, @current_user, :manage) %>
              <select name="course[enrollment_term_id]" id="course_enrollment_term_id">
                <% @context.root_account.enrollment_terms.sort_by{|t| t.start_at || Time.parse("Jan 1 2000")}.each do |term| %>
                  <option value="<%= term.id %>" <%= 'selected' if term.id == @context.enrollment_term_id %>><%= term.name %></option>
                <% end %>
              </select>
            <% else %>
              <%= @context.enrollment_term.name %>
            <% end %>
          </span>
          <span class="course_info term_name"><%= @context.enrollment_term.name %></span>
        </td>
      </tr><tr>
        <td style="width: 10%;"><%= f.label :start_at, "Starts:" %></td>
        <td class="nobr"><commit_msg>only show active terms on the course settings page<commit_after><% 
  content_for :page_title, "Course Details: #{@context.name}"
  jammit_css :course_details
  jammit_js :course_details
  @active_tab = "settings"
  
  enrollment_hashes  = {} 
  ['StudentEnrollment', 'TeacherEnrollment', 'TaEnrollment', 'ObserverEnrollment'].each do |type|
    enrollment_hashes[type] = {} 
    list = @context.detailed_enrollments.select{|e| e.type == type && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue 'a' }
    if type == 'StudentEnrollment' && @context.visibility_limited_to_course_sections?(@current_user)
      user_ids = @context.students_visible_to(@current_user).map(&:id)
      list = list.select{|e| user_ids.include?(e.user_id) }
    end
    list.each{|e| enrollment_hashes[type][e.user] ||= []; enrollment_hashes[type][e.user] << e }
  end
  can_rename_course = can_do(@context.account, @current_user, :manage_courses) || !@context.root_account.settings[:prevent_course_renaming_by_teachers]
  students = enrollment_hashes['StudentEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'StudentEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  teachers = enrollment_hashes['TeacherEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'TeacherEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  tas = enrollment_hashes['TaEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'TaEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  observers = enrollment_hashes['ObserverEnrollment'].map{|k, v| v[0]} #@context.detailed_enrollments.select{|e| e.type == 'ObserverEnrollment' && e.active_or_pending?}.sort_by{|e| e.user.sortable_name rescue "a" }
  has_multiple_sections = @context.course_sections.active.count > 1

  publishing_enabled = PluginSetting.settings_for_plugin('grade_export')[:enabled] == 'true'
%>
<% content_for :right_side do %>

  <div class="rs-margin-lr rs-margin-top">
    <% if can_do(@context, @current_user, :manage) %>
      <a href="<%= context_url(@context, :context_statistics_url) %>" class="button button-sidebar-wide"><%= image_tag "graph.png" %> Course Statistics</a>
      <a href="<%= calendar_url_for(@context) %>" class="button button-sidebar-wide"><%= image_tag "calendar_icon.png" %> Course Calendar</a>
    <% end %>
    
    <% if can_do(@context, @current_user, :update) %>
        <a href="<%= context_url(@context, :context_confirm_action_url, :event => 'conclude') %>" class="delete_course_link button button-sidebar-wide"><%= image_tag "delete.png" %>End this Course</a>
        <a href="<%= context_url(@context, :context_start_copy_url) %>" class="button button-sidebar-wide"><%= image_tag "file_multiple.png" %>Copy this Course</a>
        <a href="<%= context_url(@context, :context_imports_url) %>" class="button button-sidebar-wide"><%= image_tag "file_multiple.png" %>Import Content into this Course</a>
        <!--<a href="<%= context_url(@context, :course_content_exports_url) %>" class="button button-sidebar-wide"><%= image_tag "file_multiple.png" %>Export this Course</a>-->
    <% end %>
    <table class="summary" style="margin-top: 20px;">
      <thead>
      <tr>
        <th colspan="2">Current Users</th>
      </tr>
      </thead>
      <tr>
        <td>Students:</td>
        <td class="student_count"><%= students.empty? ? "None" : students.length %></td>
      </tr>
      <tr>
        <td>Teachers:</td>
        <td class="teacher_count"><%= teachers.empty? ? "None" : teachers.length %></td>
      </tr>
      <tr>
        <td>TA's:</td>
        <td class="ta_count"><%= tas.empty? ? "None" : tas.length %></td>
      </tr>
      <tr>
        <td>Observers:</td>
        <td class="observer_count"><%= observers.empty? ? "None" : observers.length %></td>
      </tr>
    </table>
  </div>
<% end %>

<div id="course_details_tabs" style="display:none;">
  <ul>
    <li><a href="#tab-details">Course Details</a></li>
    <li><a href="#tab-sections">Sections</a></li>
    <li><a href="#tab-users" id="tab-users-link">Users</a></li>
    <li><a href="#tab-navigation">Navigation</a></li>
    <li><a href="#tab-tools" id="tab-tols-link">External Tools</a></li>
    <% if publishing_enabled %>
      <li><a href="#tab-grade-publishing" id="tab-grade-publishing-link">Grade Publishing</a></li>
    <% end %>
  </ul>
  <div id="tab-details">
    <h2>Course Details</h2>
    <% form_for @context, :html => {:id => "course_form"} do |f| %>
    <table class="formtable">
      <tr>
        <td style="vertical-align: top; width: 10%;"><%= f.label :name, "Name:" %></td>
        <td style="width: 40%; vertical-align: top;" class="nobr">
          <% if can_rename_course %>
            <%= f.text_field :name, :class => "course_form", :style => "width: 150px;" %>
          <% else %>
            <span class="course_form name"><%= @context.name %></span>
          <% end %>
          <span class="course_info name"><%= @context.name %></span>
        </td>
        <% if feature_and_service_enabled?(:twitter) %>
          <td class="hashtag_form" style="<%= hidden unless @context.hashtag && @context.hashtag != "" %> vertical-align: top;"><%= f.label :hashtag, "Hashtag:" %></td>
          <td class="hashtag_form" style="<%= hidden unless @context.hashtag && @context.hashtag != "" %> width: 60%;">
            <%= f.text_field :hashtag, :class => "course_form" %>
            <span class="course_info" id="course_hashtag"><%= @context.hashtag %></span>
            <div style="font-size: 0.8em;" id="hashtag_options"><span class="course_form">
              <%= f.check_box :show_public_context_messages %>
              <%= f.label :show_public_context_messages, "collect public messages for this hashtag" %>
            </span></div>
          </td>
        <% end %>
      </tr>
      <tr>
        <td style="width: 10%; white-space: nowrap;"><%= f.label :course_code, "Course Code:" %></td>
        <td class="nobr">
          <% if can_rename_course %>
            <span class="course_form"><%= f.text_field :course_code, :style => "width: 100px;" %></span>
          <% else %>
            <span class="course_form course_code"><%= @context.course_code %></span>
          <% end %>
          <span class="course_info course_code"><%= @context.course_code %></span>
        </td>
        <% if feature_and_service_enabled?(:twitter) %>
          <td colspan="2" style=" display: none; padding-left: 10px;"><span class="course_form" style="font-size: 0.8em;">
            <a href="#" class="hashtag_dialog_link help"> What's a hashtag?</a>
            <div id="hashtag_dialog" style="display: none; font-size: 0.8em;">
              <%= image_tag "twitter.png", :style => "float: left; margin: 10px;" %>
              <p>Hashtags are special phrases that let people consistently mention the same
              idea (like a course) on web sites like Twitter.  For example, the message "I like #instructure" is
              using the hashtag "instructure".</p>
              <p>Hashtags should consist of letters, numbers, dashes and underscores (no spaces).  The 
              hashtag should be unique, easily recognizable, and short.  Short hashtags are better
              since sites like Twitter limit the number of letters per message.</p>
              <p>Examples:<br/>
              <table style="margin-left: 20px;"><tr>
                <td>too general:</td>
                <td><b> #biology</b></td>
              </tr><tr>
                <td>too long:</td>
                <td><b> #san-fransisco-university-biology-100</b></td>
              </tr><tr>
                <td>much better:</td>
                <td><b> #usu-bio100</b></td>
              </tr></table>
              </p>
              <div class="button-container">
                <button type="button" class="close_dialog_button button">Cool, Thanks</button>
              </div>
            </div>
          </span>
          </td>
        <% end %>
      <% if @context.sis_source_id %>
        </tr><tr>
          <td><%= f.label :sis_source_id, "SIS ID:" %></td>
          <td><%= @context.sis_source_id %></td>
      <% end %>
      <% if current_user_is_site_admin? %>
        </tr><tr>
          <td><%= f.label :root_account_id, "Root Account:" %></td>
          <td><%= @context.root_account.name %></td>
      <% end %>
      </tr><tr>
        <td><%= f.label :account_id, "Department:" %></td>
        <td>
          <span class="course_form">
            <% if can_do(@context.root_account, @current_user, :manage) %>
              <% if @context.root_account.all_accounts.count > 500 %>
                <a href="<%= context_url(@context.root_account, :context_sub_accounts_url, :format => :json) %>" id="course_account_id_url" style="display: none;">&nbsp;</a>
                <input type="hidden" name="course[account_id]" id="course_account_id" value="<%= @context.account_id %>"/>
                <input type="text" name="account[name]" id="course_account_id_lookup" value="<%= @context.account.name %>" style="width: 150px;"/>
              <% else %>
                <select name="course[account_id]" id="course_account_id">
                  <%= render :partial => "shared/account_options", :locals => {:account => @context.root_account} %>
                </select>
              <% end %>
            <% else %>
              <%= @context.account.name %>
            <% end %>
          </span>
          <span class="course_info account_name"><%= @context.account.name %></span>
        </td>
      </tr><tr>
        <td><%= f.label :enrollment_term_id, "Term:" %></td>
        <td>
          <span class="course_form">
            <% if can_do(@context.root_account, @current_user, :manage) %>
              <select name="course[enrollment_term_id]" id="course_enrollment_term_id">
                <% @context.root_account.enrollment_terms.active.sort_by{|t| t.start_at || Time.parse("Jan 1 2000")}.each do |term| %>
                  <option value="<%= term.id %>" <%= 'selected' if term.id == @context.enrollment_term_id %>><%= term.name %></option>
                <% end %>
              </select>
            <% else %>
              <%= @context.enrollment_term.name %>
            <% end %>
          </span>
          <span class="course_info term_name"><%= @context.enrollment_term.name %></span>
        </td>
      </tr><tr>
        <td style="width: 10%;"><%= f.label :start_at, "Starts:" %></td>
        <td class="nobr">
{'fraction_non_alphanumeric': 0.18637738702968426, 'fraction_numerical': 0.005294006428436377, 'mean_word_length': 2.86782449725777, 'pattern_counts': {'":': 0, '<': 579, '<?xml version=': 0, '>': 603, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5438291', 'n_tokens_mistral': 7308, 'n_tokens_neox': 6807, 'n_words': 1345}