statistics.mustache 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. <%
  19. @active_tab = 'settings'
  20. css_bundle :statistics
  21. add_crumb t('#crumbs.stats', "Statistics")
  22. %>
  23. <% content_for :page_title, join_title(t(:page_title, "Course Statistics"), @context.name) %>
  24. <div style="padding: 0 20px;" id="stats">
  25. <h1><%= t 'headings.stats', 'Statistics for %{course}', :course => @context.name %></h1>
  26. <% active_students = @context.participating_students.where("enrollments.type<>'StudentViewEnrollment'").enrolled_before(@range_end).count %>
  27. <% inactive_students = @context.student_enrollments.before(@range_end).select{|e| e.invited? }.length %>
  28. <% active_topics = @context.discussion_topics.active.before(@range_end).pluck(:id) %>
  29. <% total_topics = active_topics.length %>
  30. <% total_entries = DiscussionEntry.active.where(:discussion_topic_id => active_topics).count %>
  31. <% new_topics = @context.discussion_topics.active.before(@range_end).select{|t| t.created_at > @range_start}.length %>
  32. <% new_entries = DiscussionEntry.active.after(@range_start).where(:discussion_topic_id => active_topics).count %>
  33. <% new_assignments = @context.assignments.active.before(@range_end).select{|a| a.expects_submission? && a.created_at > @range_start }.length %>
  34. <% new_submissions = @context.submissions.before(@range_end).having_submission.where('submitted_at > ?', @range_start).count %>
  35. <% total_assignments = @context.assignments.active.before(@range_end).select{|a| a.expects_submission? }.length %>
  36. <% total_submissions = @context.submissions.before(@range_end).having_submission.count %>
  37. <%
  38. rubric_associations = @context.rubric_associations.bookmarked.before(@range_end).distinct.pluck(:rubric_id)
  39. %>
  40. <div id="reports-tabs" style="display:none;">
  41. <ul>
  42. <li><a href="#tab-totals">{{#t}}Totals{{/t}}</a></li>
  43. <li><a href="#tab-assignments">{{#t}}Assignments{{/t}}</a></li>
  44. <li><a href="#tab-students" id="students_stats_tab">{{#t}}Students{{/t}}</a></li>
  45. <li><a href="#tab-files">{{#t}}File Storage{{/t}}</a></li>
  46. </ul>
  47. <div class="stats" id="tab-totals">
  48. <h2>{{#t}}Running Totals{{/t}}</h2>
  49. <table>
  50. <tr>
  51. <td>{{#t}}Discussions{{/t}}</td>
  52. <td><%= total_topics %></td>
  53. </tr><tr>
  54. <td class="indent">{{#t}}Discussion Posts{{/t}}</td>
  55. <td class="indent"><%= total_entries %></td>
  56. </tr><tr>
  57. <td class="indent">{{#t}}New Discussions{{/t}}</td>
  58. <td class="indent"><%= new_topics %></td>
  59. </tr><tr>
  60. <td class="indent">{{#t}}New Discussion Entries{{/t}}</td>
  61. <td class="indent"><%= new_entries %></td>
  62. </tr><tr>
  63. <td>{{#t}}Assignments{{/t}}</td>
  64. <td><%= @context.assignments.active.before(@range_end).count %></td>
  65. </tr><tr>
  66. <td class="indent">{{#t}}Assignment Groups{{/t}}</td>
  67. <td class="indent"><%= @context.assignment_groups.active.before(@range_end).count %></td>
  68. </tr><tr>
  69. <td class="indent">{{#t}}Course Rubrics{{/t}}</td>
  70. <td class="indent"><%= rubric_associations.count %></td>
  71. </tr><tr>
  72. <td class="indent">{{#t}}All Rubrics{{/t}}</td>
  73. <td class="indent"><%= @context.rubrics.active.count %></td>
  74. </tr><tr>
  75. <td>{{#t}}Active Students{{/t}}</td>
  76. <td><%= active_students %></td>
  77. </tr><tr>
  78. <td class="indent">{{#t}}Unaccepted Students{{/t}}</td>
  79. <td class="indent"><%= inactive_students %></td>
  80. </tr><tr>
  81. <td>{{#t}}Quizzes{{/t}}</td>
  82. <td class="quiz_count"><%= @context.quizzes.active.before(@range_end).count %></td>
  83. </tr><tr>
  84. <td class="indent">{{#t}}Quiz Questions{{/t}}</td>
  85. <td class="indent quiz_question_count"><%= @context.quizzes.active.before(@range_end).map{|q| (q.quiz_data || []).length}.sum %></td>
  86. </tr><tr>
  87. <td class="indent">{{#t}}Quiz Submissions{{/t}}</td>
  88. <td class="indent quiz_submission_count"><%= Quizzes::QuizSubmission.where(quiz_id: @context.quizzes.active.before(@range_end)).count %></td>
  89. </tr>
  90. </table>
  91. </div>
  92. <div class="stats" id="tab-assignments">
  93. <h2>{{#t}}Assignments Usage Report{{/t}}</h2>
  94. <table>
  95. <thead><tr>
  96. <th>{{#t}}Submission Type{{/t}}</th>
  97. <th>{{#t}}# Assignments{{/t}}</th>
  98. <th>{{#t}}# Submissions{{/t}}</th>
  99. </tr>
  100. </thead>
  101. <tfoot>
  102. <tr>
  103. <th>{{#t}}New{{/t}}</th>
  104. <th><%= new_assignments %></th>
  105. <th><%= new_submissions %></th>
  106. </tr><tr>
  107. <th>{{#t}}Any{{/t}}</th>
  108. <th><%= total_assignments %></th>
  109. <th><%= total_submissions %></th>
  110. </tr></tfoot>
  111. <tbody>
  112. <tr>
  113. <td>{{#t}}File Upload{{/t}}</td>
  114. <td><%= @context.assignments.active.before(@range_end).select{|a| a.submission_types.match(/online_upload/) }.length %></td>
  115. <td><%= @context.submissions.before(@range_end).where(:submission_type => 'online_upload').count %></td>
  116. </tr><tr>
  117. <td>{{#t}}Text Entry{{/t}}</td>
  118. <td><%= @context.assignments.active.before(@range_end).select{|a| a.submission_types.match(/online_text_entry/) }.length %></td>
  119. <td><%= @context.submissions.before(@range_end).where(:submission_type => 'online_text_entry').count %></td>
  120. </tr><tr>
  121. <td>{{#t}}Website URL{{/t}}</td>
  122. <td><%= @context.assignments.active.before(@range_end).select{|a| a.submission_types.match(/online_url/) }.length %></td>
  123. <td><%= @context.submissions.before(@range_end).where(:submission_type => 'online_url').count %></td>
  124. </tr><tr>
  125. <td>{{#t}}Quiz{{/t}}</td>
  126. <td><%= @context.assignments.active.before(@range_end).select{|a| a.submission_types.match(/online_quiz/) }.length %></td>
  127. <td><%= @context.submissions.before(@range_end).where(:submission_type => 'online_quiz').count %></td>
  128. </tr><tr>
  129. <td>{{#t}}Discussion Topic{{/t}}</td>
  130. <td><%= @context.assignments.active.before(@range_end).select{|a| a.submission_types.match(/discussion_topic/) }.length %></td>
  131. <td><%= @context.submissions.before(@range_end).where(:submission_type => 'discussion_topic').count %></td>
  132. </tr>
  133. </tbody>
  134. </table>
  135. </div>
  136. <div id="tab-students">
  137. <h2>{{#t}}Recently Logged-In Users{{/t}}</h2>
  138. <ul class="item_list"></ul>
  139. </div>
  140. <div class="stats" id="tab-files">
  141. <h2>{{#t}}File Storage{{/t}}</h2>
  142. <table>
  143. <tr>
  144. <td><%= before_label('allotted_storage', %{Allotted Storage}) %></td>
  145. <td style="padding-left: 10px; text-align: right;"><%= number_to_human_size(@context.quota) %></td>
  146. <td></td>
  147. </tr>
  148. <tr>
  149. <td><%= before_label('uploaded_files', %{Uploaded Files}) %></td>
  150. <td style="padding-left: 10px; text-align: right;"><%= number_to_human_size(@files_size) %></td>
  151. <td style="padding-left: 10px; text-align: right;"><%= t 'file_count', 'file', :count => @file_count %></td>
  152. </tr>
  153. <tr>
  154. <td><%= before_label('media_files', %{Media Files}) %></td>
  155. <td style="padding-left: 10px; text-align: right;"><%= number_to_human_size(@media_files_size) %></td>
  156. <td style="padding-left: 10px; text-align: right;"><%= t 'file_count', 'file', :count => @media_file_count %></td>
  157. </tr>
  158. </table>
  159. </div>
  160. </div>
  161. </div>
  162. <% js_bundle :course_statistics %>