handle grade result passback when there is either no course or section

Change-Id: I7d20b373e93fc4a9703434a9eab3fc718735df66
Reviewed-on: https://gerrit.instructure.com/5865
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Cody Cutrer <cody@instructure.com>
This commit is contained in:
JT Olds 2011-09-27 12:13:58 -06:00
parent f86aacc138
commit ba64a08d4a
1 changed files with 6 additions and 1 deletions

View File

@ -51,7 +51,12 @@ module SIS
raise ImportError, "Improper grade_publishing_status \"#{grade_publishing_status}\" for enrollment #{enrollment_id}" unless %w{ published error }.include?(grade_publishing_status.downcase)
enrollment = Enrollment.find_by_id(enrollment_id)
enrollment = nil unless enrollment && (enrollment.course.root_account_id == @root_account.id || enrollment.course_section.root_account_id == @root_account.id)
if enrollment
found_root_account = enrollment.root_account_id == @root_account.id
found_root_account ||= enrollment.course && enrollment.course.root_account_id == @root_account.id
found_root_account ||= enrollment.course_section && enrollment.course_section.root_account_id == @root_account.id
enrollment = nil unless found_root_account
end
raise ImportError, "Enrollment #{enrollment_id} doesn't exist" unless enrollment
enrollment.grade_publishing_status = grade_publishing_status.downcase