coalescing_panda 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/coalescing_panda/workers/course_miner.rb +57 -42
- data/lib/coalescing_panda/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3111ee81eb937deba10901dc83277496eb8f350e
|
4
|
+
data.tar.gz: a6fa5a91374898ebdd73bf45a4f1d865d16a5877
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dabeb94c51efd5872babf05e970748ca18f682f216161e7f0cac853d780c510d588feb6ddde09250175679116cfeac7db8cb6ff923b6d007c7450fea3ff1c55
|
7
|
+
data.tar.gz: 3568a3cbc4f85f3d2a17c189212a3956cfa21c8bfd3c74eea19fe5ff42af1b1bdb351d96d671a2c1f5ef7e3202643da193bc9e8f3682bd12d4ff7c14e9214932
|
@@ -27,7 +27,6 @@ class CoalescingPanda::Workers::CourseMiner
|
|
27
27
|
percent_complete = (index/(options.count.nonzero? || 1).to_f * 100).round(1)
|
28
28
|
batch.update_attributes(percent_complete: percent_complete)
|
29
29
|
end
|
30
|
-
delete_removed_records
|
31
30
|
batch.update_attributes(status: "Completed", percent_complete: 100)
|
32
31
|
rescue => e
|
33
32
|
batch.update_attributes(status: "Error", message: e.message)
|
@@ -73,25 +72,19 @@ class CoalescingPanda::Workers::CourseMiner
|
|
73
72
|
end
|
74
73
|
end
|
75
74
|
|
76
|
-
def delete_removed_records
|
77
|
-
course.sections.where.not(id: course_section_ids).destroy_all
|
78
|
-
course.enrollments.where.not(id: enrollment_ids).destroy_all
|
79
|
-
course.assignments.where.not(id: assignment_ids).destroy_all
|
80
|
-
course.groups.where.not(id: group_ids).destroy_all
|
81
|
-
end
|
82
|
-
|
83
75
|
def sync_sections(collection)
|
84
|
-
|
85
|
-
|
76
|
+
begin
|
77
|
+
collection.each do |values|
|
86
78
|
values['course_section_id'] = values['id'].to_s
|
87
79
|
section = course.sections.where(canvas_section_id: values['course_section_id']).first_or_initialize
|
88
80
|
section.assign_attributes(standard_attributes(section, values))
|
89
81
|
section.sis_id = values['sis_section_id']
|
90
82
|
section.save(validate: false)
|
91
83
|
course_section_ids << section.id
|
92
|
-
rescue => e
|
93
|
-
Rails.logger.error "Error syncing sections: #{e}"
|
94
84
|
end
|
85
|
+
course.sections.where.not(id: course_section_ids).destroy_all
|
86
|
+
rescue => e
|
87
|
+
Rails.logger.error "Error syncing sections: #{e}"
|
95
88
|
end
|
96
89
|
end
|
97
90
|
|
@@ -111,8 +104,8 @@ class CoalescingPanda::Workers::CourseMiner
|
|
111
104
|
end
|
112
105
|
|
113
106
|
def sync_enrollments(collection)
|
114
|
-
|
115
|
-
|
107
|
+
begin
|
108
|
+
collection.each do |values|
|
116
109
|
values['canvas_enrollment_id'] = values['id'].to_s
|
117
110
|
enrollment = course.enrollments.where(canvas_enrollment_id: values['canvas_enrollment_id']).first_or_initialize
|
118
111
|
enrollment.section = course.sections.find_by(canvas_section_id: values['course_section_id'].to_s)
|
@@ -122,51 +115,73 @@ class CoalescingPanda::Workers::CourseMiner
|
|
122
115
|
enrollment.assign_attributes(standard_attributes(enrollment, values))
|
123
116
|
enrollment.save(validate: false)
|
124
117
|
enrollment_ids << enrollment.id
|
125
|
-
rescue => e
|
126
|
-
Rails.logger.error "Error syncing enrollments: #{e}"
|
127
118
|
end
|
119
|
+
course.enrollments.where.not(id: enrollment_ids).destroy_all
|
120
|
+
rescue => e
|
121
|
+
Rails.logger.error "Error syncing enrollments: #{e}"
|
128
122
|
end
|
129
123
|
end
|
130
124
|
|
131
125
|
def sync_assignments(collection)
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
126
|
+
begin
|
127
|
+
collection.each do |values|
|
128
|
+
values['canvas_assignment_id'] = values['id'].to_s
|
129
|
+
assignment = course.assignments.where(canvas_assignment_id: values['canvas_assignment_id']).first_or_initialize
|
130
|
+
assignment.assign_attributes(standard_attributes(assignment, values))
|
131
|
+
assignment.save(validate: false)
|
132
|
+
assignment_ids << assignment.id
|
133
|
+
end
|
134
|
+
course.assignments.where.not(id: assignment_ids).each do |assignment|
|
135
|
+
assignment.submissions.destroy_all
|
136
|
+
assignment.destroy!
|
137
|
+
end
|
138
|
+
rescue => e
|
139
|
+
Rails.logger.error "Error syncing assignments: #{e}"
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
141
143
|
def sync_submissions(collection)
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
begin
|
145
|
+
collection.each do |values|
|
146
|
+
values['canvas_submission_id'] = values['id'].to_s
|
147
|
+
submission = course.submissions.where(canvas_submission_id: values['canvas_submission_id']).first_or_initialize
|
148
|
+
submission.user = course.users.find_by(canvas_user_id: values['user_id'].to_s)
|
149
|
+
submission.assignment = course.assignments.find_by(canvas_assignment_id: values['assignment_id'].to_s)
|
150
|
+
submission.assign_attributes(standard_attributes(submission, values))
|
151
|
+
submission.save(validate: false)
|
152
|
+
end
|
153
|
+
rescue => e
|
154
|
+
Rails.logger.error "Error syncing submissions: #{e}"
|
149
155
|
end
|
150
156
|
end
|
151
157
|
|
152
158
|
def sync_groups(collection)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
+
begin
|
160
|
+
collection.each do |values|
|
161
|
+
values['canvas_group_id'] = values['id'].to_s
|
162
|
+
group = course.groups.where(canvas_group_id: values['canvas_group_id']).first_or_initialize
|
163
|
+
group.assign_attributes(standard_attributes(group, values))
|
164
|
+
group.save(validate: false)
|
165
|
+
group_ids << group.id
|
166
|
+
end
|
167
|
+
course.groups.where.not(id: group_ids).destroy_all
|
168
|
+
rescue => e
|
169
|
+
Rails.logger.error "Error syncing groups: #{e}"
|
159
170
|
end
|
160
171
|
end
|
161
172
|
|
162
173
|
def sync_group_memberships(collection)
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
174
|
+
begin
|
175
|
+
collection.each do |values|
|
176
|
+
values['canvas_group_membership_id'] = values['id'].to_s
|
177
|
+
group_membership = course.group_memberships.where(canvas_group_membership_id: values['canvas_group_membership_id']).first_or_initialize
|
178
|
+
group_membership.group = course.groups.find_by(canvas_group_id: values['group_id'].to_s)
|
179
|
+
group_membership.user = course.users.find_by(canvas_user_id: values['user_id'].to_s)
|
180
|
+
group_membership.assign_attributes(standard_attributes(group_membership, values))
|
181
|
+
group_membership.save(validate: false)
|
182
|
+
end
|
183
|
+
rescue => e
|
184
|
+
Rails.logger.error "Error syncing group memberships: #{e}"
|
170
185
|
end
|
171
186
|
end
|
172
187
|
|