canvas_sync 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas_sync.rb +41 -44
- data/lib/canvas_sync/jobs/sync_submissions_job.rb +4 -6
- data/lib/canvas_sync/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07facec35d45ba07ac771963dea85bca3dbe9c920101808305d5bc9440ae158e
|
4
|
+
data.tar.gz: 919af58a0762425c6c128460a57bfc562d89ee9fe07cec7d7bb2f5983ad9211f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c88b2b03e0f74fa473d69c4665012e6f11755d2434ce47b81c443ca527ea11384f9573519931c3f5f1e197231bb2a6468c067745105e25c885d5cd89372a4f47
|
7
|
+
data.tar.gz: 6fa4ad837efdf6647f76f7451f749e4368f82fcb42661e9f834bb2b968ab5e0fdb4c19bfcdd484046ef23bfcbb03e399f8483e95124f9d72a8fe32dc5de332ec
|
data/lib/canvas_sync.rb
CHANGED
@@ -155,69 +155,66 @@ module CanvasSync
|
|
155
155
|
# @param account_id [Integer, nil] This optional parameter can be used if your Term creation and
|
156
156
|
# canvas_sync_client methods require an account ID.
|
157
157
|
# @return [Hash]
|
158
|
-
def default_provisioning_report_chain(models, term_scope=nil, legacy_support=false, account_id=nil) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/LineLength
|
158
|
+
def default_provisioning_report_chain(models, term_scope=nil, legacy_support=false, account_id=nil, options: {}) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/LineLength
|
159
|
+
return unless models.present?
|
160
|
+
models.map! &:to_s
|
159
161
|
term_scope = term_scope.to_s if term_scope
|
162
|
+
options = options.with_indifferent_access
|
163
|
+
|
164
|
+
model_job_map = {
|
165
|
+
terms: CanvasSync::Jobs::SyncTermsJob,
|
166
|
+
users: CanvasSync::Jobs::SyncUsersJob,
|
167
|
+
roles: CanvasSync::Jobs::SyncRolesJob,
|
168
|
+
admins: CanvasSync::Jobs::SyncAdminsJob,
|
169
|
+
|
170
|
+
assignments: CanvasSync::Jobs::SyncAssignmentsJob,
|
171
|
+
submissions: CanvasSync::Jobs::SyncSubmissionsJob,
|
172
|
+
assignment_groups: CanvasSync::Jobs::SyncAssignmentGroupsJob,
|
173
|
+
context_modules: CanvasSync::Jobs::SyncContextModulesJob,
|
174
|
+
context_module_items: CanvasSync::Jobs::SyncContextModuleItemsJob,
|
175
|
+
}.with_indifferent_access
|
176
|
+
|
177
|
+
jobs = []
|
178
|
+
try_add_model_job = ->(model) {
|
179
|
+
return unless models.include?(model)
|
180
|
+
jobs.push(job: model_job_map[model].to_s, options: options[model] || {})
|
181
|
+
models -= [model]
|
182
|
+
}
|
160
183
|
|
161
184
|
##############################
|
162
185
|
# Pre provisioning report jobs
|
163
186
|
##############################
|
164
187
|
|
165
188
|
# Always sync Terms first
|
166
|
-
|
189
|
+
models.unshift('terms') unless models.include?('terms')
|
190
|
+
try_add_model_job.call('terms')
|
167
191
|
|
168
192
|
# Users, roles, and admins are synced before provisioning because they cannot be scoped to term
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
if models.include?("roles")
|
175
|
-
pre_provisioning_jobs.push(job: CanvasSync::Jobs::SyncRolesJob.to_s, options: {})
|
176
|
-
models -= ["roles"]
|
177
|
-
end
|
193
|
+
try_add_model_job.call('users') if term_scope.present?
|
194
|
+
try_add_model_job.call('roles')
|
195
|
+
try_add_model_job.call('admins')
|
178
196
|
|
179
|
-
|
180
|
-
|
181
|
-
models -= ["admins"]
|
182
|
-
end
|
197
|
+
pre_provisioning_jobs = jobs
|
198
|
+
jobs = []
|
183
199
|
|
184
200
|
###############################
|
185
201
|
# Post provisioning report jobs
|
186
202
|
###############################
|
187
203
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
end
|
194
|
-
|
195
|
-
if models.include?("submissions")
|
196
|
-
post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncSubmissionsJob.to_s, options: {})
|
197
|
-
models -= ["submissions"]
|
198
|
-
end
|
199
|
-
|
200
|
-
if models.include?("assignment_groups")
|
201
|
-
post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncAssignmentGroupsJob.to_s, options: {})
|
202
|
-
models -= ["assignment_groups"]
|
203
|
-
end
|
204
|
-
|
205
|
-
if models.include?("context_modules")
|
206
|
-
post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncContextModulesJob.to_s, options: {})
|
207
|
-
models -= ["context_modules"]
|
208
|
-
end
|
204
|
+
try_add_model_job.call('assignments')
|
205
|
+
try_add_model_job.call('submissions')
|
206
|
+
try_add_model_job.call('assignment_groups')
|
207
|
+
try_add_model_job.call('context_modules')
|
208
|
+
try_add_model_job.call('context_module_items')
|
209
209
|
|
210
|
-
|
211
|
-
post_provisioning_jobs.push(job: CanvasSync::Jobs::SyncContextModuleItemsJob.to_s, options: {})
|
212
|
-
models -= ["context_module_items"]
|
213
|
-
end
|
210
|
+
post_provisioning_jobs = jobs
|
214
211
|
|
215
|
-
|
212
|
+
jobs = pre_provisioning_jobs
|
213
|
+
jobs += Array.wrap({
|
216
214
|
job: CanvasSync::Jobs::SyncProvisioningReportJob.to_s,
|
217
215
|
options: { term_scope: term_scope, models: models },
|
218
|
-
}
|
219
|
-
|
220
|
-
jobs = pre_provisioning_jobs + Array.wrap(provisioning_job) + post_provisioning_jobs
|
216
|
+
}) if models.present?
|
217
|
+
jobs += post_provisioning_jobs
|
221
218
|
|
222
219
|
global_options = { legacy_support: legacy_support }
|
223
220
|
global_options[:account_id] = account_id if account_id.present?
|
@@ -8,12 +8,10 @@ module CanvasSync
|
|
8
8
|
#
|
9
9
|
# @param job_chain [Hash]
|
10
10
|
# @param options [Hash]
|
11
|
-
def perform(job_chain,
|
12
|
-
report_params =
|
13
|
-
|
14
|
-
|
15
|
-
{}
|
16
|
-
end
|
11
|
+
def perform(job_chain, options)
|
12
|
+
report_params = {}
|
13
|
+
report_params["parameters[enrollment_term_id]"] = job_chain[:global_options][:canvas_term_id] if job_chain[:global_options][:canvas_term_id].present?
|
14
|
+
report_params["parameters[include_all]"] = true if options[:include_all]
|
17
15
|
|
18
16
|
super(
|
19
17
|
job_chain,
|
data/lib/canvas_sync/version.rb
CHANGED