%
# Copyright (C) 2019 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see .
%>
<% if @submission.can_view_plagiarism_report('vericite', @current_user, session) && @submission.turnitin_data[:provider] == :vericite &&
(vericite_score = @submission.vericite_data(true)[attachment&.asset_string] || @submission.originality_data[OriginalityReport.submission_asset_key(@submission)]) &&
vericite_score[:similarity_score] %>
<% if show_updated_icons %>
<%
asset_string = attachment&.asset_string || @submission.asset_string
url = context_url(@context, :context_assignment_submission_vericite_report_url, @submission.assignment_id, @submission.user_id, asset_string)
%>
<%=
render partial: "shared/originality_score_icon", locals: {
plagiarism_data: vericite_score,
report_title: t("Similarity score -- more information"),
report_url: url,
tooltip_text: t("See VeriCite results")
}
%>
<% else %>
<%= vericite_score[:similarity_score] %>%
<%= t(:see_vericite_results, "See VeriCite results") %>
<% end %>
<% elsif can_do(@submission, @current_user, :view_turnitin_report) &&
(turnitin_score = @submission.originality_data[attachment&.asset_string] || @submission.originality_data[OriginalityReport.submission_asset_key(@submission)]) &&
(@submission.originality_data[:provider] == nil || @submission.originality_reports.present?) &&
(turnitin_score[:similarity_score] || turnitin_score[:state] == 'pending') %>
<% if show_updated_icons %>
<%
asset_string = attachment&.asset_string || @submission.asset_string
if !@submission.has_originality_report?
url = context_url(@context, :context_assignment_submission_vericite_report_url, @submission.assignment_id, @submission.user_id, attachment.asset_string)
title = t("Similarity score")
elsif turnitin_score[:error_message].present?
url = polymorphic_url([@context, @assignment, @submission, :originality_report], asset_string: asset_string)
title = turnitin_score[:error_message]
else
url = polymorphic_url([@context, @assignment, @submission, :originality_report], asset_string: asset_string, attempt: @submission.attempt)
# This should be I18n'ed but can't be in its current form
title = I18n.t('Similarity score')
end
%>
<%=
render partial: "shared/originality_score_icon", locals: {
plagiarism_data: turnitin_score,
report_title: title,
report_url: url
}
%>
<% else %>
<% if !@submission.has_originality_report? %>
<%= turnitin_score[:similarity_score] %>%
<% else %>
<% if turnitin_score[:error_message].present? %>
<%= image_tag("turnitin_#{turnitin_score[:state]}_score.png", :alt => turnitin_score[:error_message]) %>
<% else %>
<%= turnitin_score[:similarity_score].present? ? "#{turnitin_score[:similarity_score]}%" : ' ' %>
<% end %>
<% end %>
<% end %>
<% end %>