module_item_next.mustache 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <%
  2. # Copyright (C) 2013 - 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. module_item_next ||= nil
  20. module_item ||= module_item_next
  21. item_data ||= { published_status: 'unpublished' }
  22. completion_criteria ||= nil
  23. editable ||= false
  24. criterion = completion_criteria && completion_criteria.find{|c| c[:id] == module_item.id}
  25. @module_item_image_tags ||= {
  26. 'indent' => "<i class='icon-arrow-right'></i>".html_safe,
  27. 'outdent' => "<i class='icon-arrow-left'></i>".html_safe,
  28. 'edit' => "<i class='icon-edit'></i>".html_safe,
  29. 'delete' => "<i class='icon-end'></i>".html_safe,
  30. 'duplicate' => "<i class='icon-copy-course'></i>".html_safe,
  31. }
  32. menu_type_to_class = {
  33. :assignment_menu => Assignment,
  34. :discussion_topic_menu => DiscussionTopic,
  35. :file_menu => Attachment,
  36. :quiz_menu => Quizzes::Quiz,
  37. :wiki_page_menu => WikiPage
  38. }
  39. %>
  40. <li
  41. id="context_module_item_<%= module_item ? module_item.id : "blank" %>"
  42. style="<%= hidden unless module_item %>"
  43. class="
  44. context_module_item
  45. <%= 'student-view' if @is_student %>
  46. <%= module_item.content_type_class if module_item %>
  47. <%= 'also_assignment' if module_item && module_item.graded? %>
  48. indent_<%= module_item.try_rescue(:indent) || '0' %>
  49. <%= 'progression_requirement' if criterion %>
  50. <%= criterion[:type] if criterion %>_requirement
  51. <%= module_item.item_class if module_item %>
  52. <%= 'dupeable' if module_item&.duplicate_able? %>
  53. "
  54. >
  55. <div class="ig-row <%= 'with-completion-requirements' if criterion %> <%= 'ig-published' if module_item && module_item.published? %> <%= 'student-view' if @is_student %>">
  56. <a
  57. aria-label='<%= module_item && module_item.title %>'
  58. tabindex="-1"
  59. class="for-nvda"
  60. href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>">
  61. <%= module_item && module_item.title %>
  62. </a>
  63. <% if editable || module_item.nil? %>
  64. <div aria-hidden="true" class="ig-handle">
  65. <span
  66. class="draggable-handle move_item_link"
  67. title="{{#t}}Drag to reorder or move item to another module{{/t}}"
  68. >
  69. <i class="icon-drag-handle" aria-hidden="true"></i>
  70. </span>
  71. </div>
  72. <% end %>
  73. <span class="type_icon" title="<%= module_item_translated_content_type(module_item) %>">
  74. <span class="ig-type-icon">
  75. <i class="icon-document" aria-label="{{#t}}Item type: Document{{/t}}"></i>
  76. <i class="icon-download" aria-label="{{#t}}Item type: Download{{/t}}"></i>
  77. <i class="icon-discussion" aria-label="{{#t}}Item type: Discussion{{/t}}"></i>
  78. <i class="icon-assignment" aria-label="{{#t}}Item type: Assignment{{/t}}"></i>
  79. <i class="icon-quiz" aria-label="{{#t}}Item type: Quiz{{/t}}"></i>
  80. <i class="icon-link" aria-label="{{#t}}Item type: Link{{/t}}"></i>
  81. </span>
  82. </span>
  83. <div class="ig-info">
  84. <div class="module-item-title">
  85. <span class="item_name">
  86. <% if module_item && module_item.content_type == 'ExternalUrl' && module_item.new_tab %>
  87. <a
  88. title="<%= module_item && module_item.title %>"
  89. class="title external_url_link"
  90. target="_blank"
  91. href="<%= module_item.url %>"
  92. data-item-href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item.id %>"
  93. >
  94. <%= module_item.title %>
  95. </a>
  96. <% else %>
  97. <a
  98. title="<%= module_item && module_item.title %>"
  99. class="ig-title title"
  100. href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>"
  101. <% if item_data[:mastery_paths] && item_data[:mastery_paths][:locked] %>
  102. aria-describedby="module-item-locked-<%= module_item && module_item.id %>"
  103. <% end %>
  104. >
  105. <%= module_item && module_item.title %>
  106. </a>
  107. <% end %>
  108. <span title="<%= module_item && module_item.title %>" class="title locked_title"><%= module_item && module_item.title %></span>
  109. <span class="points_possible" style="display: none;"><%= round_if_whole(module_item.try_rescue(:assignment).try_rescue(:points_possible)) || nbsp %></span>
  110. <span class="requirement" style="display: none;">&nbsp;</span>
  111. <span class="completion_requirement" style="display: none;">&nbsp;</span>
  112. <span class="position" style="display: none;"><%= module_item && module_item.position %></span>
  113. <span class="url" style="display: none;"><%= module_item.try(:url) if editable %></span>
  114. <span class="new_tab" style="display: none;"><%= module_item.try(:new_tab) ? '1' : '0' if editable %></span>
  115. </span>
  116. </div>
  117. <div class="module_item_icons nobr">
  118. <!-- dead code? -->
  119. <span class="criterion <%= 'defined' if criterion %>">
  120. <span class="min_score" style="display: none;"><%= (criterion && criterion[:min_score]) || nbsp %></span>
  121. <span class="criterion_type" style="display: none;"><%= (criterion && criterion[:type]) || nbsp %></span>
  122. </span>
  123. <!-- /dead code -->
  124. <span class="type" style="display: none;"><%= module_item ? module_item.content_type_class : nbsp %></span>
  125. <span class="id" style="display: none;"><%= module_item ? module_item.id : nbsp %></span>
  126. <span class="graded" style="display: none;"><%= module_item && module_item.graded? ? '1' : '0' %></span>
  127. </div>
  128. <div class="ig-details">
  129. <div class="due_date_display ig-details__item"></div>
  130. <div class="points_possible_display ig-details__item"></div>
  131. <div class="requirement-description ig-details__item">
  132. <span class="completion_requirement">
  133. <span class="requirement_type min_score_requirement">
  134. <% score_display = content_tag(:span, criterion && criterion[:min_score] || nbsp, class: 'min_score') %>
  135. <span class="unfulfilled">
  136. <%= t 'min_score.unfulfilled', 'Score at least %{score}', :score => score_display %>
  137. </span>
  138. <span class="fulfilled">
  139. <%= t 'min_score.fulfilled', 'Scored at least %{score}', :score => score_display %>
  140. </span>
  141. </span>
  142. <span class="requirement_type must_view_requirement">
  143. <span class="unfulfilled">
  144. {{#t}}View{{/t}}
  145. </span>
  146. <span class="fulfilled">
  147. {{#t}}Viewed{{/t}}
  148. </span>
  149. </span>
  150. <span class="requirement_type must_mark_done_requirement">
  151. <span class="unfulfilled">
  152. <%= t 'Mark done' %>
  153. </span>
  154. <span class="fulfilled">
  155. <%= t 'Marked done' %>
  156. </span>
  157. </span>
  158. <span class="requirement_type must_contribute_requirement">
  159. <span class="unfulfilled">
  160. {{#t}}Contribute{{/t}}
  161. </span>
  162. <span class="fulfilled">
  163. {{#t}}Contributed{{/t}}
  164. </span>
  165. </span>
  166. <span class="requirement_type must_submit_requirement">
  167. <span class="unfulfilled">
  168. {{#t}}Submit{{/t}}
  169. </span>
  170. <span class="fulfilled">
  171. {{#t}}Submitted{{/t}}
  172. </span>
  173. </span>
  174. </span>
  175. </div> <!-- requirement description end -->
  176. </div>
  177. </div>
  178. <% if !editable %>
  179. <div class="module-item-status-icon"></div> <%# going to set this in JS-land, not here %>
  180. <% end %>
  181. <% if editable || module_item.nil? %>
  182. <div class="ig-admin">
  183. <span
  184. data-module-item-id="<%= module_item && module_item.id %>"
  185. data-module-type="<%= module_item && module_item.content_type_class %>"
  186. data-content-id="<%= module_item && module_item.content_id %>"
  187. class="lock-icon"
  188. >
  189. </span>
  190. <span
  191. data-module-item-name="<%= module_item && module_item.title %>"
  192. data-module-type="<%= module_item && module_item.content_type_class %>"
  193. data-content-id="<%= module_item && module_item.content_id %>"
  194. data-id="<%= module_item_publishable_id(module_item) %>"
  195. data-course-id="<%= module_item && module_item.context_id %>"
  196. data-module-id="<%= module_item && module_item.context_module_id %>"
  197. data-module-item-id="<%= module_item && module_item.id %>"
  198. data-assignment-id="<%= module_item && module_item.assignment.try(:id) %>"
  199. data-is-cyoeable="<%= module_item && cyoe_able?(module_item) %>"
  200. data-published="<%= module_item && item_data[:published_status] == 'published' %>"
  201. data-publishable="<%= module_item_publishable?(module_item) %>"
  202. data-unpublishable="<%= module_item_unpublishable?(module_item) %>"
  203. data-publish-title="<%= module_item && module_item.title ? module_item.title : '' %>"
  204. title=""
  205. data-tooltip
  206. class="publish-icon <%= item_data[:published_status] %>"
  207. >
  208. <i class="icon-<%= item_data[:published_status] %>"></i>
  209. </span>
  210. <div class="inline-block cog-menu-container">
  211. <a class="al-trigger al-trigger-gray" role="button" tabindex="0" href="#">
  212. <i class="icon-settings"></i><i class="icon-mini-arrow-down"></i>
  213. </a>
  214. <ul class="al-options">
  215. <li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="outdent_item_link" title="{{#t}}Decrease indent') %>"><%= @module_item_image_tags['outdent'] %> <%= t('Decrease indent{{/t}}</a></li>
  216. <li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="indent_item_link" title="{{#t}}Increase indent') %>"><%= @module_item_image_tags['indent'] %> <%= t('Increase indent{{/t}}</a></li>
  217. <li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="edit_item_link edit_link" title="{{#t}}Edit item details') %>"><%= @module_item_image_tags['edit'] %> <%= t('Edit{{/t}}</a></li>
  218. <li class="dupe-option" role="presentation"><a href="/api/v1<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>/duplicate" class="duplicate_item_link" title="{{#t}}Duplicate Item') %>"><%= @module_item_image_tags['duplicate'] %> <%= t('Duplicate{{/t}}</a></li>
  219. <li role="presentation">
  220. <a href="#<%= module_item ? module_item.id : "{{ id }}" %>"
  221. aria-label="{{#t}}Move this item{{/t}}"
  222. class="move_module_item_link icon-updown"
  223. title="{{#t}}Move this item{{/t}}"
  224. >{{#t}}Move to...{{/t}}</a>
  225. </li>
  226. <li role="presentation"><a href="<%= context_url(@context, :context_url) %>/modules/items/<%= module_item ? module_item.id : "{{ id }}" %>" class="delete_item_link delete_link" title="{{#t}}Remove this item from the module') %>"><i class="icon-trash"></i> <%= t('Remove{{/t}}</a></li>
  227. <% menu_type_to_class.each do |menu_type, content_class| %>
  228. <% if !module_item || module_item.content.is_a?(content_class) %>
  229. <%
  230. launch_options = {}
  231. if menu_type == :file_menu
  232. launch_options[:files] = [module_item ? module_item.content_id : "{{ content_id }}"]
  233. else
  234. launch_options[:module_items] = [module_item ? module_item.id : "{{ id }}"]
  235. end
  236. %>
  237. <%= external_tools_menu_items(@menu_tools[menu_type], {link_class: "menu_tool_link", settings_key: menu_type, in_list: true, url_params: launch_options}) %>
  238. <% end %>
  239. <% end %>
  240. </ul>
  241. </div>
  242. </div>
  243. <% end %>
  244. </div>
  245. </li>