rubric.mustache 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. rubric_association ||= nil; editable ||= false; association_object = nil; edit_view ||= false
  20. rubric ||= nil; assessing ||= false; assessment ||= nil; has_assessments ||= false
  21. for_context ||= false
  22. context = @context
  23. context = context.context if context.is_a?(Group)
  24. show_grading = !@assignment || !%w{online_quiz not_graded}.include?(@assignment.submission_types)
  25. rubric_association = assessment.rubric_association if assessment
  26. %>
  27. <% cache(['rubric_render3',
  28. (rubric.try(:cache_key) || 'no_rubric'),
  29. (rubric.try(:cache_key) || context.asset_string),
  30. (rubric_association.try(:cache_key) || 'no_association'),
  31. (assessment.try(:cache_key) || 'no_assessment'),
  32. editable,
  33. edit_view,
  34. assessing,
  35. show_grading,
  36. @domain_root_account.feature_enabled?(:rubric_criterion_range)].join('/')) do %>
  37. <div
  38. class="rubric_container rubric <%= "assessing" if assessing %> <%= "for_grading" if rubric_association.try(:use_for_grading) %>"
  39. id="<%= rubric ? "rubric_#{rubric.id}" : "default_rubric" %>"
  40. style="<%= hidden unless rubric %>"
  41. tabindex="0"
  42. >
  43. <div class="screenreader-only"><h2><%= t 'rubric', "Rubric" %></h2></div>
  44. <div class="rubric_title">
  45. <div style="float: right; <%= hidden unless editable && edit_view %>" class="links displaying">
  46. <% hash = rubric_association ? {:rubric_association_id => rubric_association.id} : {} %>
  47. <a
  48. href="<%= context_url(context, :context_rubric_url, rubric ? rubric.id : "{{ id }}", hash) %>"
  49. class="<%= 'copy_edit' if rubric && !can_do(rubric, @current_user, :update) %> edit_rubric_link no-print no-hover"
  50. style="<%= hidden unless !rubric || can_do(rubric_association, @current_user, :update) %>"
  51. title="<%= t 'links.edit', "Edit Rubric" %>"
  52. aria-label="<%= t 'links.edit', "Edit Rubric" %>"
  53. role="button"
  54. ><i class="icon-edit standalone-icon"></i></a>
  55. <a
  56. href="<%= search_rubrics_url(:q => "") %>"
  57. class="find_rubric_link no-print no-hover"
  58. style="<%= hidden unless !rubric || can_do(rubric_association, @current_user, :update) %>"
  59. title="<%= t 'links.find_another_rubric', "Find Another Rubric" %>"
  60. aria-label="<%= t 'links.find_another_rubric', "Find Another Rubric" %>"
  61. role="button"
  62. ><i class="icon-search standalone-icon"></i></a>
  63. <% if for_context %>
  64. <a
  65. href="<%= context_url(context, :context_rubric_url, rubric ? rubric.id : "{{ id }}") %>"
  66. class="delete_rubric_link no-print no-hover"
  67. style="<%= hidden unless !rubric || can_do(rubric_association, @current_user, :delete) %>"
  68. title="<%= t 'links.delete', "Delete Rubric" %>"
  69. aria-label="<%= t 'links.delete', "Delete Rubric" %>"
  70. role="button"
  71. ><i class="icon-trash standalone-icon"></i></a>
  72. <% else %>
  73. <a
  74. href="<%= context_url(context, :context_rubric_association_url, rubric_association ? rubric_association.id : "{{ rubric_association_id }}") %>"
  75. class="delete_rubric_link no-print no-hover"
  76. style="<%= hidden unless !rubric || can_do(rubric_association, @current_user, :delete) %>"
  77. title="<%= t 'links.delete', "Delete Rubric" %>"
  78. aria-label="<%= t 'links.delete', "Delete Rubric" %>"
  79. role="button"
  80. ><i class="icon-trash standalone-icon"></i></a>
  81. <% end %>
  82. <div style="display: none;">
  83. <div class="use_for_grading"><%= (rubric_association && rubric_association.use_for_grading) ? "true" : nbsp %></div>
  84. <div class="free_form_criterion_comments"><%= (rubric && rubric.free_form_criterion_comments) ? "true" : nbsp %></div>
  85. <div class="hide_score_total"><%= (rubric && rubric.hide_score_total) ? "true" : nbsp %></div>
  86. <div class="rubric_association_id"><%= rubric_association ? rubric_association.id : nbsp %></div>
  87. <div class="user_id"><%= assessment ? assessment.user_id : nbsp %></div>
  88. <div class="assessment_type"><%= assessment ? assessment.assessment_type : "" %></div>
  89. <a href="<%= context_url(context, :context_rubric_association_rubric_assessment_url, rubric_association ? rubric_association.id : "{{ rubric_association_id }}", (assessment ? assessment.id : "{{ assessment_id }}")) %>" rel="nofollow" class="edit_assessment_link">&nbsp;</a>
  90. <a href="<%= context_url(context, :context_rubric_url, "{{ rubric_id }}") %>" class="edit_rubric_url">&nbsp;</a>
  91. <% if for_context %>
  92. <a href="<%= context_url(context, :context_rubric_url, rubric ? rubric.id : "{{ id }}") %>" class="delete_rubric_url">&nbsp;</a>
  93. <% else %>
  94. <a href="<%= context_url(context, :context_rubric_association_url, "{{ association_id }}") %>" class="delete_rubric_url">&nbsp;</a>
  95. <% end %>
  96. </div>
  97. </div>
  98. <div style="float: right; font-size: 0.8em; display: none;" class="links displaying locked">
  99. <span style="<%= hidden if editable %>"><%= t 'messages.locked', "Can't change a rubric once you've started using it." %></span>
  100. <% if for_context %>
  101. <a href="<%= context_url(context, :context_rubric_url, rubric ? rubric.id : "{{ id }}") %>" class="delete_rubric_url" style="display: none;">&nbsp;</a>
  102. <% else %>
  103. <a href="<%= context_url(context, :context_rubric_association_url, "{{ association_id }}") %>" class="delete_rubric_url" style="display: none;">&nbsp;</a>
  104. <% end %>
  105. </div>
  106. <div class="editing" style="float: right;">
  107. <a href="<%= search_rubrics_url(:q => "") %>" class="find_rubric_link icon-search" style="<%= hidden unless !rubric || can_do(rubric_association, @current_user, :update) %>" title="<%= t 'titles.find_existing_rubric', "Find Existing Rubric" %>"><%= t 'links.find_a_rubric', "Find a Rubric" %></a>
  108. </div>
  109. <div class="editing" style="text-align: left">
  110. <label for="rubric-title">{{#t}}Title:{{/t}}</label>
  111. <input id="rubric-title" type="text" class="no-margin-bottom" name="title" value="<%= rubric.title rescue t('defaults.rubric_title', "Some Rubric") %>" style="width: 200px;" maxlength="255" aria-label="{{#t}}Title:{{/t}}"/>
  112. <a href="<%= search_rubrics_url(:q => "") %>" style="display: none;"><%= image_tag "find.png", :alt => '' %> <%= t 'links.find_rubric', "Find Rubric" %></a>
  113. <% if rubric_association && !rubric_association.rubric_assessments.empty? %>
  114. <div class="editing" style="font-size: 0.8em;"><%= t 'messages.rubric_in_use',
  115. { :one => "Keep in mind that 1 student has already been assessed using this rubric. Changing it will affect their evaluation.",
  116. :other => "Keep in mind that %{count} students have already been assessed using this rubric. Changing it will affect their evaluations." },
  117. :count => rubric_association.rubric_assessments.count %></div>
  118. <% end %>
  119. </div>
  120. <div class="displaying">
  121. <span class="title" tabindex="-1"><%= rubric.try(:title) || t(:rubric_title, "Title") %></span>
  122. </div>
  123. <div class="has-assessments-warning" style="<%= hidden unless edit_view && has_assessments %>">
  124. <%= t 'messages.rubric_in_use2', "You've already rated students with this rubric. Any major changes could affect their assessment results." %>
  125. </div>
  126. </div>
  127. <table class="rubric_table">
  128. <caption>
  129. <div class="screenreader-only">
  130. <span class="title"><%= rubric.try(:title) || t(:rubric_title, "Title") %></span>
  131. </div>
  132. </caption>
  133. <thead>
  134. <tr>
  135. <th scope="col"><%= t 'headers.criteria', "Criteria" %></th>
  136. <th scope="col"><%= t 'headers.ratings', "Ratings" %></th>
  137. <th scope="col"><%= t 'headers.points', "Pts" %></th>
  138. </tr>
  139. </thead>
  140. <tbody>
  141. <% if rubric && rubric.criteria %>
  142. <% rubric.criteria_object.each do |criterion| %>
  143. <% rating = assessment.ratings.find{|r| r[:criterion_id] == criterion.id} rescue nil %>
  144. {{> views/shared/rubric_criterion}}
  145. <% end %>
  146. <% end %>
  147. {{> views/shared/rubric_criterion}}
  148. <tr class="summary" style="<%= hidden if rubric_association && rubric_association.hide_score_total %>">
  149. <td colspan="4">
  150. <div style="float: right;" class="total_points_holder">
  151. <span><%= before_label :total_points, "Total Points" %>
  152. <% ot(:out_of, "%{points} *out of %{total}*", :points => capture { %>
  153. <span class="rubric_total">
  154. <%=
  155. assessment ? n(assessment.score) : n((rubric.points_possible rescue 5))
  156. %>
  157. </span>
  158. <%
  159. },
  160. wrapper: '<span class="assessing">\1</span>',
  161. total: n((rubric.points_possible rescue 5)))
  162. %>
  163. </span>
  164. </div>
  165. <div style="float: left;" class="editing">
  166. <span id="add_criterion_holder" class="criterion_link"></span>
  167. </div>
  168. <div class="clear"></div>
  169. </td>
  170. </tr>
  171. </tbody>
  172. </table>
  173. </div>
  174. <table style="display: none;">
  175. <tr id="edit_rubric">
  176. <td colspan="4">
  177. <form id="edit_rubric_form" class="edit-rubric-form no-margin-bottom">
  178. <div class="rubric_custom_ratings" style="<%= hidden unless @assignment %>">
  179. <input type="checkbox" id="rubric_custom_rating" class="rubric_custom_rating" <%= 'checked' if rubric && rubric.free_form_criterion_comments %>/>
  180. <label for="rubric_custom_rating"><%= t 'labels.custom_rating', "I'll write free-form comments when assessing students" %></label>
  181. </div>
  182. <% if show_grading %>
  183. <div class="rubric_grading" style="<%= hidden unless @assignment %>">
  184. <input type="checkbox" id="grading_rubric" class="grading_rubric_checkbox" <%= 'checked' if rubric_association && rubric_association.use_for_grading %>/>
  185. <label for="grading_rubric"><%= t 'labels.grading_rubric', "Use this rubric for assignment grading" %></label>
  186. </div>
  187. <% end %>
  188. <div class="totalling_rubric" style="<%= hidden unless @assignment %>">
  189. <input type="checkbox" id="totalling_rubric" class="totalling_rubric_checkbox" <%= 'checked' if rubric_association && rubric_association.hide_score_total %>/>
  190. <label for="totalling_rubric"><%= t 'labels.totallying_rubric', "Hide score total for assessment results" %></label>
  191. </div>
  192. <div class="ic-Action-header ic-Action-header--half-margin">
  193. <div class="ic-Action-header__Primary">
  194. <button type="button" class="Button cancel_button"><%= t '#buttons.cancel', "Cancel" %></button>
  195. <button type="submit" class="Button Button--primary save_button"><%= t 'buttons.create', "Create Rubric" %></button>
  196. </div>
  197. </div>
  198. </form>
  199. </td>
  200. </tr>
  201. </table>
  202. <% end %>