show_preview.mustache 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. <% css_bundle :submission %>
  19. <% user_name = params[:hide_student_name] ? t(:anonymous_username, "This Student") : submission_author_name_for(@assessment_request) %>
  20. <% content_for :page_title do %><%= join_title @assignment.title, submission_author_name_for(@assessment_request) %><% end %>
  21. <% if @assignment.submission_types == 'discussion_topic' && @assignment.discussion_topic %>
  22. <div style="width: 600px; margin: 10px auto;">
  23. <p>
  24. <% if assignment_visible_to_user = @assignment.visible_to_user?(@current_user)%>
  25. <% if @assignment.discussion_topic.for_group_discussion? && (group = @assignment.discussion_topic.group_category.group_for(@user)) %>
  26. <%= t('group_discussion_submission_description',
  27. "The submissions for this assignment are posts in the assignment's discussion for this group. Below are the discussion posts for %{user}, or you can *view the full group discussion*.",
  28. :user => user_name,
  29. :wrapper => "<a id='discussion_view_link' href=\"#{context_url(group, :context_discussion_topics_url, :root_discussion_topic_id => @assignment.discussion_topic.id, :hide_student_names => params[:hide_student_name], :student_id => @submission.user.id, :headless => 1)}\"><b>\\1</b></a>") %>
  30. <% else %>
  31. <%= t('discussion_submission_description',
  32. "The submissions for this assignment are posts in the assignment's discussion. Below are the discussion posts for %{user}, or you can *view the full discussion*.",
  33. :user => user_name,
  34. :wrapper => "<a id='discussion_view_link' href=\"#{context_url(@assignment.context, :context_discussion_topic_url, @assignment.discussion_topic.id, :hide_student_names => params[:hide_student_name], :student_id => @submission.user.id, :headless => 1)}\"><b>\\1</b></a>") %>
  35. <% end %>
  36. <% else %>
  37. <% if @assignment.discussion_topic.for_group_discussion? && (group = @assignment.discussion_topic.group_category.group_for(@user)) %>
  38. <%= t('group_discussion_submission_description_without_link',
  39. "The submissions for this assignment are posts in the assignment's discussion for this group. Below are the discussion posts for %{user}.",
  40. :user => user_name) %>
  41. <% else %>
  42. <%= t('discussion_submission_description_without_link',
  43. "The submissions for this assignment are posts in the assignment's discussion. Below are the discussion posts for %{user}.",
  44. :user => user_name) %>
  45. <% end %>
  46. <% end %>
  47. </p>
  48. <% @entries = @assignment.discussion_topic.discussion_entries.active.for_user(@user) %>
  49. <% if @assignment.discussion_topic.for_group_discussion? %>
  50. <% @entries = @assignment.discussion_topic.child_topics.map{|t| t.discussion_entries.active.for_user(@user) }.flatten.sort_by{|e| e.created_at} %>
  51. <% end %>
  52. <% @entries.each do |entry| %>
  53. {{> views/discussion_topics/entry}}
  54. <% end %>
  55. <div style="text-align: center; font-size: 1.2em; margin-top: 10px; display: none;">
  56. <a href="<%= context_url(@assignment.context, :context_discussion_topic_url, @assignment.discussion_topic.id, :headless => 1, :combined => 1) %>" class="forward">{{#t}}Show the Entire Discussion{{/t}}</a>
  57. </div>
  58. </div>
  59. <% elsif @submission.submission_type == "online_url" %>
  60. <div style="text-align: center; width: 500px; margin: 10px auto; font-size: 0.8em;">
  61. <% image = @submission.attachment if @submission.processed? %>
  62. {{#t}}This submission was a URL to an external page.{{/t}}
  63. <% if image %>
  64. {{#t}}We've included a snapshot of what the page looked like when it was submitted.{{/t}}
  65. <% else %>
  66. {{#t}}Keep in mind that this page may have changed since the submission originally occurred.{{/t}}
  67. <% end %>
  68. <div style="font-size: 1.4em; margin: 10px;">
  69. <%= link_to @submission.url,
  70. @submission.url,
  71. class: "not_external" %>
  72. </div>
  73. <div style="font-size: 1.4em; margin: 10px;">
  74. <%= link_to t('view_in_a_new_tab', '(View in a new tab)'),
  75. @submission.url,
  76. class: "open_in_a_new_tab",
  77. target: "_blank" %>
  78. <span style="display: inline-block;" class="ui-icon ui-icon-extlink ui-icon-inline"
  79. title="{{#t}}Links to an external site.{{/t}}"/>
  80. </div>
  81. </div>
  82. <div style="text-align: center;">
  83. <% if @submission.processed %>
  84. <img src="<%= context_url(@context, :context_assignment_submission_url, @assignment.id, @submission.user_id, :download => image.id) %>" alt="{{#t}}URL Preview{{/t}}"/>
  85. <% end %>
  86. </div>
  87. <% elsif @submission.submission_type == "online_text_entry" %>
  88. <% js_bundle 'legacy/submissions_show_preview_text' %>
  89. <div style="text-align: right; margin-top: 15px;">
  90. <select class="data_view">
  91. <option aria-label="<%= t("Assignment %{assignment} submission Paper View", :assignment=> @assignment.title) %>" value="paper">{{#t}}Paper View{{/t}}</option>
  92. <option aria-label="<%= t("Assignment %{assignment} submission Plain Text View", :assignment=> @assignment.title) %>" value="plain_text">{{#t}}Plain Text View{{/t}}</option>
  93. </select>
  94. </div>
  95. <div id="submission_preview" class="paper user_content">
  96. <%= user_content(@submission.body) %>
  97. </div>
  98. <% elsif @submission.submission_type == "online_upload" %>
  99. <% if @submission.versioned_attachments.empty? %>
  100. <div class="file-upload-submission">
  101. <span>
  102. {{#t}}No files were uploaded for this submission{{/t}}
  103. </span>
  104. </div>
  105. <% else %>
  106. <% @submission.versioned_attachments.each do |attachment| %>
  107. <div class="file-upload-submission">
  108. <div class="file-upload-submission-info">
  109. <% preview_url = context_url(@context, :context_assignment_submission_url, @assignment.id, @submission.user_id, :download => attachment.id) %>
  110. <a href="<%= preview_url %>" class="<%= attachment.mime_class %> file-upload-submission-info__link">
  111. <%= attachment.display_name %>
  112. </a>
  113. <span class="file-upload-submission-info__filesize"><%= number_to_human_size(attachment.size) %></span>
  114. </div>
  115. <div class="file-upload-submission-turnitin">
  116. <% if @submission.can_view_plagiarism_report('vericite', @current_user, session) && @submission.turnitin_data[:provider] == :vericite && (vericite_score = @submission.vericite_data(true)[attachment.asset_string]) && vericite_score[:similarity_score] %>
  117. <span class="turnitin_score_container">
  118. <span class="vericite_score_container_caret <%= vericite_score[:state] %>_score"></span>
  119. <a href="<%= context_url(@context, :context_assignment_submission_vericite_report_url, @submission.assignment_id, @submission.user_id, attachment.asset_string) %>" target="_blank" title="Similarity score -- more information" class="tooltip not_external turnitin_similarity_score <%= vericite_score[:state] %>_score">
  120. <%= vericite_score[:similarity_score] %>%
  121. <span class="tooltip_wrap right">
  122. <span class="tooltip_text">{{#t}}See VeriCite results{{/t}}</span>
  123. </span>
  124. </a>
  125. </span>
  126. <% elsif can_do(@submission, @current_user, :view_turnitin_report) &&
  127. (turnitin_score = @submission.originality_data[attachment.asset_string]) &&
  128. (@submission.originality_data[:provider] == nil || @submission.originality_reports.present?) &&
  129. turnitin_score[:similarity_score] %>
  130. <span class="turnitin_score_container">
  131. <span class="turnitin_score_container_caret <%= turnitin_score[:state] %>_score"></span>
  132. <% if @submission.originality_reports.blank? %>
  133. <a href="<%= context_url(@context, :context_assignment_submission_turnitin_report_url, @submission.assignment_id, @submission.user_id, attachment.asset_string) %>" title="Similarity score -- more information" target="_blank" class="not_external turnitin_similarity_score <%= turnitin_score[:state] %>_score"><%= turnitin_score[:similarity_score] %>%</a>
  134. <% else %>
  135. <a href="<%= polymorphic_url([@context, @assignment, @submission, :originality_report], asset_string: attachment.asset_string) %>" target="_blank" title="Similarity score -- more information" class="not_external turnitin_similarity_score <%= turnitin_score[:state] %>_score"><%= turnitin_score[:similarity_score] %>%</a>
  136. <% end %>
  137. </span>
  138. <% end %>
  139. </div>
  140. <div class="file-upload-submission-attachment">
  141. <% if attachment.crocodoc_available? || attachment.canvadoc.try(:has_annotations?) %>
  142. <% preview_document = t('preview_crocodoc_document', 'Preview your submission and view teacher feedback, if available')
  143. button_text = t('view_feedback_button', 'View Feedback')
  144. %>
  145. <% elsif attachment.canvadocable? %>
  146. <% preview_document = t('preview_submission', 'Preview your submission')
  147. button_text = t('view_preview_button', 'Preview')
  148. %>
  149. <% end %>
  150. <% if attachment.crocodoc_available? || attachment.canvadocable? %>
  151. <a href=<%= preview_url %> data-tooltip title="<%= preview_document %>" class="modal_preview_link Button--link" role="button" data-attachment_id="<%= attachment.id %>" data-submission_id="<%= @submission.id %>" data-dialog-title="<%= attachment.display_name %>" <%= doc_preview_attributes(attachment, enable_annotations: true, moderated_grading_whitelist: @moderated_grading_whitelist) %>><%= button_text %></a>
  152. <% end %>
  153. </div>
  154. </div>
  155. <% end %>
  156. <% end %>
  157. <% js_bundle 'legacy/submissions_show_preview_upload' %>
  158. <% elsif @submission.submission_type == "online_quiz" %>
  159. <% content_for :stylesheets do %>
  160. <meta HTTP-EQUIV="REFRESH" content="0; url=<%= context_url(@context, :context_quiz_history_url, @assignment.quiz.id, :user_id => @submission.user_id, :hide_student_name => params[:hide_student_name], :headless => 1, :version => @submission.quiz_submission_version) %>"/>
  161. <% end %>
  162. <div style="text-align: center;">
  163. {{#t}}This submission was a quiz submission. Redirecting to quiz page.{{/t}}
  164. </div>
  165. <% elsif @submission.submission_type == 'media_recording' && @submission.media_comment_id %>
  166. {{#t}}media_comment_link', "This submission is a media recording. *click here to view.*", :wrapper => '<div><a href="#" class="play_media_recording_link" '+ dataify(@submission, :media_comment_id, :media_comment_type) + '>\1</a></div>{{/t}}
  167. <div style="width: 400px; margin: 10px auto;" id="media_recording_box">
  168. <div class="box_content">
  169. </div>
  170. </div>
  171. <div class="media_comment_id" style="display: none;"><%= @submission.media_comment_id %></div>
  172. <% js_bundle 'legacy/submissions_show_preview_media' %>
  173. <% elsif @submission.submission_type == 'basic_lti_launch' %>
  174. <meta HTTP-EQUIV="REFRESH" content="0; url=<%= retrieve_course_external_tools_url(@context.id, assignment_id: @assignment.id, display: 'borderless', url: @submission.external_tool_url) %>"/>
  175. <% elsif @submission.has_submission? || @assignment.expects_external_submission? %>
  176. <div style="margin: 20px auto; width: 400px; height: 50px; font-size: 1.5em; font-weight: bold;">
  177. {{#t}}No Preview Available{{/t}}
  178. </div>
  179. <% else %>
  180. <div style="margin: 20px auto; width: 200px; height: 50px; font-size: 1.5em; font-weight: bold;">
  181. {{#t}}No Submission{{/t}}
  182. </div>
  183. <% end %>