Skip to content

Commit e2541c8

Browse files
committed
preload originality_reports on grade_summary
(also cache the plugin checks) Change-Id: I711910adcc8da70a7475a4efc6c6f3a25af582db Reviewed-on: https://gerrit.instructure.com/106155 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
1 parent ed5eaec commit e2541c8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

app/presenters/grade_summary_presenter.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,17 @@ def editable?
5757
end
5858

5959
def turnitin_enabled?
60-
@context.turnitin_enabled? && assignments.any?(&:turnitin_enabled)
60+
unless defined?(@turnitin_enabled)
61+
@turnitin_enabled = @context.turnitin_enabled? && assignments.any?(&:turnitin_enabled)
62+
end
63+
@turnitin_enabled
6164
end
6265

6366
def vericite_enabled?
64-
@context.vericite_enabled? && assignments.any?(&:vericite_enabled)
67+
unless defined?(@vericite_enabled)
68+
@vericite_enabled = @context.vericite_enabled? && assignments.any?(&:vericite_enabled)
69+
end
70+
@vericite_enabled
6571
end
6672

6773
def observed_students
@@ -182,6 +188,10 @@ def submissions
182188
.where("assignments.workflow_state != 'deleted'")
183189
.where(user_id: student).to_a
184190

191+
if vericite_enabled? || turnitin_enabled?
192+
ActiveRecord::Associations::Preloader.new.preload(ss, :originality_reports)
193+
end
194+
185195
visible_assignment_ids = AssignmentStudentVisibility.visible_assignment_ids_for_user(student_id, @context.id)
186196
ss.select!{ |submission| visible_assignment_ids.include?(submission.assignment_id) }
187197

0 commit comments

Comments
 (0)