ensure that deleted courses also delete enrollments
closes #3833 Change-Id: I21efa68116b7a250e9b0e9c2df2dd5dfd45a736e Reviewed-on: https://gerrit.instructure.com/2301 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Whitmer <brian@instructure.com>
This commit is contained in:
parent
f9d40283da
commit
e1a3350d7e
|
@ -437,6 +437,9 @@ class Course < ActiveRecord::Base
|
|||
if self.completed?
|
||||
enrollments = self.enrollments.scoped(:select => "id, user_id, course_id", :conditions=>"workflow_state IN ('active', 'invited')")
|
||||
Enrollment.update_all({:workflow_state => 'completed'}, {:id => enrollments.map(&:id)})
|
||||
elsif self.deleted?
|
||||
enrollments = self.enrollments.scoped(:select => "id, user_id, course_id", :conditions=>"workflow_state != 'deleted'")
|
||||
Enrollment.update_all({:workflow_state => 'deleted'}, {:id => enrollments.map(&:id)})
|
||||
end
|
||||
enrollments = self.enrollments.scoped(:select => "id, user_id, course_id")
|
||||
Enrollment.update_all({:updated_at => Time.now}, {:id => enrollments.map(&:id)})
|
||||
|
|
Loading…
Reference in New Issue