canvas_sync 0.16.4 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +235 -151
  3. data/app/controllers/{api → canvas_sync/api}/v1/health_check_controller.rb +1 -1
  4. data/app/controllers/canvas_sync/api/v1/live_events_controller.rb +122 -0
  5. data/app/models/canvas_sync/sync_batch.rb +5 -0
  6. data/config/initializers/apartment.rb +10 -1
  7. data/config/routes.rb +7 -0
  8. data/db/migrate/20170915210836_create_canvas_sync_job_log.rb +12 -31
  9. data/db/migrate/20180725155729_add_job_id_to_canvas_sync_job_logs.rb +4 -13
  10. data/db/migrate/20190916154829_add_fork_count_to_canvas_sync_job_logs.rb +3 -11
  11. data/db/migrate/20201018210836_create_canvas_sync_sync_batches.rb +11 -0
  12. data/db/migrate/20201030210836_add_full_sync_to_canvas_sync_sync_batch.rb +7 -0
  13. data/lib/canvas_sync/batch_processor.rb +41 -0
  14. data/lib/canvas_sync/concerns/ability_helper.rb +72 -0
  15. data/lib/canvas_sync/concerns/account/ancestry.rb +2 -0
  16. data/lib/canvas_sync/concerns/account/base.rb +15 -0
  17. data/lib/canvas_sync/concerns/api_syncable.rb +17 -10
  18. data/lib/canvas_sync/concerns/live_event_sync.rb +46 -0
  19. data/lib/canvas_sync/concerns/role/base.rb +57 -0
  20. data/lib/canvas_sync/concerns/sync_mapping.rb +120 -0
  21. data/lib/canvas_sync/engine.rb +80 -0
  22. data/lib/canvas_sync/generators/install_generator.rb +1 -0
  23. data/lib/canvas_sync/generators/install_live_events_generator.rb +0 -1
  24. data/lib/canvas_sync/generators/templates/migrations/create_content_migrations.rb +24 -0
  25. data/lib/canvas_sync/generators/templates/migrations/create_course_nicknames.rb +17 -0
  26. data/lib/canvas_sync/generators/templates/migrations/create_grading_period_groups.rb +18 -0
  27. data/lib/canvas_sync/generators/templates/migrations/create_grading_periods.rb +22 -0
  28. data/lib/canvas_sync/generators/templates/migrations/create_learning_outcome_results.rb +46 -0
  29. data/lib/canvas_sync/generators/templates/migrations/create_learning_outcomes.rb +30 -0
  30. data/lib/canvas_sync/generators/templates/migrations/create_rubric_assessments.rb +31 -0
  31. data/lib/canvas_sync/generators/templates/migrations/create_rubric_associations.rb +36 -0
  32. data/lib/canvas_sync/generators/templates/migrations/create_rubrics.rb +38 -0
  33. data/lib/canvas_sync/generators/templates/migrations/create_user_observers.rb +17 -0
  34. data/lib/canvas_sync/generators/templates/migrations/create_users.rb +0 -1
  35. data/lib/canvas_sync/generators/templates/models/account.rb +3 -0
  36. data/lib/canvas_sync/generators/templates/models/admin.rb +2 -0
  37. data/lib/canvas_sync/generators/templates/models/assignment.rb +3 -0
  38. data/lib/canvas_sync/generators/templates/models/assignment_group.rb +3 -0
  39. data/lib/canvas_sync/generators/templates/models/content_migration.rb +12 -0
  40. data/lib/canvas_sync/generators/templates/models/context_module.rb +3 -0
  41. data/lib/canvas_sync/generators/templates/models/context_module_item.rb +3 -0
  42. data/lib/canvas_sync/generators/templates/models/course.rb +11 -0
  43. data/lib/canvas_sync/generators/templates/models/course_nickname.rb +13 -0
  44. data/lib/canvas_sync/generators/templates/models/enrollment.rb +14 -0
  45. data/lib/canvas_sync/generators/templates/models/grading_period.rb +10 -0
  46. data/lib/canvas_sync/generators/templates/models/grading_period_group.rb +9 -0
  47. data/lib/canvas_sync/generators/templates/models/group.rb +2 -0
  48. data/lib/canvas_sync/generators/templates/models/group_membership.rb +2 -0
  49. data/lib/canvas_sync/generators/templates/models/learning_outcome.rb +24 -0
  50. data/lib/canvas_sync/generators/templates/models/learning_outcome_result.rb +48 -0
  51. data/lib/canvas_sync/generators/templates/models/pseudonym.rb +2 -0
  52. data/lib/canvas_sync/generators/templates/models/role.rb +2 -0
  53. data/lib/canvas_sync/generators/templates/models/rubric.rb +29 -0
  54. data/lib/canvas_sync/generators/templates/models/rubric_assessment.rb +17 -0
  55. data/lib/canvas_sync/generators/templates/models/rubric_association.rb +14 -0
  56. data/lib/canvas_sync/generators/templates/models/section.rb +9 -0
  57. data/lib/canvas_sync/generators/templates/models/submission.rb +3 -0
  58. data/lib/canvas_sync/generators/templates/models/term.rb +3 -0
  59. data/lib/canvas_sync/generators/templates/models/user.rb +11 -0
  60. data/lib/canvas_sync/generators/templates/models/user_observer.rb +13 -0
  61. data/lib/canvas_sync/generators/templates/services/live_events/assignment_event.rb +1 -1
  62. data/lib/canvas_sync/generators/templates/services/live_events/assignment_group_event.rb +1 -1
  63. data/lib/canvas_sync/generators/templates/services/live_events/course_event.rb +1 -3
  64. data/lib/canvas_sync/generators/templates/services/live_events/course_section_event.rb +1 -1
  65. data/lib/canvas_sync/generators/templates/services/live_events/enrollment_event.rb +1 -1
  66. data/lib/canvas_sync/generators/templates/services/live_events/grade_event.rb +1 -1
  67. data/lib/canvas_sync/generators/templates/services/live_events/module_event.rb +1 -1
  68. data/lib/canvas_sync/generators/templates/services/live_events/module_item_event.rb +1 -1
  69. data/lib/canvas_sync/generators/templates/services/live_events/submission_event.rb +1 -1
  70. data/lib/canvas_sync/generators/templates/services/live_events/syllabus_event.rb +1 -1
  71. data/lib/canvas_sync/generators/templates/services/live_events/user_event.rb +1 -3
  72. data/lib/canvas_sync/importers/bulk_importer.rb +138 -31
  73. data/lib/canvas_sync/job.rb +7 -5
  74. data/lib/canvas_sync/job_batches/active_job.rb +108 -0
  75. data/lib/canvas_sync/job_batches/batch.rb +543 -0
  76. data/lib/canvas_sync/job_batches/callback.rb +149 -0
  77. data/lib/canvas_sync/job_batches/chain_builder.rb +249 -0
  78. data/lib/canvas_sync/job_batches/context_hash.rb +159 -0
  79. data/lib/canvas_sync/job_batches/hier_batch_ids.lua +25 -0
  80. data/lib/canvas_sync/job_batches/jobs/base_job.rb +7 -0
  81. data/lib/canvas_sync/job_batches/jobs/concurrent_batch_job.rb +22 -0
  82. data/lib/canvas_sync/job_batches/jobs/managed_batch_job.rb +170 -0
  83. data/lib/canvas_sync/job_batches/jobs/serial_batch_job.rb +22 -0
  84. data/lib/canvas_sync/job_batches/pool.rb +245 -0
  85. data/lib/canvas_sync/job_batches/pool_refill.lua +47 -0
  86. data/lib/canvas_sync/job_batches/redis_model.rb +69 -0
  87. data/lib/canvas_sync/job_batches/redis_script.rb +163 -0
  88. data/lib/canvas_sync/job_batches/schedule_callback.lua +14 -0
  89. data/lib/canvas_sync/job_batches/sidekiq/web/batches_assets/css/styles.less +182 -0
  90. data/lib/canvas_sync/job_batches/sidekiq/web/batches_assets/js/batch_tree.js +108 -0
  91. data/lib/canvas_sync/job_batches/sidekiq/web/batches_assets/js/util.js +2 -0
  92. data/lib/canvas_sync/job_batches/sidekiq/web/helpers.rb +41 -0
  93. data/lib/canvas_sync/job_batches/sidekiq/web/views/_batch_tree.erb +6 -0
  94. data/lib/canvas_sync/job_batches/sidekiq/web/views/_batches_table.erb +44 -0
  95. data/lib/canvas_sync/job_batches/sidekiq/web/views/_common.erb +13 -0
  96. data/lib/canvas_sync/job_batches/sidekiq/web/views/_jobs_table.erb +21 -0
  97. data/lib/canvas_sync/job_batches/sidekiq/web/views/_pagination.erb +26 -0
  98. data/lib/canvas_sync/job_batches/sidekiq/web/views/batch.erb +81 -0
  99. data/lib/canvas_sync/job_batches/sidekiq/web/views/batches.erb +23 -0
  100. data/lib/canvas_sync/job_batches/sidekiq/web/views/pool.erb +137 -0
  101. data/lib/canvas_sync/job_batches/sidekiq/web/views/pools.erb +47 -0
  102. data/lib/canvas_sync/job_batches/sidekiq/web.rb +218 -0
  103. data/lib/canvas_sync/job_batches/sidekiq.rb +136 -0
  104. data/lib/canvas_sync/job_batches/status.rb +91 -0
  105. data/lib/canvas_sync/jobs/begin_sync_chain_job.rb +99 -0
  106. data/lib/canvas_sync/jobs/canvas_process_waiter.rb +41 -0
  107. data/lib/canvas_sync/jobs/report_checker.rb +70 -8
  108. data/lib/canvas_sync/jobs/report_processor_job.rb +4 -7
  109. data/lib/canvas_sync/jobs/report_starter.rb +34 -20
  110. data/lib/canvas_sync/jobs/sync_accounts_job.rb +3 -5
  111. data/lib/canvas_sync/jobs/sync_admins_job.rb +2 -4
  112. data/lib/canvas_sync/jobs/sync_assignment_groups_job.rb +2 -4
  113. data/lib/canvas_sync/jobs/sync_assignments_job.rb +2 -4
  114. data/lib/canvas_sync/jobs/sync_content_migrations_job.rb +20 -0
  115. data/lib/canvas_sync/jobs/sync_context_module_items_job.rb +2 -4
  116. data/lib/canvas_sync/jobs/sync_context_modules_job.rb +2 -4
  117. data/lib/canvas_sync/jobs/sync_provisioning_report_job.rb +16 -50
  118. data/lib/canvas_sync/jobs/sync_roles_job.rb +2 -5
  119. data/lib/canvas_sync/jobs/sync_rubric_assessments_job.rb +15 -0
  120. data/lib/canvas_sync/jobs/sync_rubric_associations_job.rb +15 -0
  121. data/lib/canvas_sync/jobs/sync_rubrics_job.rb +15 -0
  122. data/lib/canvas_sync/jobs/sync_simple_table_job.rb +11 -32
  123. data/lib/canvas_sync/jobs/sync_submissions_job.rb +6 -4
  124. data/lib/canvas_sync/jobs/sync_terms_job.rb +9 -8
  125. data/lib/canvas_sync/jobs/term_batches_job.rb +50 -0
  126. data/lib/canvas_sync/{generators/templates/services/live_events/base_event.rb → live_events/base_handler.rb} +6 -10
  127. data/lib/canvas_sync/live_events/process_event_job.rb +26 -0
  128. data/lib/canvas_sync/live_events.rb +38 -0
  129. data/lib/canvas_sync/misc_helper.rb +63 -0
  130. data/lib/canvas_sync/processors/assignment_groups_processor.rb +3 -8
  131. data/lib/canvas_sync/processors/assignments_processor.rb +3 -8
  132. data/lib/canvas_sync/processors/content_migrations_processor.rb +19 -0
  133. data/lib/canvas_sync/processors/context_module_items_processor.rb +3 -8
  134. data/lib/canvas_sync/processors/context_modules_processor.rb +3 -8
  135. data/lib/canvas_sync/processors/model_mappings.yml +420 -0
  136. data/lib/canvas_sync/processors/normal_processor.rb +3 -3
  137. data/lib/canvas_sync/processors/provisioning_report_processor.rb +42 -55
  138. data/lib/canvas_sync/processors/report_processor.rb +15 -9
  139. data/lib/canvas_sync/processors/rubric_assessments_processor.rb +19 -0
  140. data/lib/canvas_sync/processors/rubric_associations_processor.rb +19 -0
  141. data/lib/canvas_sync/processors/rubrics_processor.rb +19 -0
  142. data/lib/canvas_sync/processors/submissions_processor.rb +3 -8
  143. data/lib/canvas_sync/record.rb +103 -0
  144. data/lib/canvas_sync/version.rb +1 -1
  145. data/lib/canvas_sync.rb +124 -125
  146. data/spec/canvas_sync/canvas_sync_spec.rb +224 -155
  147. data/spec/canvas_sync/jobs/canvas_process_waiter_spec.rb +34 -0
  148. data/spec/canvas_sync/jobs/job_spec.rb +9 -17
  149. data/spec/canvas_sync/jobs/report_checker_spec.rb +1 -3
  150. data/spec/canvas_sync/jobs/report_processor_job_spec.rb +0 -3
  151. data/spec/canvas_sync/jobs/report_starter_spec.rb +19 -28
  152. data/spec/canvas_sync/jobs/sync_admins_job_spec.rb +1 -4
  153. data/spec/canvas_sync/jobs/sync_assignment_groups_job_spec.rb +2 -1
  154. data/spec/canvas_sync/jobs/sync_assignments_job_spec.rb +3 -2
  155. data/spec/canvas_sync/jobs/sync_content_migrations_job_spec.rb +30 -0
  156. data/spec/canvas_sync/jobs/sync_context_module_items_job_spec.rb +3 -2
  157. data/spec/canvas_sync/jobs/sync_context_modules_job_spec.rb +3 -2
  158. data/spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb +7 -41
  159. data/spec/canvas_sync/jobs/sync_roles_job_spec.rb +1 -4
  160. data/spec/canvas_sync/jobs/sync_simple_table_job_spec.rb +5 -12
  161. data/spec/canvas_sync/jobs/sync_submissions_job_spec.rb +8 -2
  162. data/spec/canvas_sync/jobs/sync_terms_job_spec.rb +1 -4
  163. data/spec/canvas_sync/live_events/live_event_sync_spec.rb +27 -0
  164. data/spec/canvas_sync/live_events/live_events_controller_spec.rb +54 -0
  165. data/spec/canvas_sync/live_events/process_event_job_spec.rb +38 -0
  166. data/spec/canvas_sync/misc_helper_spec.rb +58 -0
  167. data/spec/canvas_sync/models/assignment_spec.rb +1 -1
  168. data/spec/canvas_sync/processors/content_migrations_processor_spec.rb +13 -0
  169. data/spec/canvas_sync/processors/provisioning_report_processor_spec.rb +101 -1
  170. data/spec/canvas_sync/processors/rubric_assessments_spec.rb +16 -0
  171. data/spec/canvas_sync/processors/rubric_associations_spec.rb +16 -0
  172. data/spec/canvas_sync/processors/rubrics_processor_spec.rb +17 -0
  173. data/spec/dummy/app/models/account.rb +6 -0
  174. data/spec/dummy/app/models/admin.rb +2 -0
  175. data/spec/dummy/app/models/assignment.rb +3 -0
  176. data/spec/dummy/app/models/assignment_group.rb +3 -0
  177. data/spec/dummy/app/models/content_migration.rb +18 -0
  178. data/spec/dummy/app/models/context_module.rb +3 -0
  179. data/spec/dummy/app/models/context_module_item.rb +3 -0
  180. data/spec/dummy/app/models/course.rb +11 -0
  181. data/spec/dummy/app/models/course_nickname.rb +19 -0
  182. data/spec/dummy/app/models/enrollment.rb +14 -0
  183. data/spec/dummy/app/models/grading_period.rb +16 -0
  184. data/spec/dummy/app/models/grading_period_group.rb +15 -0
  185. data/spec/dummy/app/models/group.rb +2 -0
  186. data/spec/dummy/app/models/group_membership.rb +2 -0
  187. data/spec/dummy/app/models/learning_outcome.rb +30 -0
  188. data/spec/dummy/app/models/learning_outcome_result.rb +54 -0
  189. data/spec/dummy/app/models/pseudonym.rb +16 -0
  190. data/spec/dummy/app/models/role.rb +2 -0
  191. data/spec/dummy/app/models/rubric.rb +35 -0
  192. data/spec/dummy/app/models/rubric_assessment.rb +22 -0
  193. data/spec/dummy/app/models/rubric_association.rb +20 -0
  194. data/spec/dummy/app/models/section.rb +9 -0
  195. data/spec/dummy/app/models/submission.rb +4 -0
  196. data/spec/dummy/app/models/term.rb +3 -0
  197. data/spec/dummy/app/models/user.rb +11 -0
  198. data/spec/dummy/app/models/user_observer.rb +19 -0
  199. data/spec/dummy/app/services/live_events/assignment_event.rb +1 -1
  200. data/spec/dummy/app/services/live_events/course_event.rb +1 -3
  201. data/spec/dummy/app/services/live_events/course_section_event.rb +1 -1
  202. data/spec/dummy/app/services/live_events/enrollment_event.rb +1 -1
  203. data/spec/dummy/app/services/live_events/grade_event.rb +1 -1
  204. data/spec/dummy/app/services/live_events/module_event.rb +1 -1
  205. data/spec/dummy/app/services/live_events/module_item_event.rb +1 -1
  206. data/spec/dummy/app/services/live_events/submission_event.rb +1 -1
  207. data/spec/dummy/app/services/live_events/syllabus_event.rb +1 -1
  208. data/spec/dummy/app/services/live_events/user_event.rb +1 -3
  209. data/spec/dummy/config/environments/test.rb +2 -0
  210. data/spec/dummy/config/routes.rb +1 -0
  211. data/spec/dummy/db/migrate/20201016181346_create_pseudonyms.rb +24 -0
  212. data/spec/dummy/db/migrate/20210907233329_create_user_observers.rb +23 -0
  213. data/spec/dummy/db/migrate/20210907233330_create_grading_periods.rb +28 -0
  214. data/spec/dummy/db/migrate/20211001184920_create_grading_period_groups.rb +24 -0
  215. data/spec/dummy/db/migrate/20220308072643_create_content_migrations.rb +30 -0
  216. data/spec/dummy/db/migrate/20220712210559_create_learning_outcomes.rb +36 -0
  217. data/spec/dummy/db/migrate/{20190702203620_create_users.rb → 20220926221926_create_users.rb} +0 -1
  218. data/spec/dummy/db/migrate/20240408223326_create_course_nicknames.rb +23 -0
  219. data/spec/dummy/db/migrate/20240509105100_create_rubrics.rb +44 -0
  220. data/spec/dummy/db/migrate/20240510094100_create_rubric_associations.rb +42 -0
  221. data/spec/dummy/db/migrate/20240510101100_create_rubric_assessments.rb +37 -0
  222. data/spec/dummy/db/migrate/20240523101010_create_learning_outcome_results.rb +52 -0
  223. data/spec/dummy/db/schema.rb +244 -5
  224. data/spec/factories/user_factory.rb +0 -1
  225. data/spec/job_batching/active_job_spec.rb +107 -0
  226. data/spec/job_batching/batch_spec.rb +489 -0
  227. data/spec/job_batching/callback_spec.rb +38 -0
  228. data/spec/job_batching/context_hash_spec.rb +54 -0
  229. data/spec/job_batching/flow_spec.rb +82 -0
  230. data/spec/job_batching/integration/fail_then_succeed.rb +42 -0
  231. data/spec/job_batching/integration/integration.rb +57 -0
  232. data/spec/job_batching/integration/nested.rb +88 -0
  233. data/spec/job_batching/integration/simple.rb +47 -0
  234. data/spec/job_batching/integration/workflow.rb +134 -0
  235. data/spec/job_batching/integration_helper.rb +50 -0
  236. data/spec/job_batching/pool_spec.rb +161 -0
  237. data/spec/job_batching/sidekiq_spec.rb +125 -0
  238. data/spec/job_batching/status_spec.rb +76 -0
  239. data/spec/job_batching/support/base_job.rb +14 -0
  240. data/spec/job_batching/support/sample_callback.rb +2 -0
  241. data/spec/spec_helper.rb +17 -0
  242. data/spec/support/fixtures/reports/content_migrations.csv +3 -0
  243. data/spec/support/fixtures/reports/course_nicknames.csv +3 -0
  244. data/spec/support/fixtures/reports/grading_period_groups.csv +2 -0
  245. data/spec/support/fixtures/reports/grading_periods.csv +3 -0
  246. data/spec/support/fixtures/reports/learning_outcome_results.csv +3 -0
  247. data/spec/support/fixtures/reports/learning_outcomes.csv +3 -0
  248. data/spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv +3 -0
  249. data/spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv +4 -0
  250. data/spec/support/fixtures/reports/rubric_assessments.csv +3 -0
  251. data/spec/support/fixtures/reports/rubric_associations.csv +3 -0
  252. data/spec/support/fixtures/reports/rubrics.csv +3 -0
  253. data/spec/support/fixtures/reports/user_observers.csv +3 -0
  254. data/spec/support/fixtures/reports/users.csv +3 -2
  255. data/spec/support/fixtures/reports/xlist.csv +1 -1
  256. metadata +329 -27
  257. data/app/controllers/api/v1/live_events_controller.rb +0 -18
  258. data/lib/canvas_sync/job_chain.rb +0 -57
  259. data/lib/canvas_sync/jobs/fork_gather.rb +0 -59
  260. data/spec/canvas_sync/jobs/fork_gather_spec.rb +0 -73
@@ -7,6 +7,7 @@ users:
7
7
  user_id:
8
8
  database_column_name: sis_id
9
9
  type: string
10
+ deprecated: true
10
11
  email:
11
12
  database_column_name: email
12
13
  type: string
@@ -407,3 +408,422 @@ group_memberships:
407
408
  status:
408
409
  database_column_name: workflow_state
409
410
  type: string
411
+
412
+ user_observers:
413
+ conflict_target:
414
+ - canvas_observer_id
415
+ - canvas_student_id
416
+ report_columns:
417
+ canvas_observer_id:
418
+ database_column_name: observing_user_id
419
+ type: integer
420
+ canvas_student_id:
421
+ database_column_name: observed_user_id
422
+ type: integer
423
+ status:
424
+ database_column_name: workflow_state
425
+ type: string
426
+
427
+ grading_periods:
428
+ conflict_target: grading_period_id
429
+ report_columns:
430
+ grading_period_id:
431
+ database_column_name: canvas_id
432
+ type: integer
433
+ title:
434
+ database_column_name: title
435
+ type: string
436
+ weight:
437
+ database_column_name: weight
438
+ type: float
439
+ start_date:
440
+ database_column_name: start_date
441
+ type: datetime
442
+ end_date:
443
+ database_column_name: end_date
444
+ type: datetime
445
+ close_date:
446
+ database_column_name: close_date
447
+ type: datetime
448
+ grading_period_group_id:
449
+ database_column_name: canvas_grading_period_group_id
450
+ type: integer
451
+ status:
452
+ database_column_name: workflow_state
453
+ type: string
454
+
455
+ grading_period_groups:
456
+ conflict_target: grading_period_group_id
457
+ report_columns:
458
+ grading_period_group_id:
459
+ database_column_name: canvas_id
460
+ type: integer
461
+ title:
462
+ database_column_name: title
463
+ type: string
464
+ weighted:
465
+ database_column_name: weighted
466
+ type: boolean
467
+ display_totals_for_all_grading_periods:
468
+ database_column_name: display_totals_for_all_grading_periods
469
+ type: boolean
470
+ status:
471
+ database_column_name: workflow_state
472
+ type: string
473
+
474
+ content_migrations:
475
+ conflict_target: canvas_migration_id
476
+ report_columns:
477
+ canvas_migration_id:
478
+ database_column_name: canvas_id
479
+ type: integer
480
+ canvas_context_id:
481
+ database_column_name: canvas_context_id
482
+ type: integer
483
+ canvas_context_type:
484
+ database_column_name: canvas_context_type
485
+ type: string
486
+ workflow_state:
487
+ database_column_name: workflow_state
488
+ type: string
489
+ migration_settings:
490
+ database_column_name: migration_settings
491
+ type: text
492
+ started_at:
493
+ database_column_name: started_at
494
+ type: datetime
495
+ finished_at:
496
+ database_column_name: finished_at
497
+ type: datetime
498
+ progress:
499
+ database_column_name: progress
500
+ type: float
501
+ canvas_source_course_id:
502
+ database_column_name: canvas_source_course_id
503
+ type: integer
504
+ migration_type:
505
+ database_column_name: migration_type
506
+ type: string
507
+ canvas_child_subscription_id:
508
+ database_column_name: canvas_child_subscription_id
509
+ type: integer
510
+ canvas_root_account_id:
511
+ database_column_name: canvas_root_account_id
512
+ type: integer
513
+
514
+ learning_outcomes:
515
+ conflict_target: learning_outcome_id
516
+ report_columns:
517
+ learning_outcome_id:
518
+ database_column_name: canvas_id
519
+ type: integer
520
+ context_id:
521
+ database_column_name: canvas_context_id
522
+ type: integer
523
+ context_type:
524
+ database_column_name: canvas_context_type
525
+ type: string
526
+ name:
527
+ database_column_name: name
528
+ type: string
529
+ friendly_name:
530
+ database_column_name: friendly_name
531
+ type: string
532
+ workflow_state:
533
+ database_column_name: workflow_state
534
+ type: string
535
+ created_at:
536
+ database_column_name: canvas_created_at
537
+ type: datetime
538
+ updated_at:
539
+ database_column_name: canvas_updated_at
540
+ type: datetime
541
+ migration_id:
542
+ database_column_name: migration_id
543
+ type: string
544
+ vendor_guid:
545
+ database_column_name: vendor_guid
546
+ type: string
547
+ low_grade:
548
+ database_column_name: low_grade
549
+ type: string
550
+ high_grade:
551
+ database_column_name: high_grade
552
+ type: string
553
+ calculation_method:
554
+ database_column_name: calculation_method
555
+ type: string
556
+ calculation_int:
557
+ database_column_name: calculation_int
558
+ type: integer
559
+ outcome_import_id:
560
+ database_column_name: outcome_import_id
561
+ type: integer
562
+ root_account_ids:
563
+ database_column_name: root_account_ids
564
+ type: integer
565
+ description:
566
+ database_column_name: description
567
+ type: string
568
+
569
+ learning_outcome_results:
570
+ conflict_target: id
571
+ report_columns:
572
+ id:
573
+ database_column_name: canvas_id
574
+ type: integer
575
+ context_id:
576
+ database_column_name: canvas_context_id
577
+ type: integer
578
+ context_type:
579
+ database_column_name: canvas_context_type
580
+ type: string
581
+ association_id:
582
+ database_column_name: canvas_association_id
583
+ type: integer
584
+ association_type:
585
+ database_column_name: canvas_association_type
586
+ type: string
587
+ content_tag_id:
588
+ database_column_name: canvas_content_tag_id
589
+ type: integer
590
+ learning_outcome_id:
591
+ database_column_name: canvas_learning_outcome_id
592
+ type: integer
593
+ user_id:
594
+ database_column_name: canvas_user_id
595
+ type: integer
596
+ mastery:
597
+ database_column_name: mastery
598
+ type: boolean
599
+ original_mastery:
600
+ database_column_name: original_mastery
601
+ type: boolean
602
+ artifact_id:
603
+ database_column_name: canvas_artifact_id
604
+ type: integer
605
+ artifact_type:
606
+ database_column_name: canvas_artifact_type
607
+ type: string
608
+ assessed_at:
609
+ database_column_name: assessed_at
610
+ type: datetime
611
+ title:
612
+ database_column_name: title
613
+ type: string
614
+ percent:
615
+ database_column_name: percent
616
+ type: float
617
+ associated_asset_id:
618
+ database_column_name: canvas_associated_asset_id
619
+ type: integer
620
+ associated_asset_type:
621
+ database_column_name: canvas_associated_asset_type
622
+ type: string
623
+ attempt:
624
+ database_column_name: attempt
625
+ type: integer
626
+ score:
627
+ database_column_name: score
628
+ type: float
629
+ possible:
630
+ database_column_name: possible
631
+ type: float
632
+ original_score:
633
+ database_column_name: original_score
634
+ type: float
635
+ original_possible:
636
+ database_column_name: original_possible
637
+ type: float
638
+ workflow_state:
639
+ database_column_name: workflow_state
640
+ type: string
641
+
642
+ course_nicknames:
643
+ conflict_target:
644
+ - canvas_user_id
645
+ - canvas_course_id
646
+ report_columns:
647
+ user_preference_value_id:
648
+ database_column_name: canvas_user_preference_value_id
649
+ type: integer
650
+ canvas_user_id:
651
+ database_column_name: canvas_user_id
652
+ type: integer
653
+ canvas_course_id:
654
+ database_column_name: canvas_course_id
655
+ type: integer
656
+ nickname:
657
+ database_column_name: nickname
658
+ type: string
659
+
660
+ rubrics:
661
+ conflict_target: id
662
+ report_columns:
663
+ id:
664
+ database_column_name: canvas_id
665
+ type: integer
666
+ user_id:
667
+ database_column_name: canvas_user_id
668
+ type: integer
669
+ rubric_id:
670
+ database_column_name: canvas_rubric_id
671
+ type: integer
672
+ context_id:
673
+ database_column_name: canvas_context_id
674
+ type: integer
675
+ context_type:
676
+ database_column_name: canvas_context_type
677
+ type: string
678
+ data:
679
+ database_column_name: data
680
+ type: text
681
+ points_possible:
682
+ database_column_name: points_possible
683
+ type: float
684
+ title:
685
+ database_column_name: title
686
+ type: string
687
+ description:
688
+ database_column_name: description
689
+ type: text
690
+ created_at:
691
+ database_column_name: created_at
692
+ type: datetime
693
+ reusable:
694
+ database_column_name: reusable
695
+ type: boolean
696
+ public:
697
+ database_column_name: public
698
+ type: boolean
699
+ read_only:
700
+ database_column_name: read_only
701
+ type: boolean
702
+ association_count:
703
+ database_column_name: association_count
704
+ type: integer
705
+ free_form_criterion_comments:
706
+ database_column_name: free_form_criterion_comments
707
+ type: boolean
708
+ context_code:
709
+ database_column_name: context_code
710
+ type: string
711
+ migration_id:
712
+ database_column_name: migration_id
713
+ type: string
714
+ hide_score_total:
715
+ database_column_name: hide_score_total
716
+ type: boolean
717
+ workflow_state:
718
+ database_column_name: workflow_state
719
+ type: string
720
+ root_account_id:
721
+ database_column_name: canvas_root_account_id
722
+ type: integer
723
+
724
+ rubric_associations:
725
+ conflict_target: id
726
+ report_columns:
727
+ id:
728
+ database_column_name: canvas_id
729
+ type: integer
730
+ rubric_id:
731
+ database_column_name: canvas_rubric_id
732
+ type: integer
733
+ association_id:
734
+ database_column_name: canvas_association_id
735
+ type: integer
736
+ association_type:
737
+ database_column_name: canvas_association_type
738
+ type: string
739
+ use_for_grading:
740
+ database_column_name: use_for_grading
741
+ type: boolean
742
+ created_at:
743
+ database_column_name: created_at
744
+ type: datetime
745
+ title:
746
+ database_column_name: title
747
+ type: string
748
+ summary_data:
749
+ database_column_name: summary_data
750
+ type: text
751
+ purpose:
752
+ database_column_name: purpose
753
+ type: string
754
+ url:
755
+ database_column_name: url
756
+ type: string
757
+ context_id:
758
+ database_column_name: canvas_context_id
759
+ type: integer
760
+ context_type:
761
+ database_column_name: canvas_context_type
762
+ type: string
763
+ hide_score_total:
764
+ database_column_name: hide_score_total
765
+ type: boolean
766
+ bookmarked:
767
+ database_column_name: bookmarked
768
+ type: boolean
769
+ context_code:
770
+ database_column_name: context_code
771
+ type: string
772
+ hide_points:
773
+ database_column_name: hide_points
774
+ type: boolean
775
+ hide_outcome_results:
776
+ database_column_name: hide_outcome_results
777
+ type: boolean
778
+ root_account_id:
779
+ database_column_name: canvas_root_account_id
780
+ type: integer
781
+ workflow_state:
782
+ database_column_name: workflow_state
783
+ type: string
784
+
785
+ rubric_assessments:
786
+ conflict_target: id
787
+ report_columns:
788
+ id:
789
+ database_column_name: canvas_id
790
+ type: integer
791
+ user_id:
792
+ database_column_name: canvas_user_id
793
+ type: integer
794
+ rubric_id:
795
+ database_column_name: canvas_rubric_id
796
+ type: integer
797
+ rubric_association_id:
798
+ database_column_name: canvas_rubric_association_id
799
+ type: integer
800
+ score:
801
+ database_column_name: score
802
+ type: float
803
+ data:
804
+ database_column_name: data
805
+ type: text
806
+ created_at:
807
+ database_column_name: created_at
808
+ type: datetime
809
+ artifact_id:
810
+ database_column_name: canvas_artifact_id
811
+ type: integer
812
+ artifact_type:
813
+ database_column_name: canvas_artifact_type
814
+ type: string
815
+ assessment_type:
816
+ database_column_name: assessment_type
817
+ type: string
818
+ assessor_id:
819
+ database_column_name: canvas_assessor_id
820
+ type: integer
821
+ artifact_attempt:
822
+ database_column_name: artifact_attempt
823
+ type: integer
824
+ hide_points:
825
+ database_column_name: hide_points
826
+ type: boolean
827
+ root_account_id:
828
+ database_column_name: canvas_root_account_id
829
+ type: integer
@@ -13,12 +13,12 @@ module CanvasSync
13
13
  end
14
14
 
15
15
  def initialize(report_file_path, options)
16
- conflict_target = mapping[options[:mapping].to_sym][:conflict_target]
16
+ m = mapping[options[:mapping].to_sym]
17
17
  CanvasSync::Importers::BulkImporter.import(
18
18
  report_file_path,
19
- mapping[options[:mapping].to_sym][:report_columns],
19
+ m[:columns],
20
20
  options[:klass].constantize,
21
- conflict_target ? conflict_target.to_sym : conflict_target
21
+ m[:conflict_target],
22
22
  )
23
23
  end
24
24
  end
@@ -21,7 +21,6 @@ module CanvasSync
21
21
 
22
22
  def initialize(report_file_path, options) # rubocop:disable Metrics/AbcSize
23
23
  @options = options
24
-
25
24
  if options[:models].length == 1
26
25
  run_import(options[:models][0], report_file_path)
27
26
  else
@@ -70,85 +69,73 @@ module CanvasSync
70
69
  end
71
70
 
72
71
  def bulk_process_users(report_file_path)
73
- CanvasSync::Importers::BulkImporter.import(
74
- report_file_path,
75
- mapping[:users][:report_columns],
76
- User,
77
- mapping[:users][:conflict_target].to_sym,
78
- )
72
+ do_bulk_import(report_file_path, User, options: @options)
73
+ end
74
+
75
+ def bulk_process_user_observers(report_file_path)
76
+ do_bulk_import(report_file_path, UserObserver, options: @options)
79
77
  end
80
78
 
81
79
  def bulk_process_pseudonyms(report_file_path)
82
- CanvasSync::Importers::BulkImporter.import(
83
- report_file_path,
84
- mapping[:pseudonyms][:report_columns],
85
- Pseudonym,
86
- mapping[:pseudonyms][:conflict_target].to_sym,
87
- )
80
+ do_bulk_import(report_file_path, Pseudonym, options: @options)
88
81
  end
89
82
 
90
83
  def bulk_process_accounts(report_file_path)
91
- CanvasSync::Importers::BulkImporter.import(
92
- report_file_path,
93
- mapping[:accounts][:report_columns],
94
- Account,
95
- mapping[:accounts][:conflict_target].to_sym
96
- )
84
+ do_bulk_import(report_file_path, Account, options: @options)
97
85
  end
98
86
 
99
87
  def bulk_process_courses(report_file_path)
100
- CanvasSync::Importers::BulkImporter.import(
101
- report_file_path,
102
- mapping[:courses][:report_columns],
103
- Course,
104
- mapping[:courses][:conflict_target].to_sym,
105
- )
88
+ do_bulk_import(report_file_path, Course, options: @options)
106
89
  end
107
90
 
108
91
  def bulk_process_enrollments(report_file_path)
109
- CanvasSync::Importers::BulkImporter.import(
110
- report_file_path,
111
- mapping[:enrollments][:report_columns],
112
- Enrollment,
113
- mapping[:enrollments][:conflict_target].to_sym,
114
- )
92
+ do_bulk_import(report_file_path, Enrollment, options: @options)
115
93
  end
116
94
 
117
95
  def bulk_process_sections(report_file_path)
118
- CanvasSync::Importers::BulkImporter.import(
119
- report_file_path,
120
- mapping[:sections][:report_columns],
121
- Section,
122
- mapping[:sections][:conflict_target].to_sym,
123
- )
96
+ do_bulk_import(report_file_path, Section, options: @options)
124
97
  end
125
98
 
126
99
  def bulk_process_xlist(report_file_path)
127
- CanvasSync::Importers::BulkImporter.import(
128
- report_file_path,
129
- mapping[:xlist][:report_columns],
130
- Section,
131
- mapping[:xlist][:conflict_target].to_sym,
132
- )
100
+ do_bulk_import(report_file_path, Section, options: @options, mapping_key: :xlist)
133
101
  end
134
102
 
135
103
  def bulk_process_groups(report_file_path)
136
- CanvasSync::Importers::BulkImporter.import(
137
- report_file_path,
138
- mapping[:groups][:report_columns],
139
- Group,
140
- mapping[:groups][:conflict_target].to_sym,
141
- )
104
+ do_bulk_import(report_file_path, Group, options: @options)
105
+ end
106
+
107
+ def bulk_process_grading_periods(report_file_path)
108
+ do_bulk_import(report_file_path, GradingPeriod, options: @options)
109
+ end
110
+
111
+ def bulk_process_grading_period_groups(report_file_path)
112
+ do_bulk_import(report_file_path, GradingPeriodGroup, options: @options)
142
113
  end
143
114
 
144
115
  # Note that group membership is singular because we override the model name param in sync_provisioning_report_job
145
116
  def bulk_process_group_membership(report_file_path)
146
- CanvasSync::Importers::BulkImporter.import(
147
- report_file_path,
148
- mapping[:group_memberships][:report_columns],
149
- GroupMembership,
150
- mapping[:group_memberships][:conflict_target].to_sym,
151
- )
117
+ do_bulk_import(report_file_path, GroupMembership, options: @options)
118
+ end
119
+
120
+ def bulk_process_learning_outcomes(report_file_path)
121
+ do_bulk_import(report_file_path, LearningOutcome, options: @options) do |row|
122
+ row[:root_account_ids] = JSON.parse row[:root_account_ids]
123
+ row
124
+ end
125
+ end
126
+
127
+ def bulk_process_learning_outcome_results(report_file_path)
128
+ do_bulk_import(report_file_path, LearningOutcomeResult, options: @options)
129
+ end
130
+
131
+ def bulk_process_course_nicknames(report_file_path)
132
+ exists = []
133
+ do_bulk_import(report_file_path, CourseNickname, options: @options) do |row|
134
+ exists << row[:user_preference_value_id]
135
+ row
136
+ end
137
+ # Canvas does not soft delete UserPreferenceValues so there's no point in doing the same
138
+ CourseNickname.where.not(canvas_user_preference_value_id: exists).or(CourseNickname.where(canvas_user_preference_value_id: nil)).delete_all
152
139
  end
153
140
  end
154
141
  end
@@ -5,17 +5,23 @@ module CanvasSync
5
5
  # Base report processing class
6
6
  class ReportProcessor
7
7
  def mapping
8
- @mapping ||= begin
9
- mapping = YAML.load_file(File.join(__dir__, "model_mappings.yml")).deep_symbolize_keys!
10
- override_filepath = Rails.root.join("config/canvas_sync_provisioning_mapping.yml")
8
+ CanvasSync::Concerns::SyncMapping::Mapping.default_mappings
9
+ end
11
10
 
12
- if File.file?(override_filepath)
13
- override = YAML.load_file(override_filepath).deep_symbolize_keys!
14
- mapping = mapping.merge(override)
15
- end
11
+ def mapping_for(model, key = nil)
12
+ CanvasSync::Concerns::SyncMapping.mapping_for(model, key)
13
+ end
16
14
 
17
- mapping
18
- end
15
+ def do_bulk_import(report_file_path, model, options: {}, mapping_key: nil, &blk)
16
+ m = mapping_for(model, mapping_key)
17
+ CanvasSync::Importers::BulkImporter.import(
18
+ report_file_path,
19
+ m[:columns],
20
+ model,
21
+ m[:conflict_target],
22
+ import_args: options,
23
+ &blk
24
+ )
19
25
  end
20
26
  end
21
27
  end
@@ -0,0 +1,19 @@
1
+ require_relative "./report_processor"
2
+
3
+ module CanvasSync
4
+ module Processors
5
+ # Processes a rubric assessments report using the bulk importer.
6
+ #
7
+ # @param report_file_path [String]
8
+ # @param options [Hash]
9
+ class RubricAssessmentsProcessor < ReportProcessor
10
+ def self.process(report_file_path, _options, report_id)
11
+ new(report_file_path, _options)
12
+ end
13
+
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, RubricAssessment, options: options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "./report_processor"
2
+
3
+ module CanvasSync
4
+ module Processors
5
+ # Processes a rubric association report using the bulk importer.
6
+ #
7
+ # @param report_file_path [String]
8
+ # @param options [Hash]
9
+ class RubricAssociationsProcessor < ReportProcessor
10
+ def self.process(report_file_path, _options, report_id)
11
+ new(report_file_path, _options)
12
+ end
13
+
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, RubricAssociation, options: options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "./report_processor"
2
+
3
+ module CanvasSync
4
+ module Processors
5
+ # Processes a rubrics report using the bulk importer.
6
+ #
7
+ # @param report_file_path [String]
8
+ # @param options [Hash]
9
+ class RubricsProcessor < ReportProcessor
10
+ def self.process(report_file_path, _options, report_id)
11
+ new(report_file_path, _options)
12
+ end
13
+
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, Rubric, options: options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -8,16 +8,11 @@ module CanvasSync
8
8
  # @param options [Hash]
9
9
  class SubmissionsProcessor < ReportProcessor
10
10
  def self.process(report_file_path, _options, report_id)
11
- new(report_file_path)
11
+ new(report_file_path, _options)
12
12
  end
13
13
 
14
- def initialize(report_file_path)
15
- CanvasSync::Importers::BulkImporter.import(
16
- report_file_path,
17
- mapping[:submissions][:report_columns],
18
- Submission,
19
- mapping[:submissions][:conflict_target].to_sym,
20
- )
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, Submission, options: options)
21
16
  end
22
17
  end
23
18
  end