submit_assignment.mustache 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. show_google_docs = @assignment.allow_google_docs_submission? &&
  20. @real_current_user.blank? &&
  21. @domain_root_account &&
  22. feature_and_service_enabled?(:google_drive)
  23. -%>
  24. <%
  25. js_bundle :submit_assignment
  26. css_bundle :tinymce
  27. js_env({
  28. :SUBMIT_ASSIGNMENT => {
  29. :ALLOWED_EXTENSIONS => (@assignment.allowed_extensions || []),
  30. :ID => @assignment.id,
  31. :GROUP_ID_FOR_USER => @assignment.group_category.try(:group_for, @current_user).try(:id)
  32. }
  33. })
  34. %>
  35. <div style="display: none;" id="submit_assignment" data-context_code="<%= @assignment.context_code %>" data-asset_string="<%= @assignment.asset_string %>">
  36. <div class="content" id="submit_assignment_tabs">
  37. <ul>
  38. <% if @assignment.submission_types && @assignment.submission_types.match(/online_upload/) %>
  39. <li><a href="#submit_online_upload_form" class="submit_online_upload_option"><%= t 'links.submit.file_upload', "File Upload" %></a></li>
  40. <% end %>
  41. <% if @assignment.submission_types && @assignment.submission_types.match(/online_text_entry/) %>
  42. <li><a href="#submit_online_text_entry_form" class="submit_online_text_entry_option"><%= t 'links.submit.text_entry', "Text Entry" %></a></li>
  43. <% end %>
  44. <% if @assignment.submission_types && @assignment.submission_types.match(/online_url/) %>
  45. <li><a href="#submit_online_url_form" class="submit_online_url_option"><%= t 'links.submit.website', "Website URL" %></a></li>
  46. <% end %>
  47. <% if show_google_docs %>
  48. <li><a href="#submit_google_doc_form" class="submit_online_url_option"><%= t 'links.submit.google_doc', 'Google Doc' %></a></li>
  49. <% end %>
  50. <% if @assignment.submission_types && @assignment.submission_types.match(/media_recording/) %>
  51. <li><a href="#submit_media_recording_form" class="submit_media_recording_option"><%= t 'links.submit.media', "Media" %></a></li>
  52. <% end %>
  53. <% (@external_tools[0,3] || []).each do |external_tool| %>
  54. <li><a href="#submit_from_external_tool_form_<%= external_tool.id %>"
  55. class="external-tool"
  56. data-id="<%= external_tool.id %>"
  57. data-name="<%= external_tool.name %>"><%= external_tool.label_for(:homework_submission, I18n.locale) %></a></li>
  58. <% end %>
  59. <% if @external_tools.length > 3 %>
  60. <li><a href="#submit_from_external_tool_form" class="submit_from_external_tool_option"><%= t 'links.submit.external_tool', "More" %></a></li>
  61. <% end %>
  62. </ul>
  63. <% if @assignment.submission_types && @assignment.submission_types.match(/online_upload/) %>
  64. <%= form_tag(context_url(@context, :controller => :submissions, :assignment_id => @assignment.id, :action => :create), {:id => "submit_online_upload_form", :class => "submit_assignment_form", :multipart => true }) do %>
  65. <%= hidden_field :submission, :submission_type, :value => "online_upload" %>
  66. <%= hidden_field :submission, :attachment_ids, :value => "", :id => "submission_attachment_ids" %>
  67. <table class="formtable" style="width: 100%;">
  68. <tr>
  69. <td colspan="2">
  70. <%= t :upload_or_choose_file, "Upload a file, or choose a file you've already uploaded." %>
  71. {{> views/assignments/group_submission_reminder}}
  72. </td>
  73. </tr><tr>
  74. <td><%= blabel :attachment, :uploaded_data, :en => "File", id: 'attachmentLabel' %></td>
  75. <td>
  76. <a href="#" class="add_another_file_link">
  77. <i class="icon-add" aria-hidden="true"></i>
  78. <%= t 'links.add_another_file', "Add Another File" %>
  79. </a>
  80. <div id="submission_attachment_blank" class="submission_attachment" style="display: none;">
  81. <input aria-labelledby="attachmentLabel" type="file" name="attachments[-1][uploaded_data]" class="input-file"/>
  82. <a href="#" class="remove_attachment_link no-hover" style="display: none;"><i class="icon-end" aria-hidden="true"></i></a>
  83. <% if @assignment.allowed_extensions.present? -%>
  84. <div class='bad_ext_msg error_message' style="display: none">
  85. <%= t 'errors.unacceptable_file_type', "This file type is not allowed. Accepted file types are: %{allowed_extensions_list}", :allowed_extensions_list => @assignment.allowed_extensions.to_sentence %>
  86. </div>
  87. <% end -%>
  88. </div>
  89. </td>
  90. </tr>
  91. <% unless @current_user.attachments.active.empty? %>
  92. <tr>
  93. <td></td>
  94. <td style="font-size: 0.8em;">
  95. <a href="#" class="toggle_uploaded_files_link"><%= t 'links.find_file', "Click here to find a file you've already uploaded" %></a><br/>
  96. <div id="uploaded_files" style="display: none;">
  97. <% folders = @current_user.folders.active %>
  98. <% content = (render :partial => "files/nested_content", :object => (folders.select{|f| !f.parent_folder_id}), :locals => {:folders => folders}) %>
  99. <%= t(:no_files, "No Files") if @current_user.attachments.active.empty? || !content || content.strip.empty? %>
  100. <%= content %>
  101. </div>
  102. </td>
  103. </tr>
  104. <% end %>
  105. <tr>
  106. <td colspan="2">
  107. <%= text_area :submission, :comment, :class => 'submission_comment_textarea', :placeholder => t('comments_placeholder', 'Comments...'), :title => t('additional_comments', 'Additional comments') %>
  108. </td>
  109. </tr>
  110. {{> views/group_comment}}
  111. <% if @assignment.turnitin_enabled? %>
  112. {{> views/turnitin}}
  113. <% end %>
  114. <% if @assignment.vericite_enabled? %>
  115. {{> views/vericite}}
  116. <% end %>
  117. <% if @assignment.tool_settings_tool.present? ||
  118. @assignment.vericite_enabled? ||
  119. @assignment.turnitin_enabled? %>
  120. <tr>
  121. <td colspan="2">
  122. <label class='checkbox'>
  123. <input type="checkbox" class='turnitin_pledge' name="turnitin_pledge" value="1"/>
  124. <%= @similarity_pledge %>
  125. </label>
  126. </td>
  127. </tr>
  128. <% end %>
  129. <tr>
  130. <td colspan="2" class='button-container'>
  131. <button type="button" class='cancel_button btn'><%= t '#buttons.cancel', "Cancel" %></button>
  132. <button type="submit" class="btn btn-primary" id="submit_file_button"><%= t 'buttons.submit_assignment', "Submit Assignment" %></button>
  133. </td>
  134. </tr><tr style="display: none;">
  135. <td colspan="2" style="text-align: center;">
  136. <%= t 'messages.submitting', "Submitting..." %> <img src=""/>
  137. </td>
  138. </tr>
  139. </table>
  140. <% end %>
  141. <% end %>
  142. <% if @assignment.submission_types && @assignment.submission_types.match(/online_text_entry/) %>
  143. <%= form_tag(context_url(@context, :controller => :submissions, :assignment_id => @assignment.id, :action => :create), {:id => "submit_online_text_entry_form", :class => "submit_assignment_form"}) do %>
  144. <%= hidden_field :submission, :submission_type, :value => "online_text_entry" %>
  145. <table class="formtable" style="width: 100%;">
  146. <tr>
  147. <td>
  148. <%= t 'instructions.online_text_entry', "Copy and paste or type your submission right here." %>
  149. {{> views/assignments/group_submission_reminder}}
  150. </td>
  151. </tr><tr>
  152. <td>
  153. <div style="text-align: right; font-size: 0.8em;">
  154. <a class="switch_text_entry_submission_views" href="#"><%= t '#editor.switch_editor_html', "HTML Editor" %></a>
  155. <a class="switch_text_entry_submission_views" href="#" style="display:none"><%= t '#editor.switch_editor_rich_text', "Rich Content Editor" %></a>
  156. </div>
  157. <%= text_area :submission, :body, :style => "width: 100%; height: 250px;" %>
  158. </td>
  159. </tr><tr>
  160. <td>
  161. <%= text_area :submission, :comment, :class => 'submission_comment_textarea', :placeholder => t('comments_placeholder', 'Comments...'), :title => t('additional_comments', 'Additional comments') %>
  162. </td>
  163. </tr>
  164. {{> views/group_comment}}
  165. <% if @assignment.turnitin_enabled? %>
  166. {{> views/turnitin}}
  167. <% end %>
  168. <% if @assignment.vericite_enabled? %>
  169. {{> views/vericite}}
  170. <% end %>
  171. <tr>
  172. <td class='button-container'>
  173. <button type="button" class='cancel_button btn'><%= t '#buttons.cancel', "Cancel" %></button>
  174. <button type="submit" class="btn btn-primary"><%= t 'buttons.submit_assignment', "Submit Assignment" %></button>
  175. </td>
  176. </tr>
  177. </table>
  178. <% end %>
  179. <% end %>
  180. <% if @assignment.submission_types && @assignment.submission_types.match(/online_url/) %>
  181. <%= form_tag(context_url(@context, :controller => :submissions, :assignment_id => @assignment.id, :action => :create), {:id => "submit_online_url_form", :class => "submit_assignment_form"}) do %>
  182. <%= hidden_field :submission, :submission_type, :value => "online_url" %>
  183. <table class="formtable" style="width: 100%;">
  184. <tr>
  185. <td colspan="2">
  186. <%= t 'instructions.online_url', "Copy and paste the link to the web site you'd like to submit for this assignment." %>
  187. {{> views/assignments/group_submission_reminder}}
  188. </td>
  189. </tr><tr>
  190. <td colspan="2">
  191. <%= blabel :submission, :url, :en => "Website URL" %>
  192. &nbsp;&nbsp;
  193. <%= text_field :submission, :url, :style => "min-width: 250px;" %>
  194. </td>
  195. </tr><tr>
  196. <td colspan="2" style="text-align: center;">
  197. <div style="text-align: left;">
  198. <%= text_area :submission, :comment, :class => 'submission_comment_textarea', :placeholder => t('comments_placeholder', 'Comments...'), :title => t('additional_comments', 'Additional comments') %>
  199. </div>
  200. </td>
  201. </tr>
  202. {{> views/group_comment}}
  203. <% if @assignment.turnitin_enabled? %>
  204. {{> views/turnitin}}
  205. <% end %>
  206. <% if @assignment.vericite_enabled? %>
  207. {{> views/vericite}}
  208. <% end %>
  209. <tr>
  210. <td colspan="2" class='button-container'>
  211. <button type="button" class='cancel_button btn'><%= t '#buttons.cancel', "Cancel" %></button>
  212. <button type="submit" class="btn btn-primary"><%= t 'buttons.submit_assignment', "Submit Assignment" %></button>
  213. </td>
  214. </tr>
  215. </table>
  216. <% end %>
  217. <% end %>
  218. <style>
  219. #google_docs_tree li.folder {
  220. cursor: pointer;
  221. }
  222. #google_docs_tree li.file {
  223. cursor: pointer;
  224. -moz-border-radius: 3px;
  225. width: 80%;
  226. padding-right: 20px;
  227. }
  228. #google_docs_tree li.file:hover {
  229. background-color: #eee;
  230. }
  231. ul.instTree li span.active {
  232. background: none;
  233. }
  234. #google_docs_tree li.file.leaf.active {
  235. background-color: #ddd;
  236. }
  237. #google_docs_tree li.file .filename {
  238. float: left;
  239. max-width: 98%;
  240. }
  241. #google_docs_tree li.file .popout {
  242. float: right;
  243. }
  244. </style>
  245. <% if show_google_docs %>
  246. <% if @user_has_google_drive %>
  247. <% if @domain_root_account.feature_enabled?(:google_docs_domain_restriction) &&
  248. @domain_root_account.settings[:google_docs_domain] &&
  249. !@current_user.gmail.match(%r{@#{@domain_root_account.settings[:google_docs_domain]}$}) %>
  250. <div id="submit_google_doc_form">
  251. <p class="alert alert-error">
  252. <i class="icon-warning" aria-hidden="true"></i>
  253. {{#t}}Invalid domain{{/t}}
  254. </p>
  255. <p>
  256. <%= t(:gmail_restriction_description, <<-END, domain: @domain_root_account.settings[:google_docs_domain])
  257. Your account has restricted Google Doc submissions to Google accounts
  258. on the %{domain} domain. To submit this assignment with a Google Doc,
  259. you will need to reconfigure the Google Docs integration on your
  260. user settings page.
  261. END
  262. %>
  263. </p>
  264. </div>
  265. <% else %>
  266. <%= form_tag(context_url(@context, :controller => :submissions, :assignment_id => @assignment.id, :action => :create), {:id => "submit_google_doc_form", :class => "submit_assignment_form"}) do %>
  267. <%= hidden_field :submission, :submission_type, :value => "google_doc" %>
  268. <%= hidden_field :google_doc, :document_id, :value => "", :class => "google_doc_id" %>
  269. <table class="formtable" style="width: 100%;">
  270. <tr>
  271. <td style="padding-bottom: 10px;" colspan="2">
  272. <%= t 'instructions.google_docs', "Select the file from the list below." %>
  273. {{> views/assignments/group_submission_reminder}}
  274. </td>
  275. </tr><tr>
  276. <td colspan="2">
  277. <div id="google_docs_container" style="height: 200px; overflow: auto;">
  278. <div style="text-align: center; margin: 10px;">
  279. <%= image_tag "ajax-loader-bar.gif", :alt => '' %>
  280. </div>
  281. </div>
  282. </td>
  283. </tr><tr>
  284. <td colspan="2" style="text-align: center;">
  285. <div style="text-align: left;">
  286. <%= text_area :submission, :comment, :class => 'submission_comment_textarea', :placeholder => t('comments_placeholder', 'Comments...'), :title => t('additional_comments', 'Additional comments') %>
  287. </div>
  288. </td>
  289. </tr>
  290. {{> views/group_comment}}
  291. <% if @assignment.turnitin_enabled? %>
  292. {{> views/turnitin}}
  293. <% end %>
  294. <% if @assignment.vericite_enabled? %>
  295. {{> views/vericite}}
  296. <% end %>
  297. <tr>
  298. <td colspan="2" class='button-container'>
  299. <button type="button" class='cancel_button btn'><%= t '#buttons.cancel', "Cancel" %></button>
  300. <button type="submit" class="btn btn-primary"><%= t 'buttons.submit_assignment', "Submit Assignment" %></button>
  301. </td>
  302. </tr>
  303. </table>
  304. <div id="uploading_google_doc_message" style="display: none;">
  305. <%= t 'messages.uploading', "Retrieving a copy of your Google Doc to submit for this assignment. This may take a little while, depending on the size of the file..." %>
  306. <div style="text-align: center; margin: 10px;">
  307. <%= image_tag "ajax-loader-bar.gif", :alt => '' %>
  308. </div>
  309. </div>
  310. <% end %>
  311. <% end %>
  312. <% else %>
  313. <div id="submit_google_doc_form">
  314. <%= t 'messages.google_drives_auth_required', "Before you can submit assignments directly from Google Drive you need to authorize Canvas to access your Google Drive account:" %>
  315. <div style="font-size: 1.1em; text-align: center; margin: 10px;">
  316. <a class="btn" href="<%= oauth_url(:service => :google_drive, :return_to => (request.url + "#submit_google_doc_form")) %>"><%= t 'links.authorize_google_drive', "Authorize Google Drive Access" %></a>
  317. </div>
  318. </div>
  319. <% end %>
  320. <% end %>
  321. <% if @assignment.submission_types && @assignment.submission_types.match(/media_recording/) %>
  322. <% if !feature_enabled?(:kaltura) %>
  323. <div id="submit_media_recording_form">
  324. <h3><%= t 'titles.media_recordings_disabled', "Media recordings are not enabled for this Canvas site" %></h3>
  325. <p><%= t 'messages.media_recordings_disabled', "Media recordings are not enabled for this Canvas site, and you will not be able to submit these types of assignments. Please contact your instructor about changing the settings for this assignment, or your system administrator about enabling media recordings." %></p>
  326. </div>
  327. <% else %>
  328. <%= form_tag(context_url(@context, :controller => :submissions, :assignment_id => @assignment.id, :action => :create), {:id => "submit_media_recording_form", :class => "submit_assignment_form", :multipart => true }) do %>
  329. <%= hidden_field :submission, :submission_type, :value => "media_recording" %>
  330. <%= hidden_field :submission, :media_comment_id, :value => "", :class => "media_comment_id" %>
  331. <%= hidden_field :submission, :media_comment_type, :value => "video" %>
  332. <table class="formtable" style="width: 100%;">
  333. <tr>
  334. <td colspan="2" style="padding-bottom: 10px;">
  335. <%= t 'instructions.media_recording', "Use the link below to record your submission. Click \"Save\" when you're finished and ready to submit." %>
  336. {{> views/assignments/group_submission_reminder}}
  337. </td>
  338. </tr><tr>
  339. <td>
  340. <div id="media_media_recording_submission_holder" style="font-size: 1.2em; font-weight: bold;">
  341. <div id="media_media_recording_ready" style="display: none; font-size: 1.5em;">
  342. <%= t 'messages.media_recording_ready', "Ready to Submit! Click 'Submit Assignment' button to finish."%>
  343. <div id="media_media_recording_thumbnail">
  344. <%= image_tag "media_comment.png", :alt => '' %>
  345. </div>
  346. </div>
  347. <a href="#" class="record_media_comment_link btn" style="font-size: 1.1em;"><%= image_tag "record.gif", :alt => '' %> <%= t 'buttons.record_media', "Record / Upload Media" %></a>
  348. <div id="media_media_recording_submission" style="display: none; float: left; width: auto; border: 2px solid #444;">
  349. </div>
  350. <div class="clear"></div>
  351. </div>
  352. </td>
  353. </tr>
  354. <tr>
  355. <td colspan="2" style="text-align: center;">
  356. <div style="text-align: left;">
  357. <%= text_area :submission, :comment, :class => 'submission_comment_textarea', :placeholder => t('comments_placeholder', 'Comments...'), :title => t('additional_comments', 'Additional comments') %>
  358. </div>
  359. </td>
  360. </tr>
  361. {{> views/group_comment}}
  362. <tr>
  363. <td colspan="2" class='button-container'>
  364. <button type="button" class='cancel_button btn'><%= t '#buttons.cancel', "Cancel" %></button>
  365. <button type="submit" class="btn btn-primary" disabled="disabled" id="media_comment_submit_button"><%= t 'buttons.submit_assignment', "Submit Assignment" %></button>
  366. </td>
  367. </tr><tr style="display: none;">
  368. <td colspan="2" style="text-align: center;">
  369. <%= t 'messages.submitting', "Submitting..." %> <img src=""/>
  370. </td>
  371. </tr>
  372. </table>
  373. <% end %>
  374. <% end %>
  375. <% end %>
  376. <% (@external_tools || []).each do |external_tool| %>
  377. <div id="submit_from_external_tool_form_<%= external_tool.id %>" style="padding: 5px 5px 0 5px;"></div>
  378. <% end %>
  379. <% if @external_tools.length > 3 %>
  380. <%= form_tag(context_url(@context, :controller => :submissions, :assignment_id => @assignment.id, :action => :create), {:id => "submit_from_external_tool_form", :class => "submit_assignment_form" }) do %>
  381. <%= hidden_field :submission, :submission_type, :value => "online_url", :id => 'external_tool_submission_type' %>
  382. <%= hidden_field :submission, :filename, :id => 'external_tool_filename' %>
  383. <%= hidden_field :submission, :attachment_ids, :id => 'external_tool_file_id' %>
  384. <%= hidden_field :submission, :url, :id => 'external_tool_url' %>
  385. <%= hidden_field :submission, :content_type, :id => 'external_tool_content_type' %>
  386. <a href="<%= context_url(@context, :homework_submissions_context_external_tools_url) %>" id="external_tools_url"></a>
  387. <a href="/api/v1/courses/<%= @context.id %>/assignments/<%= @assignment.id %>/submissions/<%= @current_user.id %>/files" id="homework_file_url"></a>
  388. <table role="presentation" class="formtable" style="width: 100%;">
  389. <tr>
  390. <td colspan="2">
  391. <%= t 'instructions.from_external_tool', "Select a tool from the list below to load and submit a resource provided by that tool." %>
  392. {{> views/assignments/group_submission_reminder}}
  393. </td>
  394. </tr>
  395. <tr>
  396. <td colspan="2">
  397. <ul class='tools'>
  398. <li><%= t 'loading_tools', "Loading tools..." %></li>
  399. </ul>
  400. </td>
  401. </tr>
  402. <tr>
  403. <td colspan="2">
  404. {{#t}}Submission:{{/t}}
  405. <span id="external_tool_submission_details" class='not_selected'>
  406. {{#t}}No Submission Selected{{/t}}
  407. </span>
  408. <% if @assignment.allowed_extensions.present? -%>
  409. <div class='bad_ext_msg error_message' style="display: none">
  410. <%= t 'errors.unacceptable_file_type', "This file type is not allowed. Accepted file types are: %{allowed_extensions_list}", :allowed_extensions_list => @assignment.allowed_extensions.to_sentence %>
  411. </div>
  412. <% end -%>
  413. </td>
  414. </tr><tr>
  415. <td colspan="2" style="text-align: center;">
  416. <div style="text-align: left;">
  417. <%= text_area :submission, :comment, :class => 'submission_comment_textarea', :style => "height: 16px;", :placeholder => t('comments_placeholder', 'Comments...'), :title => t('additional_comments', 'Additional comments') %>
  418. </div>
  419. </td>
  420. </tr>
  421. {{> views/group_comment}}
  422. <% if @assignment.turnitin_enabled? %>
  423. {{> views/turnitin}}
  424. <% end %>
  425. <% if @assignment.vericite_enabled? %>
  426. {{> views/vericite}}
  427. <% end %>
  428. <tr>
  429. <td colspan="2" class='button-container'>
  430. <button type="button" class="cancel_button btn"><%= t '#buttons.cancel', "Cancel" %></button>
  431. <button type="submit" class="btn btn-primary"><%= t 'buttons.submit_assignment', "Submit Assignment" %></button>
  432. </td>
  433. </tr>
  434. </table>
  435. <% end %>
  436. <% end %>
  437. </div>
  438. </div>