course.mustache 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <%
  2. # Copyright (C) 2011 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <% course ||= nil %>
  19. <% if !course || !course.deleted? %>
  20. <% master_template = course && @master_template_index && @master_template_index[course.id] %>
  21. <% teacher_names = course && !master_template && (course.teacher_names || course.teachers.distinct.map(&:name)) %>
  22. <% student_count = course && !master_template && (course.student_count || course.students.where("enrollments.type <> ?", "StudentViewEnrollment").count) %>
  23. <li class="course" id="course_<%= course ? course.id : "blank" %>" style="<%= hidden unless course %>">
  24. <div class="course <%= 'unpublished' if course && course.read_attribute(:workflow_state) && (course.created? || course.claimed?) %>">
  25. <div class="name ellipsis">
  26. <a href="<%= course_path(course ? course.id : "{{ id }}") %>" class="name"><%= (course && course.name) || nbsp %></a>
  27. <i class="icon-unpublished" title="{{#t}}This course hasn't been published yet") %>" style="<%= (course && course.read_attribute(:workflow_state) && (course.created? || course.claimed?) ? "" : "display: none;{{/t}}"></i>
  28. </div>
  29. <% if course %>
  30. <div class="details ellipsis">
  31. <div>
  32. <span style="padding-right: 30px;">
  33. <%= show_code_and_term_for(course) %>
  34. </span>
  35. <% if course.respond_to?(:sis_source_id) && course.sis_source_id %>
  36. <%= before_label(t(:sis_id_label, "SIS ID")) %> <%= course.sis_source_id %>
  37. <% end %>
  38. </div>
  39. <% if master_template %>
  40. <strong>{{#t}}Blueprint Course{{/t}}</strong>
  41. <% if master_template.last_export_completed_at %><br><%= t('Last Pushed Update: %{last_export_at}', :last_export_at => datetime_string(master_template.last_export_completed_at)) %><% end %>
  42. <br><%= t(:associated_count, {:one => "1 Associated Course", :other => "%{count} Associated Courses"}, :count => master_template.child_course_count) %>
  43. <% else %>
  44. <% teacher_names_new = teacher_names[0, 2] %>
  45. <% teacher_names_new << t(:more_count, { :one => "1 more", :other => "%{count} more" }, :count => teacher_names.length - 2) if teacher_names.length > 2 %>
  46. <span style="display: inline-block; min-width: 80px;"><%= t(:student_count, { :one => "1 Student", :other => "%{count} Students" }, :count => student_count || 0) %></span>
  47. <%= before_label(t(:teachers_label, "Teachers")) %> <%= teacher_names.blank? ? t(:none, 'none') : teacher_names_new.to_sentence %>
  48. <% end %>
  49. </div>
  50. <% end %>
  51. <div class="info">
  52. <span class="links">
  53. <%= link_to t(:settings_link, "Settings"), course_settings_path(course ? course : "{{ id }}") %> |
  54. <%= link_to t(:statistics_link, "Statistics"), course_statistics_path(course ? course : "{{ id }}") %> |
  55. <%= link_to t(:homepage_link, "Homepage"), course_path(course ? course : "{{ id }}") %>
  56. </span>
  57. </div>
  58. </div>
  59. </li>
  60. <% end %>