coalescing_panda 4.0.2 → 4.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3111ee81eb937deba10901dc83277496eb8f350e
4
- data.tar.gz: a6fa5a91374898ebdd73bf45a4f1d865d16a5877
3
+ metadata.gz: c416f5ba3e29b409e62db9851120231f37b84087
4
+ data.tar.gz: d542133873f5f8b0e7c9eaa78cdbeb224ae17515
5
5
  SHA512:
6
- metadata.gz: 3dabeb94c51efd5872babf05e970748ca18f682f216161e7f0cac853d780c510d588feb6ddde09250175679116cfeac7db8cb6ff923b6d007c7450fea3ff1c55
7
- data.tar.gz: 3568a3cbc4f85f3d2a17c189212a3956cfa21c8bfd3c74eea19fe5ff42af1b1bdb351d96d671a2c1f5ef7e3202643da193bc9e8f3682bd12d4ff7c14e9214932
6
+ metadata.gz: efad447c43b7c9648c010c940dd591fabd76fc128046647b813bec25a701630e84d45ef337a92d31dd8b71876d8bada67b4d80761327e160aec30515bf529f5b
7
+ data.tar.gz: b8610970bdfa070cc993280f2ee98217c438ffc593a0745cf9ae7afc544a09200e765ec3f7d7dce865caf648c599cd8a28b6b4b6cdf8a1895deb87a27a791e9e
@@ -1,7 +1,7 @@
1
1
  class CoalescingPanda::Workers::CourseMiner
2
2
  SUPPORTED_MODELS = [:sections, :users, :enrollments, :assignments, :submissions, :groups, :group_memberships] #ORDER MATTERS!!
3
3
 
4
- attr_accessor :options, :account, :course, :batch, :course_section_ids, :enrollment_ids, :assignment_ids, :group_ids
4
+ attr_accessor :options, :account, :course, :batch, :course_section_ids, :enrollment_ids, :assignment_ids, :group_ids, :user_ids
5
5
 
6
6
  def initialize(course, options = [])
7
7
  @course = course
@@ -12,6 +12,7 @@ class CoalescingPanda::Workers::CourseMiner
12
12
  @enrollment_ids = []
13
13
  @assignment_ids = []
14
14
  @group_ids = []
15
+ @user_ids = []
15
16
  end
16
17
 
17
18
  def api_client
@@ -89,17 +90,26 @@ class CoalescingPanda::Workers::CourseMiner
89
90
  end
90
91
 
91
92
  def sync_users(collection)
92
- collection.each do |values|
93
- begin
93
+ begin
94
+ collection.each do |values|
94
95
  values['canvas_user_id'] = values["id"].to_s
95
96
  user = account.users.where(canvas_user_id: values['canvas_user_id']).first_or_initialize
96
97
  user.coalescing_panda_lti_account_id = account.id
97
98
  user.assign_attributes(standard_attributes(user, values))
98
99
  user.sis_id = values['sis_user_id'].to_s
100
+ user_ids << user.id
99
101
  user.save(validate: false)
100
- rescue => e
101
- Rails.logger.error "Error syncing users: #{e}"
102
102
  end
103
+ removed_users = course.users.where.not(id: user_ids)
104
+ removed_users.each do |user|
105
+ user.enrollments.each do |enrollment|
106
+ course.submissions.where(coalescing_panda_user_id: enrollment.user.id).destroy_all
107
+ enrollment.destroy
108
+ end
109
+ end
110
+ removed_users.destroy_all
111
+ rescue => e
112
+ Rails.logger.error "Error syncing users: #{e}"
103
113
  end
104
114
  end
105
115
 
@@ -116,7 +126,11 @@ class CoalescingPanda::Workers::CourseMiner
116
126
  enrollment.save(validate: false)
117
127
  enrollment_ids << enrollment.id
118
128
  end
119
- course.enrollments.where.not(id: enrollment_ids).destroy_all
129
+ removed_enrollments = course.enrollments.where.not(id: enrollment_ids)
130
+ removed_enrollments.each do |enrollment|
131
+ course.submissions.where(coalescing_panda_user_id: enrollment.user.id).destroy_all
132
+ end
133
+ removed_enrollments.destroy_all
120
134
  rescue => e
121
135
  Rails.logger.error "Error syncing enrollments: #{e}"
122
136
  end
@@ -1,3 +1,3 @@
1
1
  module CoalescingPanda
2
- VERSION = '4.0.2'
2
+ VERSION = '4.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coalescing_panda
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Mills