diff --git a/lib/tasks/migrate_course_resource.rake b/lib/tasks/migrate_course_resource.rake index e22f0b54e..44e4ef5f4 100644 --- a/lib/tasks/migrate_course_resource.rake +++ b/lib/tasks/migrate_course_resource.rake @@ -208,7 +208,7 @@ namespace :migrate_course_resource do end new_user_ids = [] group.course_members.where(role: 4).each do |member| - new_member = target_course.course_members.find_by(user_id: member.user_id) + new_member = target_course.students.find_by(user_id: member.user_id) if new_member.present? new_member.update_column("course_group_id", new_group.id) else @@ -227,6 +227,18 @@ namespace :migrate_course_resource do end end + user_ids = [] + source_course.students.where(course_group_id: 0).each do |member| + new_member = target_course.students.find_by(user_id: member.user_id) + if new_member.present? + new_member.update_column("course_group_id", 0) + else + CourseMember.create!(course_id: target_course.id, course_group_id: 0, user_id: member.user_id, role: member.role) + user_ids << member.user_id + end + end + CourseAddStudentCreateWorksJob.perform_later(target_course.id, user_ids) unless user_ids.blank? + end end \ No newline at end of file