speed_grader_json: load quizzes faster
this should provide a significant speed boost to speed_grader_json for quizzes by squashing a few N+1s (the most significant N+1 being for Quiz loading). also made a tweak to submission permission checks that should improve performance. closes CNVS-27323 test plan: - create a quiz with submissions - verify you can open the quiz in speedgrader Change-Id: If069c52440e5981c872f57723e30d0d0665ec8ad Reviewed-on: https://gerrit.instructure.com/73490 Reviewed-by: Cameron Matheson <cameron@instructure.com> Tested-by: Jenkins QA-Review: KC Naegle <knaegle@instructure.com> Product-Review: Spencer Olson <solson@instructure.com>
This commit is contained in:
parent
64bb692a70
commit
7707758cf2
|
@ -1437,7 +1437,7 @@ class Assignment < ActiveRecord::Base
|
|||
map{|s| s.as_json(:include_root => false, :only => [:user_id, :course_section_id]) }
|
||||
res[:context][:quiz] = self.quiz.as_json(:include_root => false, :only => [:anonymous_submissions])
|
||||
|
||||
includes = [:versions, :quiz_submission]
|
||||
includes = [:versions, :quiz_submission, :user]
|
||||
includes << (grading_role == :grader ? :submission_comments : :all_submission_comments)
|
||||
submissions = self.submissions.where(:user_id => students).preload(*includes)
|
||||
|
||||
|
@ -1524,6 +1524,12 @@ class Assignment < ActiveRecord::Base
|
|||
elsif quiz && sub.quiz_submission
|
||||
qs_versions[sub.quiz_submission.id].map do |v|
|
||||
qs = v.model
|
||||
# copy already-loaded associations over to the
|
||||
# model so we don't have to load them again
|
||||
# when qs.late? gets called
|
||||
qs.quiz = quiz
|
||||
qs.submission = sub
|
||||
|
||||
{submission: {
|
||||
grade: qs.score,
|
||||
show_grade_in_dropdown: true,
|
||||
|
|
Loading…
Reference in New Issue