fix speedgrader regression when viewing quizzes
fixes CNVS-8204 Test plan: * Make a quiz * give students a score for the quiz in gradebook (do not take the quiz) * open the quiz in speedgrader * the gradebook should load with no errors Change-Id: I6328fb786a2ba27d80e04ebeaecd85c579e7b4cd Reviewed-on: https://gerrit.instructure.com/24463 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
67c29b7660
commit
1d0d6249e6
|
@ -1148,38 +1148,38 @@ class Assignment < ActiveRecord::Base
|
|||
:methods => [:scribdable?, :scribd_doc, :submission_history, :late],
|
||||
:only => submission_fields
|
||||
)
|
||||
if json['submission_history'] && quiz.nil?
|
||||
json['submission_history'].map! do |version|
|
||||
version.as_json(
|
||||
:include => {
|
||||
:submission_comments => { :only => comment_fields }
|
||||
},
|
||||
:only => submission_fields,
|
||||
:methods => [:versioned_attachments, :late]
|
||||
).tap do |version_json|
|
||||
if version_json['submission'] && version_json['submission']['versioned_attachments']
|
||||
version_json['submission']['versioned_attachments'].map! do |a|
|
||||
a.as_json(
|
||||
:only => attachment_fields,
|
||||
:methods => [:view_inline_ping_url, :scribd_render_url]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif quiz
|
||||
quiz_submission_versions = sub.quiz_submission.versions.reverse
|
||||
json['submission_history'] = quiz_submission_versions.map do |v|
|
||||
qs = v.model
|
||||
{submission: {
|
||||
grade: qs.score,
|
||||
show_grade_in_dropdown: true,
|
||||
submitted_at: qs.finished_at,
|
||||
late: qs.overdue?,
|
||||
version: v.number,
|
||||
}}
|
||||
end
|
||||
end
|
||||
json['submission_history'] = if json['submission_history'] && quiz.nil?
|
||||
json['submission_history'].map do |version|
|
||||
version.as_json(
|
||||
:include => {
|
||||
:submission_comments => { :only => comment_fields }
|
||||
},
|
||||
:only => submission_fields,
|
||||
:methods => [:versioned_attachments, :late]
|
||||
).tap do |version_json|
|
||||
if version_json['submission'] && version_json['submission']['versioned_attachments']
|
||||
version_json['submission']['versioned_attachments'].map! do |a|
|
||||
a.as_json(
|
||||
:only => attachment_fields,
|
||||
:methods => [:view_inline_ping_url, :scribd_render_url]
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif quiz && sub.quiz_submission
|
||||
quiz_submission_versions = sub.quiz_submission.versions.reverse
|
||||
quiz_submission_versions.map do |v|
|
||||
qs = v.model
|
||||
{submission: {
|
||||
grade: qs.score,
|
||||
show_grade_in_dropdown: true,
|
||||
submitted_at: qs.finished_at,
|
||||
late: qs.overdue?,
|
||||
version: v.number,
|
||||
}}
|
||||
end
|
||||
end
|
||||
json
|
||||
}
|
||||
res[:GROUP_GRADING_MODE] = grade_as_group?
|
||||
|
|
|
@ -2162,6 +2162,22 @@ describe Assignment do
|
|||
end
|
||||
json["GROUP_GRADING_MODE"].should be_true
|
||||
end
|
||||
|
||||
it "works for quizzes without quiz_submissions" do
|
||||
course_with_teacher(:active_all => true)
|
||||
student_in_course
|
||||
quiz = @course.quizzes.create! :title => "Final",
|
||||
:quiz_type => "assignment"
|
||||
quiz.did_edit
|
||||
quiz.offer
|
||||
|
||||
assignment = quiz.assignment
|
||||
assignment.grade_student(@student, grade: 1)
|
||||
json = assignment.speed_grader_json(@teacher)
|
||||
json[:submissions].all? { |s|
|
||||
s.has_key? 'submission_history'
|
||||
}.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
describe "update_student_submissions" do
|
||||
|
|
Loading…
Reference in New Issue