canvas_sync 0.27.13 → 0.27.15

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.
Files changed (236) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/canvas_sync/api/v1/health_check_controller.rb +0 -0
  3. data/app/models/canvas_sync/job_log.rb +0 -0
  4. data/app/models/canvas_sync/sync_batch.rb +0 -0
  5. data/config/initializers/apartment.rb +0 -0
  6. data/config/routes.rb +0 -0
  7. data/db/migrate/20170915210836_create_canvas_sync_job_log.rb +0 -0
  8. data/db/migrate/20180725155729_add_job_id_to_canvas_sync_job_logs.rb +0 -0
  9. data/db/migrate/20190916154829_add_fork_count_to_canvas_sync_job_logs.rb +0 -0
  10. data/db/migrate/20201018210836_create_canvas_sync_sync_batches.rb +0 -0
  11. data/db/migrate/20201030210836_add_full_sync_to_canvas_sync_sync_batch.rb +0 -0
  12. data/lib/canvas_sync/api_syncable.rb +0 -0
  13. data/lib/canvas_sync/batch_processor.rb +0 -0
  14. data/lib/canvas_sync/class_callback_executor.rb +0 -0
  15. data/lib/canvas_sync/concerns/ability_helper.rb +43 -2
  16. data/lib/canvas_sync/concerns/account/ancestry.rb +0 -0
  17. data/lib/canvas_sync/concerns/account/base.rb +0 -0
  18. data/lib/canvas_sync/concerns/api_syncable.rb +0 -0
  19. data/lib/canvas_sync/concerns/canvas_id_as_primary.rb +0 -0
  20. data/lib/canvas_sync/concerns/jit_syncing.rb +0 -0
  21. data/lib/canvas_sync/concerns/legacy_columns.rb +0 -0
  22. data/lib/canvas_sync/concerns/role/base.rb +0 -0
  23. data/lib/canvas_sync/generators/install_generator.rb +0 -0
  24. data/lib/canvas_sync/generators/install_live_events_generator.rb +0 -0
  25. data/lib/canvas_sync/generators/templates/migrations/create_accounts.rb +0 -0
  26. data/lib/canvas_sync/generators/templates/migrations/create_admins.rb +0 -0
  27. data/lib/canvas_sync/generators/templates/migrations/create_assignment_groups.rb +0 -0
  28. data/lib/canvas_sync/generators/templates/migrations/create_assignments.rb +0 -0
  29. data/lib/canvas_sync/generators/templates/migrations/create_content_migrations.rb +0 -0
  30. data/lib/canvas_sync/generators/templates/migrations/create_context_module_items.rb +0 -0
  31. data/lib/canvas_sync/generators/templates/migrations/create_context_modules.rb +0 -0
  32. data/lib/canvas_sync/generators/templates/migrations/create_course_nicknames.rb +0 -0
  33. data/lib/canvas_sync/generators/templates/migrations/create_course_progresses.rb +0 -0
  34. data/lib/canvas_sync/generators/templates/migrations/create_grading_period_groups.rb +0 -0
  35. data/lib/canvas_sync/generators/templates/migrations/create_grading_periods.rb +0 -0
  36. data/lib/canvas_sync/generators/templates/migrations/create_group_memberships.rb +0 -0
  37. data/lib/canvas_sync/generators/templates/migrations/create_groups.rb +0 -0
  38. data/lib/canvas_sync/generators/templates/migrations/create_learning_outcome_results.rb +0 -0
  39. data/lib/canvas_sync/generators/templates/migrations/create_learning_outcomes.rb +0 -0
  40. data/lib/canvas_sync/generators/templates/migrations/create_pseudonyms.rb +0 -0
  41. data/lib/canvas_sync/generators/templates/migrations/create_rubric_assessments.rb +0 -0
  42. data/lib/canvas_sync/generators/templates/migrations/create_rubric_associations.rb +0 -0
  43. data/lib/canvas_sync/generators/templates/migrations/create_rubrics.rb +0 -0
  44. data/lib/canvas_sync/generators/templates/migrations/create_sections.rb +0 -0
  45. data/lib/canvas_sync/generators/templates/migrations/create_submissions.rb +0 -0
  46. data/lib/canvas_sync/generators/templates/migrations/create_terms.rb +0 -0
  47. data/lib/canvas_sync/generators/templates/migrations/create_user_observers.rb +0 -0
  48. data/lib/canvas_sync/generators/templates/migrations/create_users.rb +0 -0
  49. data/lib/canvas_sync/generators/templates/models/content_migration.rb +0 -0
  50. data/lib/canvas_sync/generators/templates/models/course_nickname.rb +0 -0
  51. data/lib/canvas_sync/generators/templates/models/rubric.rb +0 -0
  52. data/lib/canvas_sync/generators/templates/models/rubric_assessment.rb +0 -0
  53. data/lib/canvas_sync/generators/templates/models/rubric_association.rb +0 -0
  54. data/lib/canvas_sync/generators/templates/services/live_events/assignment_event.rb +0 -0
  55. data/lib/canvas_sync/generators/templates/services/live_events/assignment_group_event.rb +0 -0
  56. data/lib/canvas_sync/generators/templates/services/live_events/course_event.rb +0 -0
  57. data/lib/canvas_sync/generators/templates/services/live_events/course_section_event.rb +0 -0
  58. data/lib/canvas_sync/generators/templates/services/live_events/enrollment_event.rb +0 -0
  59. data/lib/canvas_sync/generators/templates/services/live_events/grade_event.rb +0 -0
  60. data/lib/canvas_sync/generators/templates/services/live_events/module_event.rb +0 -0
  61. data/lib/canvas_sync/generators/templates/services/live_events/module_item_event.rb +0 -0
  62. data/lib/canvas_sync/generators/templates/services/live_events/submission_event.rb +0 -0
  63. data/lib/canvas_sync/generators/templates/services/live_events/syllabus_event.rb +0 -0
  64. data/lib/canvas_sync/generators/templates/services/live_events/user_event.rb +0 -0
  65. data/lib/canvas_sync/importers/legacy_importer.rb +0 -0
  66. data/lib/canvas_sync/jobs/begin_sync_chain_job.rb +0 -0
  67. data/lib/canvas_sync/jobs/canvas_process_waiter.rb +0 -0
  68. data/lib/canvas_sync/jobs/report_starter.rb +5 -1
  69. data/lib/canvas_sync/jobs/report_sync_task.rb +4 -1
  70. data/lib/canvas_sync/jobs/sync_admins_job.rb +0 -0
  71. data/lib/canvas_sync/jobs/sync_assignment_groups_job.rb +0 -0
  72. data/lib/canvas_sync/jobs/sync_assignments_job.rb +0 -0
  73. data/lib/canvas_sync/jobs/sync_content_migrations_job.rb +0 -0
  74. data/lib/canvas_sync/jobs/sync_context_module_items_job.rb +0 -0
  75. data/lib/canvas_sync/jobs/sync_context_modules_job.rb +0 -0
  76. data/lib/canvas_sync/jobs/sync_provisioning_report_job.rb +1 -1
  77. data/lib/canvas_sync/jobs/sync_rubrics_job.rb +0 -0
  78. data/lib/canvas_sync/jobs/sync_simple_table_job.rb +0 -0
  79. data/lib/canvas_sync/live_events/base_handler.rb +0 -0
  80. data/lib/canvas_sync/live_events.rb +0 -0
  81. data/lib/canvas_sync/misc_helper.rb +0 -0
  82. data/lib/canvas_sync/processors/normal_processor.rb +0 -0
  83. data/lib/canvas_sync/sidekiq_job.rb +0 -0
  84. data/lib/canvas_sync/version.rb +1 -1
  85. data/lib/canvas_sync.rb +65 -86
  86. data/spec/canvas_sync/concerns/ability_helper_spec.rb +165 -0
  87. data/spec/canvas_sync/jobs/canvas_process_waiter_spec.rb +0 -0
  88. data/spec/canvas_sync/jobs/report_starter_spec.rb +0 -0
  89. data/spec/canvas_sync/jobs/sync_admins_job_spec.rb +0 -0
  90. data/spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb +2 -2
  91. data/spec/canvas_sync/jobs/sync_roles_job_spec.rb +0 -0
  92. data/spec/canvas_sync/jobs/sync_simple_table_job_spec.rb +0 -0
  93. data/spec/canvas_sync/jobs/sync_terms_job_spec.rb +0 -0
  94. data/spec/canvas_sync/live_events/live_event_sync_spec.rb +0 -0
  95. data/spec/canvas_sync/live_events/live_events_controller_spec.rb +0 -0
  96. data/spec/canvas_sync/misc_helper_spec.rb +0 -0
  97. data/spec/canvas_sync/models/accounts_spec.rb +0 -0
  98. data/spec/canvas_sync/models/admins_spec.rb +0 -0
  99. data/spec/canvas_sync/models/assignment_group_spec.rb +0 -0
  100. data/spec/canvas_sync/models/assignment_spec.rb +0 -0
  101. data/spec/canvas_sync/models/context_module_item_spec.rb +0 -0
  102. data/spec/canvas_sync/models/context_module_spec.rb +0 -0
  103. data/spec/canvas_sync/models/course_spec.rb +0 -0
  104. data/spec/canvas_sync/models/enrollment_spec.rb +0 -0
  105. data/spec/canvas_sync/models/group_membership_spec.rb +0 -0
  106. data/spec/canvas_sync/models/group_spec.rb +0 -0
  107. data/spec/canvas_sync/models/roles_spec.rb +0 -0
  108. data/spec/canvas_sync/models/section_spec.rb +0 -0
  109. data/spec/canvas_sync/models/submission_spec.rb +0 -0
  110. data/spec/canvas_sync/models/term_spec.rb +0 -0
  111. data/spec/canvas_sync/models/user_spec.rb +0 -0
  112. data/spec/canvas_sync/processors/assignment_groups_processor_spec.rb +0 -0
  113. data/spec/canvas_sync/processors/assignments_processor_spec.rb +0 -0
  114. data/spec/canvas_sync/processors/content_migrations_processor_spec.rb +0 -0
  115. data/spec/canvas_sync/processors/context_module_items_processor_spec.rb +0 -0
  116. data/spec/canvas_sync/processors/context_modules_processor_spec.rb +0 -0
  117. data/spec/canvas_sync/processors/course_completion_report_processor_spec.rb +0 -0
  118. data/spec/canvas_sync/processors/rubric_assessments_spec.rb +0 -0
  119. data/spec/canvas_sync/processors/rubric_associations_spec.rb +0 -0
  120. data/spec/canvas_sync/processors/rubrics_processor_spec.rb +0 -0
  121. data/spec/canvas_sync/processors/submissions_processor_spec.rb +0 -0
  122. data/spec/canvas_sync/services/module_event_spec.rb +0 -0
  123. data/spec/canvas_sync/services/module_item_event_spec.rb +0 -0
  124. data/spec/factories/admin_factory.rb +0 -0
  125. data/spec/factories/assignment_factory.rb +0 -0
  126. data/spec/factories/assignment_group_factory.rb +0 -0
  127. data/spec/factories/context_module_factory.rb +0 -0
  128. data/spec/factories/context_module_item_factory.rb +0 -0
  129. data/spec/factories/course_factory.rb +0 -0
  130. data/spec/factories/enrollment_factory.rb +0 -0
  131. data/spec/factories/group_factory.rb +0 -0
  132. data/spec/factories/group_membership_factory.rb +0 -0
  133. data/spec/factories/role_factory.rb +0 -0
  134. data/spec/factories/section_factory.rb +0 -0
  135. data/spec/factories/submission_factory.rb +0 -0
  136. data/spec/factories/term_factory.rb +0 -0
  137. data/spec/factories/user_factory.rb +0 -0
  138. data/spec/support/fixtures/canvas_responses/admins.json +0 -0
  139. data/spec/support/fixtures/canvas_responses/module.json +0 -0
  140. data/spec/support/fixtures/canvas_responses/module_item.json +0 -0
  141. data/spec/support/fixtures/canvas_responses/roles.json +0 -0
  142. data/spec/support/fixtures/canvas_responses/terms.json +0 -0
  143. data/spec/support/fixtures/reports/assignment_groups.csv +0 -0
  144. data/spec/support/fixtures/reports/assignments.csv +0 -0
  145. data/spec/support/fixtures/reports/content_migrations.csv +0 -0
  146. data/spec/support/fixtures/reports/context_module_items.csv +0 -0
  147. data/spec/support/fixtures/reports/context_modules.csv +0 -0
  148. data/spec/support/fixtures/reports/course_nicknames.csv +0 -0
  149. data/spec/support/fixtures/reports/course_progresses.csv +0 -0
  150. data/spec/support/fixtures/reports/course_progresses_conflict.csv +0 -0
  151. data/spec/support/fixtures/reports/grading_period_groups.csv +0 -0
  152. data/spec/support/fixtures/reports/grading_periods.csv +0 -0
  153. data/spec/support/fixtures/reports/group_memberships.csv +0 -0
  154. data/spec/support/fixtures/reports/groups.csv +0 -0
  155. data/spec/support/fixtures/reports/learning_outcome_results.csv +0 -0
  156. data/spec/support/fixtures/reports/learning_outcomes.csv +0 -0
  157. data/spec/support/fixtures/reports/provisioning_csv +0 -0
  158. data/spec/support/fixtures/reports/rubric_assessments.csv +0 -0
  159. data/spec/support/fixtures/reports/rubric_associations.csv +0 -0
  160. data/spec/support/fixtures/reports/rubrics.csv +0 -0
  161. data/spec/support/fixtures/reports/sections.csv +0 -0
  162. data/spec/support/fixtures/reports/submissions.csv +0 -0
  163. data/spec/support/fixtures/reports/user_observers.csv +0 -0
  164. data/spec/support/fixtures/reports/users.csv +0 -0
  165. data/spec/support/fixtures/reports/xlist.csv +0 -0
  166. metadata +3 -141
  167. data/spec/internal/app/models/account.rb +0 -35
  168. data/spec/internal/app/models/admin.rb +0 -35
  169. data/spec/internal/app/models/assignment.rb +0 -39
  170. data/spec/internal/app/models/assignment_group.rb +0 -31
  171. data/spec/internal/app/models/assignment_override.rb +0 -34
  172. data/spec/internal/app/models/content_migration.rb +0 -18
  173. data/spec/internal/app/models/context_module.rb +0 -69
  174. data/spec/internal/app/models/context_module_item.rb +0 -33
  175. data/spec/internal/app/models/course.rb +0 -57
  176. data/spec/internal/app/models/course_nickname.rb +0 -20
  177. data/spec/internal/app/models/course_progress.rb +0 -29
  178. data/spec/internal/app/models/enrollment.rb +0 -48
  179. data/spec/internal/app/models/grading_period.rb +0 -17
  180. data/spec/internal/app/models/grading_period_group.rb +0 -16
  181. data/spec/internal/app/models/group.rb +0 -28
  182. data/spec/internal/app/models/group_membership.rb +0 -26
  183. data/spec/internal/app/models/learning_outcome.rb +0 -30
  184. data/spec/internal/app/models/learning_outcome_result.rb +0 -54
  185. data/spec/internal/app/models/pseudonym.rb +0 -19
  186. data/spec/internal/app/models/role.rb +0 -27
  187. data/spec/internal/app/models/rubric.rb +0 -36
  188. data/spec/internal/app/models/rubric_assessment.rb +0 -23
  189. data/spec/internal/app/models/rubric_association.rb +0 -20
  190. data/spec/internal/app/models/score.rb +0 -18
  191. data/spec/internal/app/models/section.rb +0 -36
  192. data/spec/internal/app/models/submission.rb +0 -32
  193. data/spec/internal/app/models/term.rb +0 -46
  194. data/spec/internal/app/models/user.rb +0 -43
  195. data/spec/internal/app/models/user_observer.rb +0 -22
  196. data/spec/internal/app/services/live_events/assignment_event.rb +0 -43
  197. data/spec/internal/app/services/live_events/course_event.rb +0 -28
  198. data/spec/internal/app/services/live_events/course_section_event.rb +0 -28
  199. data/spec/internal/app/services/live_events/enrollment_event.rb +0 -30
  200. data/spec/internal/app/services/live_events/grade_event.rb +0 -36
  201. data/spec/internal/app/services/live_events/module_event.rb +0 -26
  202. data/spec/internal/app/services/live_events/module_item_event.rb +0 -25
  203. data/spec/internal/app/services/live_events/submission_event.rb +0 -28
  204. data/spec/internal/app/services/live_events/syllabus_event.rb +0 -31
  205. data/spec/internal/app/services/live_events/user_event.rb +0 -27
  206. data/spec/internal/db/migrate/20251029222307_create_users.rb +0 -26
  207. data/spec/internal/db/migrate/20251029222308_create_pseudonyms.rb +0 -24
  208. data/spec/internal/db/migrate/20251029222309_create_courses.rb +0 -30
  209. data/spec/internal/db/migrate/20251029222310_create_groups.rb +0 -29
  210. data/spec/internal/db/migrate/20251029222311_create_group_memberships.rb +0 -24
  211. data/spec/internal/db/migrate/20251029222312_create_accounts.rb +0 -23
  212. data/spec/internal/db/migrate/20251029222313_create_terms.rb +0 -24
  213. data/spec/internal/db/migrate/20251029222314_create_enrollments.rb +0 -31
  214. data/spec/internal/db/migrate/20251029222315_create_sections.rb +0 -27
  215. data/spec/internal/db/migrate/20251029222316_create_assignments.rb +0 -37
  216. data/spec/internal/db/migrate/20251029222317_create_submissions.rb +0 -32
  217. data/spec/internal/db/migrate/20251029222318_create_roles.rb +0 -24
  218. data/spec/internal/db/migrate/20251029222319_create_admins.rb +0 -26
  219. data/spec/internal/db/migrate/20251029222320_create_assignment_groups.rb +0 -28
  220. data/spec/internal/db/migrate/20251029222321_create_context_modules.rb +0 -28
  221. data/spec/internal/db/migrate/20251029222322_create_context_module_items.rb +0 -26
  222. data/spec/internal/db/migrate/20251029222324_create_grading_periods.rb +0 -28
  223. data/spec/internal/db/migrate/20251029222325_create_grading_period_groups.rb +0 -24
  224. data/spec/internal/db/migrate/20251029222326_create_content_migrations.rb +0 -30
  225. data/spec/internal/db/migrate/20251029222327_create_learning_outcomes.rb +0 -36
  226. data/spec/internal/db/migrate/20251029222328_create_learning_outcome_results.rb +0 -52
  227. data/spec/internal/db/migrate/20251029222330_create_rubrics.rb +0 -44
  228. data/spec/internal/db/migrate/20251029222331_create_rubric_associations.rb +0 -42
  229. data/spec/internal/db/migrate/20251029222332_create_rubric_assessments.rb +0 -37
  230. data/spec/internal/db/migrate/20251029222334_create_assignment_overrides.rb +0 -25
  231. data/spec/internal/db/migrate/20251029222335_create_scores.rb +0 -42
  232. data/spec/internal/db/migrate/20251029223411_create_user_observers.rb +0 -23
  233. data/spec/internal/db/migrate/20251029224009_create_course_nicknames.rb +0 -23
  234. data/spec/internal/db/migrate/20251029224010_create_course_progresses.rb +0 -26
  235. data/spec/support/fixtures/reports/provisioning_csv_unzipped/courses.csv +0 -3
  236. data/spec/support/fixtures/reports/provisioning_csv_unzipped/users.csv +0 -4
@@ -1,36 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class Rubric < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
-
13
- canvas_sync_features :defaults
14
-
15
- validates :canvas_id, uniqueness: true, presence: true
16
- belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id
17
- belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id # based on another rubric
18
- belongs_to :context, polymorphic: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
19
-
20
- has_many :rubric_assessments, through: :rubric_associations, dependent: :destroy
21
- has_many :rubric_associations, primary_key: :canvas_id, foreign_key: :canvas_rubric_id
22
- has_many :associated_objects, through: :rubric_associations, source: :association_object
23
-
24
- api_syncable({
25
- canvas_id: :id,
26
- title: :title,
27
- canvas_context_id: :context_id,
28
- canvas_context_type: :context_type,
29
- points_possible: :points_possible,
30
- reusable: :reusable,
31
- read_only: :read_only,
32
- free_form_criterion_comments: :free_form_criterion_comments,
33
- hide_score_total: :hide_score_total,
34
- data: :data,
35
- }, -> (api) { api.rubrics("self", canvas_id) })
36
- end
@@ -1,23 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class RubricAssessment < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
-
13
- canvas_sync_features :defaults
14
-
15
- validates :canvas_id, uniqueness: true, presence: true
16
-
17
- belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id, optional: true
18
- belongs_to :rubric_association, primary_key: :canvas_id, foreign_key: :canvas_rubric_association_id, optional: true
19
- belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
20
- belongs_to :assessor, class_name: "User", primary_key: :canvas_id, foreign_key: :canvas_assessor_id, optional: true
21
- belongs_to :artifact, polymorphic: true, primary_key: :canvas_id, foreign_type: :canvas_artifact_type, foreign_key: :canvas_artifact_id, optional: true
22
-
23
- end
@@ -1,20 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class RubricAssociation < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
-
13
- canvas_sync_features :defaults
14
-
15
- validates :canvas_id, uniqueness: true, presence: true
16
- belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id, optional: true
17
- belongs_to :association_object, polymorphic: true, primary_key: :canvas_id, foreign_type: :canvas_association_type, optional: true
18
- belongs_to :context, polymorphic: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, optional: true
19
- has_many :rubric_assessments
20
- end
@@ -1,18 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class Score < ApplicationRecord
10
- include CanvasSync::Record
11
-
12
- canvas_sync_features :defaults
13
-
14
- validates :canvas_id, uniqueness: true, presence: true
15
- belongs_to :enrollment, primary_key: :canvas_id, foreign_key: :canvas_enrollment_id, optional: true
16
- belongs_to :assignment_group, primary_key: :canvas_id, foreign_key: :canvas_assignment_group_id, optional: true
17
- belongs_to :grading_period, primary_key: :canvas_id, foreign_key: :canvas_grading_period_id, optional: true
18
- end
@@ -1,36 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class Section < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
- # include CanvasSync::Concerns::DeletedScoping
13
-
14
- canvas_sync_features :defaults
15
-
16
- # include CanvasSync::Concerns::LiveEventSync
17
- # after_process_live_event do
18
- # # A section change could constitute a crosslisting change, which means
19
- # # we need to make sure all our enrollments are pointing to the correct course
20
- # enrollments.update_all(canvas_course_id: canvas_course_id)
21
- # end
22
-
23
- validates :canvas_id, uniqueness: true, presence: true
24
- belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
25
- has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_section_id
26
-
27
- api_syncable({
28
- sis_id: :sis_section_id,
29
- canvas_course_id: :course_id,
30
- canvas_nonxlist_course_id: :nonxlist_course_id,
31
- name: :name,
32
- start_at: :start_at,
33
- end_at: :end_at,
34
- workflow_state: ->(r){ 'active' },
35
- }, -> (api) { api.section(canvas_id) })
36
- end
@@ -1,32 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class Submission < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
- # include CanvasSync::Concerns::LiveEventSync
13
- # include CanvasSync::Concerns::DeletedScoping
14
-
15
- canvas_sync_features :defaults
16
-
17
- validates :canvas_id, uniqueness: true, presence: true
18
- belongs_to :assignment, primary_key: :canvas_id, foreign_key: :canvas_assignment_id, optional: true
19
- belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
20
- belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
21
-
22
- api_syncable({
23
- canvas_assignment_id: :assignment_id,
24
- canvas_user_id: :user_id,
25
- submitted_at: :submitted_at,
26
- graded_at: :graded_at,
27
- cached_due_date: :due_at,
28
- score: :score,
29
- excused: :excused,
30
- workflow_state: :workflow_state,
31
- }, -> (api) { api.user_course_assignment_submission(assignment.context.canvas_id, canvas_assignment_id, canvas_user_id) })
32
- end
@@ -1,46 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class Term < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
- # include CanvasSync::Concerns::DeletedScoping
13
-
14
- canvas_sync_features :defaults
15
-
16
- validates :canvas_id, uniqueness: true, presence: true
17
- has_many :courses, foreign_key: :canvas_term_id, primary_key: :canvas_id
18
- belongs_to :grading_period_group, primary_key: :canvas_id, foreign_key: :grading_period_group_id, optional: true
19
-
20
- api_syncable({
21
- canvas_id: :id,
22
- name: :name,
23
- sis_id: :sis_term_id,
24
- start_at: :start_at,
25
- end_at: :end_at,
26
- workflow_state: :workflow_state,
27
- grading_period_group_id: :grading_period_group_id,
28
- }, -> (api) {
29
- terms = api.terms('self').all_pages!
30
- term_data = terms.find{|term| term['id'] == canvas_id }
31
- raise Footrest::HttpError::NotFound unless term_data.present?
32
- term_data
33
- })
34
-
35
- # Our pattern has usually had `Term.active` include date scoping.
36
- # `active` here is then a bit of a misnomer, but the template is written to follow our previous patterns.
37
- scope :active, -> { where(workflow_state: 'active').current }
38
-
39
- scope :current, ->(grace_time: 0.seconds) {
40
- all
41
- .where("#{current_table_name}.start_at <= ? OR #{current_table_name}.start_at IS NULL", grace_time.from_now)
42
- .where("#{current_table_name}.end_at >= ? OR #{current_table_name}.end_at IS NULL", grace_time.ago)
43
- }
44
-
45
- scope :should_canvas_sync, -> { where(workflow_state: 'active').current(grace_time: 15.days) }
46
- end
@@ -1,43 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class User < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
- # include CanvasSync::Concerns::DeletedScoping
13
-
14
- canvas_sync_features :defaults
15
-
16
- # include CanvasSync::Concerns::LiveEventSync
17
- # around_process_live_event do |user, blk|
18
- # blk.call
19
- # rescue Footrest::HttpError::Unauthorized => e
20
- # # This can happen when a new user is created, but hasn't setup a login on Canvas yet.
21
- # Rails.logger.info("Failed to fetch user #{canvas_user_id}: #{e.backtrace}")
22
- # end
23
-
24
- validates :canvas_id, uniqueness: true, presence: true
25
- has_many :pseudonyms, primary_key: :canvas_id, foreign_key: :canvas_user_id
26
- has_many :active_pseudonyms, ->() { active }, primary_key: :canvas_id, foreign_key: :canvas_user_id, class_name: "Pseudonym"
27
- has_many :all_pseudonyms, primary_key: :canvas_id, foreign_key: :canvas_user_id, class_name: "Pseudonym"
28
- has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_user_id
29
- has_many :admins, primary_key: :canvas_id, foreign_key: :canvas_user_id
30
- has_many :admin_roles, through: :admins, source: :role
31
- has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_user_id
32
- has_many :group_memberships, primary_key: :canvas_id, foreign_key: :canvas_user_id
33
- has_many :rubrics, primary_key: :canvas_id, foreign_key: :canvas_user_id
34
-
35
- api_syncable({
36
- sis_id: :sis_user_id,
37
- email: :email,
38
- login_id: :login_id,
39
- name: :name,
40
- sortable_name: :sortable_name,
41
- first_name: :short_name,
42
- }, -> (api) { api.user_detail(canvas_id) })
43
- end
@@ -1,22 +0,0 @@
1
- # #
2
- # AUTO GENERATED MODEL
3
- # This model was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
-
8
-
9
- class UserObserver < ApplicationRecord
10
- include CanvasSync::Record
11
- include CanvasSync::Concerns::ApiSyncable
12
- # include CanvasSync::Concerns::DeletedScoping
13
-
14
- canvas_sync_features :defaults
15
-
16
- self.primary_key = [:observing_user_id, :observed_user_id] unless column_names.include?("id")
17
-
18
- validates :canvas_id, uniqueness: true, presence: true
19
-
20
- belongs_to :observing_user, primary_key: :canvas_id, foreign_key: :observing_user_id, class_name: 'User', optional: true
21
- belongs_to :observed_user, primary_key: :canvas_id, foreign_key: :observed_user_id, class_name: 'User', optional: true
22
- end
@@ -1,43 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class AssignmentEvent < CanvasSync::LiveEvents::BaseHandler
15
-
16
- def process
17
- canvas_assignment_id = local_canvas_id(payload[:assignment_id])
18
- assignment = Assignment.where(canvas_id: canvas_assignment_id).first_or_initialize
19
- assignment.context_id = canvas_course_id
20
- assignment.sync_from_api
21
- end
22
-
23
- private
24
-
25
- # This could be nil if the context type for this assignment is not 'Course' of if a local course was not found
26
- def canvas_course_id
27
- payload[:context_type] == "Course" ? local_canvas_id(payload[:context_id]) : nil
28
- end
29
-
30
- # This could be nil if the context type for this assignment is not 'Course' of if a local course was not found
31
- def course
32
- @course ||= begin
33
- course = Course.where(canvas_id: canvas_course_id).first_or_initialize
34
- course.sync_from_api unless course.persisted?
35
- course
36
- end
37
- end
38
-
39
- end
40
-
41
- class AssignmentCreatedEvent < LiveEvents::AssignmentEvent; end
42
- class AssignmentUpdatedEvent < LiveEvents::AssignmentEvent; end
43
- end
@@ -1,28 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class CourseEvent < CanvasSync::LiveEvents::BaseHandler
15
- def process
16
- course = Course.where(canvas_id: local_canvas_id(payload[:course_id])).first_or_initialize
17
- course.canvas_account_id = local_canvas_id(payload[:account_id])
18
- if course.account.nil?
19
- acc = Account.new(canvas_id: course.canvas_account_id)
20
- acc.sync_from_api
21
- end
22
- course.sync_from_api
23
- end
24
- end
25
-
26
- class CourseCreatedEvent < LiveEvents::CourseEvent; end
27
- class CourseUpdatedEvent < LiveEvents::CourseEvent; end
28
- end
@@ -1,28 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class CourseSectionEvent < CanvasSync::LiveEvents::BaseHandler
15
-
16
- def process
17
- section = Section.where(canvas_id: local_canvas_id(payload[:course_section_id])).first_or_initialize
18
- section.sync_from_api
19
- # A section change could constitute a crosslisting change, which means
20
- # we need to make sure all our enrollments are pointing to the correct course
21
- section.enrollments.update_all(canvas_course_id: section.canvas_course_id)
22
- end
23
-
24
- end
25
-
26
- class CourseSectionCreatedEvent < LiveEvents::CourseSectionEvent; end
27
- class CourseSectionUpdatedEvent < LiveEvents::CourseSectionEvent; end
28
- end
@@ -1,30 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class EnrollmentEvent < CanvasSync::LiveEvents::BaseHandler
15
- attr_accessor :enrollment
16
-
17
- def process()
18
- @enrollment = Enrollment.where(canvas_id: local_canvas_id(payload[:enrollment_id])).first_or_initialize
19
- enrollment.canvas_course_id = local_canvas_id(payload[:course_id])
20
- enrollment.sync_from_api
21
- if enrollment.user.nil?
22
- u = User.new(canvas_id: enrollment.canvas_user_id)
23
- u.sync_from_api
24
- end
25
- end
26
- end
27
-
28
- class EnrollmentCreatedEvent < LiveEvents::EnrollmentEvent; end
29
- class EnrollmentUpdatedEvent < LiveEvents::EnrollmentEvent; end
30
- end
@@ -1,36 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class GradeEvent < CanvasSync::LiveEvents::BaseHandler
15
-
16
- def process
17
- raise "process must be implemented in your subclass"
18
- end
19
-
20
- private
21
-
22
- def submission
23
- Submission.find_by(canvas_submission_id: local_canvas_id(payload[:submission_id]))
24
- end
25
-
26
- def assignment
27
- Assignment.find_by(canvas_assignment_id: local_canvas_id(payload[:assignment_id]))
28
- end
29
-
30
- def user
31
- User.find_by(canvas_user_id: local_canvas_id(payload[:user_id]))
32
- end
33
- end
34
-
35
- class GradeChangedEvent < LiveEvents::GradeEvent; end
36
- end
@@ -1,26 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class ModuleEvent < CanvasSync::LiveEvents::BaseHandler
15
-
16
- def process
17
- return unless payload["context_type"] == "Course"
18
- context_module = ContextModule.find_or_initialize_by(canvas_id: payload["module_id"])
19
- context_module.sync_from_api
20
- end
21
-
22
- end
23
-
24
- class ModuleCreatedEvent < LiveEvents::ModuleEvent; end
25
- class ModuleUpdatedEvent < LiveEvents::ModuleEvent; end
26
- end
@@ -1,25 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class ModuleItemEvent < CanvasSync::LiveEvents::BaseHandler
15
-
16
- def process
17
- context_module_item = ContextModuleItem.find_or_initialize_by(canvas_id: payload["module_item_id"])
18
- context_module_item.sync_from_api
19
- end
20
-
21
- end
22
-
23
- class ModuleItemCreatedEvent < LiveEvents::ModuleItemEvent; end
24
- class ModuleItemUpdatedEvent < LiveEvents::ModuleItemEvent; end
25
- end
@@ -1,28 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class SubmissionEvent < CanvasSync::LiveEvents::BaseHandler
15
-
16
- def process
17
- submission = Submission.where(canvas_id: local_canvas_id(payload["submission_id"])).first_or_initialize
18
- submission.canvas_assignment_id = local_canvas_id(payload["assignment_id"])
19
- submission.canvas_user_id = local_canvas_id(payload["user_id"])
20
- submission.canvas_course_id = submission.assignment.context.canvas_id
21
- submission.sync_from_api
22
- end
23
-
24
- end
25
-
26
- class SubmissionCreatedEvent < LiveEvents::SubmissionEvent; end
27
- class SubmissionUpdatedEvent < LiveEvents::SubmissionEvent; end
28
- end
@@ -1,31 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class SyllabusEvent < CanvasSync::LiveEvents::BaseHandler
15
-
16
- def process
17
- # syllabus = Syllabus.where(course_id: attrs[:course_id]).first_or_initialize
18
- # syllabus.body = attrs[:syllabus_body] # Syllabus Body can get truncated by live events
19
- # syllabus.save!
20
- raise "process must be implemented in your subclass"
21
- end
22
-
23
- private
24
-
25
- def course
26
- Course.find_by(canvas_course_id: local_canvas_id(payload[:course_id]))
27
- end
28
- end
29
-
30
- class SyllabusUpdatedEvent < LiveEvents::SyllabusEvent; end
31
- end
@@ -1,27 +0,0 @@
1
- # #
2
- # AUTO GENERATED LIVE EVENT
3
- # This was auto generated by the CanvasSync Gem.
4
- # You can customize it as needed, but make sure you test
5
- # any changes you make to the auto generated methods.
6
- #
7
- # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
8
- # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
9
- # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
10
- #
11
-
12
-
13
- module LiveEvents
14
- class UserEvent < CanvasSync::LiveEvents::BaseHandler
15
- def process
16
- canvas_user_id = local_canvas_id(payload[:user_id])
17
- user = User.where(canvas_id: canvas_user_id).first_or_initialize
18
- user.sync_from_api
19
- rescue Footrest::HttpError::Unauthorized => e
20
- # This can happen when a new user is created, but hasn't setup a login on Canvas yet.
21
- Rails.logger.info("Failed to fetch user #{canvas_user_id}: #{e.backtrace}")
22
- end
23
- end
24
-
25
- class UserCreatedEvent < LiveEvents::UserEvent; end
26
- class UserUpdatedEvent < LiveEvents::UserEvent; end
27
- end
@@ -1,26 +0,0 @@
1
- # #
2
- # AUTO GENERATED MIGRATION
3
- # This migration was auto generated by the CanvasSync Gem.
4
- # You can add new columns to this table, but removing or
5
- # re-naming ones created here may break Canvas Syncing.
6
- #
7
-
8
-
9
- class CreateUsers < ActiveRecord::Migration[5.1]
10
- def change
11
- create_table :users, id: false do |t|
12
- t.bigint :canvas_id, null: false
13
- t.string :email
14
- t.string :first_name
15
- t.string :last_name
16
- t.string :workflow_state
17
- t.string :login_id
18
- t.string :name
19
- t.string :sortable_name
20
-
21
- t.timestamps
22
- end
23
-
24
- add_index :users, :canvas_id, unique: true
25
- end
26
- end
@@ -1,24 +0,0 @@
1
- # #
2
- # AUTO GENERATED MIGRATION
3
- # This migration was auto generated by the CanvasSync Gem.
4
- # You can add new columns to this table, but removing or
5
- # re-naming ones created here may break Canvas Syncing.
6
- #
7
-
8
-
9
- class CreatePseudonyms < ActiveRecord::Migration[5.1]
10
- def change
11
- create_table :pseudonyms, id: false do |t|
12
- t.bigint :canvas_id, null: false
13
- t.bigint :canvas_user_id
14
- t.string :sis_id
15
- t.string :unique_id
16
- t.string :workflow_state
17
-
18
- t.timestamps
19
- end
20
-
21
- add_index :pseudonyms, :canvas_id, unique: true
22
- add_index :pseudonyms, :canvas_user_id
23
- end
24
- end