canvas_sync 0.9.4 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/lib/canvas_sync/api_syncable.rb +1 -0
  4. data/lib/canvas_sync/generators/install_generator.rb +3 -3
  5. data/lib/canvas_sync/generators/templates/migrations/create_accounts.rb +17 -0
  6. data/lib/canvas_sync/generators/templates/{models → migrations}/create_admins.rb +2 -2
  7. data/lib/canvas_sync/generators/templates/{models → migrations}/create_assignment_groups.rb +2 -2
  8. data/lib/canvas_sync/generators/templates/{models → migrations}/create_assignments.rb +7 -7
  9. data/lib/canvas_sync/generators/templates/{models → migrations}/create_context_module_items.rb +4 -4
  10. data/lib/canvas_sync/generators/templates/{models → migrations}/create_context_modules.rb +2 -2
  11. data/lib/canvas_sync/generators/templates/{models → migrations}/create_courses.rb +7 -8
  12. data/lib/canvas_sync/generators/templates/{models → migrations}/create_enrollments.rb +4 -6
  13. data/lib/canvas_sync/generators/templates/{models → migrations}/create_roles.rb +2 -2
  14. data/lib/canvas_sync/generators/templates/{models → migrations}/create_sections.rb +5 -5
  15. data/lib/canvas_sync/generators/templates/{models → migrations}/create_submissions.rb +2 -2
  16. data/lib/canvas_sync/generators/templates/{models → migrations}/create_terms.rb +2 -2
  17. data/lib/canvas_sync/generators/templates/{models → migrations}/create_users.rb +4 -4
  18. data/lib/canvas_sync/generators/templates/models/account.rb +4 -4
  19. data/lib/canvas_sync/generators/templates/models/admin.rb +4 -4
  20. data/lib/canvas_sync/generators/templates/models/assignment.rb +10 -9
  21. data/lib/canvas_sync/generators/templates/models/assignment_group.rb +5 -5
  22. data/lib/canvas_sync/generators/templates/models/context_module.rb +2 -2
  23. data/lib/canvas_sync/generators/templates/models/context_module_item.rb +3 -2
  24. data/lib/canvas_sync/generators/templates/models/course.rb +14 -14
  25. data/lib/canvas_sync/generators/templates/models/enrollment.rb +10 -9
  26. data/lib/canvas_sync/generators/templates/models/role.rb +3 -3
  27. data/lib/canvas_sync/generators/templates/models/section.rb +6 -6
  28. data/lib/canvas_sync/generators/templates/models/submission.rb +5 -5
  29. data/lib/canvas_sync/generators/templates/models/term.rb +4 -3
  30. data/lib/canvas_sync/generators/templates/models/user.rb +6 -6
  31. data/lib/canvas_sync/generators/templates/services/live_events/base_event.rb +4 -0
  32. data/lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb +1 -1
  33. data/lib/canvas_sync/generators/templates/services/live_events/course_section/course_section_event.rb +4 -4
  34. data/lib/canvas_sync/generators/templates/services/live_events/module/module_event.rb +1 -1
  35. data/lib/canvas_sync/generators/templates/services/live_events/module_item/module_item_event.rb +3 -3
  36. data/lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb +1 -1
  37. data/lib/canvas_sync/jobs/sync_provisioning_report_job.rb +7 -2
  38. data/lib/canvas_sync/jobs/sync_simple_table_job.rb +7 -2
  39. data/lib/canvas_sync/processors/model_mappings.yml +35 -41
  40. data/lib/canvas_sync/version.rb +1 -1
  41. data/spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb +4 -4
  42. data/spec/canvas_sync/jobs/sync_simple_table_job_spec.rb +3 -3
  43. data/spec/canvas_sync/models/accounts_spec.rb +2 -2
  44. data/spec/canvas_sync/models/admins_spec.rb +3 -3
  45. data/spec/canvas_sync/models/assignment_group_spec.rb +4 -4
  46. data/spec/canvas_sync/models/assignment_spec.rb +8 -8
  47. data/spec/canvas_sync/models/context_module_spec.rb +2 -2
  48. data/spec/canvas_sync/models/course_spec.rb +7 -8
  49. data/spec/canvas_sync/models/enrollment_spec.rb +5 -5
  50. data/spec/canvas_sync/models/roles_spec.rb +3 -3
  51. data/spec/canvas_sync/models/section_spec.rb +4 -4
  52. data/spec/canvas_sync/models/submission_spec.rb +5 -5
  53. data/spec/canvas_sync/models/term_spec.rb +7 -7
  54. data/spec/canvas_sync/models/user_spec.rb +4 -4
  55. data/spec/canvas_sync/processors/provisioning_report_processor_spec.rb +5 -5
  56. data/spec/canvas_sync/services/module_event_spec.rb +1 -1
  57. data/spec/canvas_sync/services/module_item_event_spec.rb +7 -7
  58. data/spec/dummy/app/models/account.rb +9 -1
  59. data/spec/dummy/app/models/admin.rb +4 -4
  60. data/spec/dummy/app/models/assignment.rb +23 -5
  61. data/spec/dummy/app/models/assignment_group.rb +15 -3
  62. data/spec/dummy/app/models/context_module.rb +2 -2
  63. data/spec/dummy/app/models/context_module_item.rb +3 -2
  64. data/spec/dummy/app/models/course.rb +20 -7
  65. data/spec/dummy/app/models/enrollment.rb +20 -4
  66. data/spec/dummy/app/models/role.rb +3 -3
  67. data/spec/dummy/app/models/section.rb +14 -3
  68. data/spec/dummy/app/models/submission.rb +16 -4
  69. data/spec/dummy/app/models/term.rb +4 -3
  70. data/spec/dummy/app/models/user.rb +15 -4
  71. data/spec/dummy/app/services/live_events/base_event.rb +4 -0
  72. data/spec/dummy/app/services/live_events/course_event.rb +1 -1
  73. data/spec/dummy/app/services/live_events/course_section_event.rb +4 -4
  74. data/spec/dummy/app/services/live_events/module_event.rb +1 -1
  75. data/spec/dummy/app/services/live_events/module_item_event.rb +3 -3
  76. data/spec/dummy/app/services/live_events/user_event.rb +1 -1
  77. data/spec/dummy/db/migrate/{20180216171618_create_submissions.rb → 20190521003447_create_submissions.rb} +4 -4
  78. data/spec/dummy/db/migrate/{20180103162102_create_roles.rb → 20190521003448_create_roles.rb} +2 -2
  79. data/spec/dummy/db/migrate/{20180109210452_create_admins.rb → 20190521003449_create_admins.rb} +2 -2
  80. data/spec/dummy/db/migrate/{20180222163506_create_assignment_groups.rb → 20190521003450_create_assignment_groups.rb} +2 -2
  81. data/spec/dummy/db/migrate/{20180411215348_create_context_modules.rb → 20190521003451_create_context_modules.rb} +2 -2
  82. data/spec/dummy/db/migrate/{20180215214227_create_assignments.rb → 20190603192310_create_assignments.rb} +11 -11
  83. data/spec/dummy/db/migrate/{20180605172338_create_context_module_items.rb → 20190603193502_create_context_module_items.rb} +4 -4
  84. data/spec/dummy/db/migrate/{20180509194201_create_users.rb → 20190603215718_create_users.rb} +4 -4
  85. data/spec/dummy/db/migrate/{20170906193506_create_terms.rb → 20190603215721_create_terms.rb} +2 -2
  86. data/spec/dummy/db/migrate/{20171107213207_create_sections.rb → 20190603215722_create_sections.rb} +5 -5
  87. data/spec/dummy/db/migrate/{20170914181345_create_courses.rb → 20190603220011_create_courses.rb} +7 -8
  88. data/spec/dummy/db/migrate/{20170905192509_create_enrollments.rb → 20190603220013_create_enrollments.rb} +4 -6
  89. data/spec/dummy/db/migrate/{20180220172559_create_accounts.rb → 20190604193942_create_accounts.rb} +6 -6
  90. data/spec/dummy/db/schema.rb +56 -58
  91. data/spec/dummy/log/test.log +1350 -0
  92. data/spec/factories/account_factory.rb +5 -5
  93. data/spec/factories/admin_factory.rb +1 -1
  94. data/spec/factories/assignment_factory.rb +1 -1
  95. data/spec/factories/assignment_group_factory.rb +1 -1
  96. data/spec/factories/context_module_factory.rb +2 -2
  97. data/spec/factories/context_module_item_factory.rb +1 -1
  98. data/spec/factories/course_factory.rb +5 -5
  99. data/spec/factories/enrollment_factory.rb +1 -1
  100. data/spec/factories/role_factory.rb +1 -1
  101. data/spec/factories/section_factory.rb +1 -1
  102. data/spec/factories/submission_factory.rb +1 -1
  103. data/spec/factories/term_factory.rb +1 -1
  104. data/spec/factories/user_factory.rb +1 -1
  105. data/spec/spec_helper.rb +1 -0
  106. metadata +41 -41
  107. data/lib/canvas_sync/generators/templates/models/create_accounts.rb +0 -17
@@ -1,6 +1,7 @@
1
1
  # <%= autogenerated_migration_warning %>
2
2
 
3
3
  class ContextModuleItem < ApplicationRecord
4
- belongs_to :context_module, primary_key: :canvas_context_module_id, foreign_key: :canvas_context_module_id, optional: true
5
- belongs_to :assignment, foreign_key: :canvas_assignment_id, primary_key: :canvas_assignment_id
4
+ belongs_to :context_module, primary_key: :canvas_id, foreign_key: :canvas_context_module_id, optional: true
5
+ belongs_to :content, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_content_id, foreign_type: :canvas_content_type
6
+ belongs_to :assignment, foreign_key: :canvas_assignment_id, primary_key: :canvas_id
6
7
  end
@@ -3,22 +3,22 @@
3
3
  class Course < ApplicationRecord
4
4
  include CanvasSync::ApiSyncable
5
5
 
6
- validates :canvas_course_id, uniqueness: true, presence: true
7
- belongs_to :term, foreign_key: :canvas_term_id, primary_key: :canvas_term_id, optional: true
8
- has_many :enrollments, primary_key: :canvas_course_id, foreign_key: :canvas_course_id
9
- has_many :sections, primary_key: :canvas_course_id, foreign_key: :canvas_course_id
10
- has_many :assignments, as: :context, primary_key: :canvas_course_id
11
- has_many :submissions, primary_key: :canvas_course_id, foreign_key: :canvas_course_id
12
- has_many :assignment_groups, primary_key: :canvas_course_id, foreign_key: :canvas_course_id
13
-
6
+ validates :canvas_id, uniqueness: true, presence: true
7
+ belongs_to :term, foreign_key: :canvas_term_id, primary_key: :canvas_id, optional: true
8
+ has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_course_id
9
+ has_many :sections, primary_key: :canvas_id, foreign_key: :canvas_course_id
10
+ has_many :assignments, as: :context, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
11
+ has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_course_id
12
+ has_many :assignment_groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
13
+
14
14
  api_syncable({
15
15
  sis_id: :sis_course_id,
16
- short_name: :course_code,
17
- long_name: :name,
18
- status: :workflow_state,
16
+ course_code: :course_code,
17
+ name: :name,
18
+ workflow_state: :workflow_state,
19
19
  canvas_term_id: :enrollment_term_id,
20
20
  canvas_account_id: :account_id,
21
- start_date: :start_at,
22
- end_date: :end_at,
23
- }, -> (api) { api.course(canvas_course_id) })
21
+ start_at: :start_at,
22
+ end_at: :end_at,
23
+ }, -> (api) { api.course(canvas_id) })
24
24
  end
@@ -3,21 +3,22 @@
3
3
  class Enrollment < ApplicationRecord
4
4
  include CanvasSync::ApiSyncable
5
5
 
6
- validates :canvas_enrollment_id, uniqueness: true, presence: true
7
- belongs_to :user, primary_key: :canvas_user_id, foreign_key: :canvas_user_id, optional: true
8
- belongs_to :course, primary_key: :canvas_course_id, foreign_key: :canvas_course_id, optional: true
9
- belongs_to :section, primary_key: :canvas_section_id, foreign_key: :canvas_section_id, optional: true
6
+ validates :canvas_id, uniqueness: true, presence: true
7
+ belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
8
+ belongs_to :role, primary_key: :canvas_id, foreign_key: :canvas_role_id, optional: true
9
+ belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
10
+ belongs_to :section, primary_key: :canvas_id, foreign_key: :canvas_section_id, optional: true
10
11
 
11
12
  api_syncable({
12
- canvas_enrollment_id: :id,
13
+ canvas_id: :id,
13
14
  canvas_course_id: :course_id,
14
15
  course_sis_id: :sis_course_id,
15
16
  canvas_user_id: :user_id,
16
17
  user_sis_id: :sis_user_id,
17
18
  canvas_section_id: :course_section_id,
18
- section_sis_id: :sis_section_id,
19
19
  role: :role,
20
- role_id: :role_id,
21
- status: :enrollment_state,
22
- }, -> (api) { api.enrollment("self", canvas_enrollment_id) })
20
+ canvas_role_id: :role_id,
21
+ base_role_type: :type,
22
+ workflow_state: :enrollment_state,
23
+ }, -> (api) { api.enrollment("self", canvas_id) })
23
24
  end
@@ -1,11 +1,11 @@
1
1
  <%= autogenerated_model_warning %>
2
2
 
3
3
  class Role < ApplicationRecord
4
- validates :canvas_role_id, uniqueness: true, presence: true
5
- has_many :admins, foreign_key: :canvas_role_id, primary_key: :canvas_role_id
4
+ validates :canvas_id, uniqueness: true, presence: true
5
+ has_many :admins, foreign_key: :canvas_role_id, primary_key: :canvas_id
6
6
 
7
7
  def self.create_or_update(role_params)
8
- role = Role.find_or_initialize_by(canvas_role_id: role_params['id'])
8
+ role = Role.find_or_initialize_by(canvas_id: role_params['id'])
9
9
 
10
10
  role.assign_attributes(label: role_params['label'],
11
11
  base_role_type: role_params['base_role_type'],
@@ -3,16 +3,16 @@
3
3
  class Section < ApplicationRecord
4
4
  include CanvasSync::ApiSyncable
5
5
 
6
- validates :canvas_section_id, uniqueness: true, presence: true
7
- belongs_to :course, primary_key: :canvas_course_id, foreign_key: :canvas_course_id, optional: true
8
- has_many :enrollments, primary_key: :canvas_section_id, foreign_key: :canvas_section_id
6
+ validates :canvas_id, uniqueness: true, presence: true
7
+ belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
8
+ has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_section_id
9
9
 
10
10
  api_syncable({
11
11
  sis_id: :sis_section_id,
12
12
  canvas_course_id: :course_id,
13
13
  canvas_nonxlist_course_id: :nonxlist_course_id,
14
14
  name: :name,
15
- start_date: :start_at,
16
- end_date: :end_at,
17
- }, -> (api) { api.section(canvas_section_id) })
15
+ start_at: :start_at,
16
+ end_at: :end_at,
17
+ }, -> (api) { api.section(canvas_id) })
18
18
  end
@@ -3,10 +3,10 @@
3
3
  class Submission < ApplicationRecord
4
4
  include CanvasSync::ApiSyncable
5
5
 
6
- validates :canvas_submission_id, uniqueness: true, presence: true
7
- belongs_to :assignment, primary_key: :canvas_assignment_id, foreign_key: :canvas_assignment_id, optional: true
8
- belongs_to :user, primary_key: :canvas_user_id, foreign_key: :canvas_user_id, optional: true
9
- belongs_to :course, primary_key: :canvas_course_id, foreign_key: :canvas_course_id, optional: true
6
+ validates :canvas_id, uniqueness: true, presence: true
7
+ belongs_to :assignment, primary_key: :canvas_id, foreign_key: :canvas_assignment_id, optional: true
8
+ belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
9
+ belongs_to :course, primary_key: :canvas_id, foreign_key: :canvas_course_id, optional: true
10
10
 
11
11
  api_syncable({
12
12
  canvas_assignment_id: :assignment_id,
@@ -16,5 +16,5 @@ class Submission < ApplicationRecord
16
16
  score: :score,
17
17
  excused: :excused,
18
18
  workflow_state: :workflow_state,
19
- }, -> (api) { api.user_course_assignment_submission(assignment.context.canvas_course_id, canvas_assignment_id, canvas_user_id) })
19
+ }, -> (api) { api.user_course_assignment_submission(assignment.context.canvas_id, canvas_assignment_id, canvas_user_id) })
20
20
  end
@@ -1,8 +1,8 @@
1
1
  <%= autogenerated_model_warning %>
2
2
 
3
3
  class Term < ApplicationRecord
4
- validates :canvas_term_id, uniqueness: true, presence: true
5
- has_many :courses, foreign_key: :canvas_term_id, primary_key: :canvas_term_id
4
+ validates :canvas_id, uniqueness: true, presence: true
5
+ has_many :courses, foreign_key: :canvas_term_id, primary_key: :canvas_id
6
6
 
7
7
  # This is a sample scope created by the CanvasSync gem; feel
8
8
  # free to customize it for your tool's requirements.
@@ -13,7 +13,7 @@ class Term < ApplicationRecord
13
13
  }
14
14
 
15
15
  def self.create_or_update(term_params)
16
- term = Term.find_or_initialize_by(canvas_term_id: term_params['id'])
16
+ term = Term.find_or_initialize_by(canvas_id: term_params['id'])
17
17
 
18
18
  term.assign_attributes(name: term_params['name'],
19
19
  start_at: term_params['start_at'],
@@ -25,4 +25,5 @@ class Term < ApplicationRecord
25
25
  term.save! if term.changed?
26
26
  term
27
27
  end
28
+
28
29
  end
@@ -3,18 +3,18 @@
3
3
  class User < ApplicationRecord
4
4
  include CanvasSync::ApiSyncable
5
5
 
6
- validates :canvas_user_id, uniqueness: true, presence: true
7
- has_many :enrollments, primary_key: :canvas_user_id, foreign_key: :canvas_user_id
8
- has_many :admins, foreign_key: :canvas_user_id, primary_key: :canvas_user_id
6
+ validates :canvas_id, uniqueness: true, presence: true
7
+ has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_user_id
8
+ has_many :admins, primary_key: :canvas_id, foreign_key: :canvas_user_id
9
9
  has_many :admin_roles, through: :admins, source: :role
10
- has_many :submissions, primary_key: :canvas_user_id, foreign_key: :canvas_user_id
10
+ has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_user_id
11
11
 
12
12
  api_syncable({
13
13
  sis_id: :sis_user_id,
14
14
  email: :email,
15
15
  login_id: :login_id,
16
- full_name: :name,
16
+ name: :name,
17
17
  sortable_name: :sortable_name,
18
18
  first_name: :short_name,
19
- }, -> (api) { api.user_detail(canvas_user_id) })
19
+ }, -> (api) { api.user_detail(canvas_id) })
20
20
  end
@@ -2,9 +2,13 @@
2
2
 
3
3
  module LiveEvents
4
4
  class BaseEvent < CanvasSync::Job
5
+ attr_accessor :raw_payload
5
6
  attr_accessor :payload
7
+ attr_accessor :metadata
6
8
 
7
9
  def perform(event_payload)
10
+ @raw_payload = event_payload
11
+ @metadata = HashWithIndifferentAccess.new(event_payload["attributes"])
8
12
  @payload = HashWithIndifferentAccess.new(event_payload["body"])
9
13
  end
10
14
 
@@ -18,7 +18,7 @@ module LiveEvents
18
18
  attrs = {
19
19
  canvas_course_id: local_canvas_id(payload[:course_id]),
20
20
  canvas_account_id: local_canvas_id(payload[:account_id]),
21
- long_name: payload[:name],
21
+ name: payload[:name],
22
22
  status: payload[:workflow_state],
23
23
  }
24
24
  create_or_update(attrs)
@@ -5,7 +5,7 @@ module LiveEvents
5
5
  # The following is provided in the live events call:
6
6
  # {
7
7
  # course_section_id: section.id,
8
- # sis_source_id: section.sis_source_id,
8
+ # sis_id: section.sis_id,
9
9
  # sis_batch_id: section.sis_batch_id,
10
10
  # course_id: section.course_id,
11
11
  # root_account_id: section.root_account_id,
@@ -29,9 +29,9 @@ module LiveEvents
29
29
  canvas_section_id: local_canvas_id(payload[:course_section_id]),
30
30
  canvas_course_id: local_canvas_id(payload[:course_id]),
31
31
  name: payload[:name],
32
- status: payload[:workflow_state],
33
- start_date: payload[:start_at],
34
- end_date: payload[:end_at],
32
+ workflow_state: payload[:workflow_state],
33
+ start_at: payload[:start_at],
34
+ end_at: payload[:end_at],
35
35
  canvas_nonxlist_course_id: payload[:nonxlist_course_id],
36
36
  }
37
37
  create_or_update(attrs)
@@ -21,7 +21,7 @@ module LiveEvents
21
21
 
22
22
  def create_or_update_from_api(payload)
23
23
  return unless payload["context_type"] == "Course"
24
- context_module = ContextModule.find_or_initialize_by(canvas_context_module_id: payload["module_id"])
24
+ context_module = ContextModule.find_or_initialize_by(canvas_id: payload["module_id"])
25
25
  api_params = canvas_sync_client.course_module(payload["context_id"], payload["module_id"])
26
26
 
27
27
  context_module.assign_attributes(
@@ -20,15 +20,15 @@ module LiveEvents
20
20
  private
21
21
 
22
22
  def create_or_update_from_api(payload)
23
- context_module_item = ContextModuleItem.find_or_initialize_by(canvas_context_module_item_id: payload["module_item_id"])
23
+ context_module_item = ContextModuleItem.find_or_initialize_by(canvas_id: payload["module_item_id"])
24
24
  api_params = canvas_sync_client.module_item(payload["context_id"], payload["module_id"], payload["module_item_id"])
25
25
 
26
26
  context_module_item.assign_attributes(
27
27
  canvas_context_module_id: payload["module_id"],
28
28
  position: payload["position"],
29
29
  workflow_state: payload["workflow_state"],
30
- content_id: api_params["content_id"],
31
- content_type: api_params["type"],
30
+ canvas_content_id: api_params["content_id"],
31
+ canvas_content_type: api_params["type"],
32
32
  )
33
33
 
34
34
  context_module_item.save! if context_module_item.changed?
@@ -17,7 +17,7 @@ module LiveEvents
17
17
  super
18
18
  attrs = {
19
19
  canvas_user_id: local_canvas_id(payload[:user_id]),
20
- full_name: payload[:name],
20
+ name: payload[:name],
21
21
  status: payload[:workflow_state],
22
22
  }
23
23
  create_or_update(attrs)
@@ -11,9 +11,10 @@ module CanvasSync
11
11
  Term.send(options[:term_scope]).find_each do |term|
12
12
  # Deep copy the job_chain so each report gets the correct term id passed into
13
13
  # its options with no side effects
14
+ term_id = get_term_id(term)
14
15
  duped_job_chain = Marshal.load(Marshal.dump(job_chain))
15
- duped_job_chain[:global_options][:canvas_term_id] = term.canvas_term_id
16
- start_report(report_params(options, term.canvas_term_id), duped_job_chain, options)
16
+ duped_job_chain[:global_options][:canvas_term_id] = term_id
17
+ start_report(report_params(options, term_id), duped_job_chain, options)
17
18
  end
18
19
  else
19
20
  start_report(report_params(options), job_chain, options)
@@ -45,6 +46,10 @@ module CanvasSync
45
46
 
46
47
  params
47
48
  end
49
+
50
+ def get_term_id(term)
51
+ term.try(:canvas_id) || term.canvas_term_id
52
+ end
48
53
  end
49
54
  end
50
55
  end
@@ -12,9 +12,10 @@ module CanvasSync
12
12
  Term.send(options[:term_scope]).find_each do |term|
13
13
  # Deep copy the job_chain so each report gets the correct term id passed into
14
14
  # its options with no side effects
15
+ term_id = get_term_id(term)
15
16
  duped_job_chain = Marshal.load(Marshal.dump(job_chain))
16
- duped_job_chain[:global_options][:canvas_term_id] = term.canvas_term_id
17
- start_report(report_params(options, term.canvas_term_id), duped_job_chain, options)
17
+ duped_job_chain[:global_options][:canvas_term_id] = term_id
18
+ start_report(report_params(options, term_id), duped_job_chain, options)
18
19
  end
19
20
  else
20
21
  start_report(report_params(options), job_chain, options)
@@ -36,6 +37,10 @@ module CanvasSync
36
37
  params["parameters[enrollment_term_id]"] = canvas_term_id if canvas_term_id
37
38
  params
38
39
  end
40
+
41
+ def get_term_id(term)
42
+ term.try(:canvas_id) || term.canvas_term_id
43
+ end
39
44
  end
40
45
  end
41
46
  end
@@ -2,7 +2,7 @@ users:
2
2
  conflict_target: canvas_user_id
3
3
  report_columns:
4
4
  canvas_user_id:
5
- database_column_name: canvas_user_id
5
+ database_column_name: canvas_id
6
6
  type: integer
7
7
  user_id:
8
8
  database_column_name: sis_id
@@ -17,13 +17,13 @@ users:
17
17
  database_column_name: last_name
18
18
  type: string
19
19
  full_name:
20
- database_column_name: full_name
20
+ database_column_name: name
21
21
  type: string
22
22
  sortable_name:
23
23
  database_column_name: sortable_name
24
24
  type: string
25
25
  status:
26
- database_column_name: status
26
+ database_column_name: workflow_state
27
27
  type: string
28
28
  login_id:
29
29
  database_column_name: login_id
@@ -33,38 +33,38 @@ accounts:
33
33
  conflict_target: canvas_account_id
34
34
  report_columns:
35
35
  canvas_account_id:
36
- database_column_name: canvas_account_id
36
+ database_column_name: canvas_id
37
37
  type: integer
38
38
  account_id:
39
- database_column_name: account_id
39
+ database_column_name: sis_id
40
40
  type: string
41
41
  canvas_parent_id:
42
- database_column_name: canvas_parent_id
42
+ database_column_name: canvas_parent_account_id
43
43
  type: integer
44
44
  parent_account_id:
45
- database_column_name: parent_account_id
45
+ database_column_name: sis_parent_account_id
46
46
  type: string
47
47
  name:
48
48
  database_column_name: name
49
49
  type: string
50
50
  status:
51
- database_column_name: status
51
+ database_column_name: workflow_state
52
52
  type: string
53
53
 
54
54
  courses:
55
55
  conflict_target: canvas_course_id
56
56
  report_columns:
57
57
  canvas_course_id:
58
- database_column_name: canvas_course_id
58
+ database_column_name: canvas_id
59
59
  type: integer
60
60
  course_id:
61
61
  database_column_name: sis_id
62
62
  type: string
63
63
  short_name:
64
- database_column_name: short_name
64
+ database_column_name: course_code
65
65
  type: string
66
66
  long_name:
67
- database_column_name: long_name
67
+ database_column_name: name
68
68
  type: string
69
69
  canvas_account_id:
70
70
  database_column_name: canvas_account_id
@@ -72,24 +72,21 @@ courses:
72
72
  canvas_term_id:
73
73
  database_column_name: canvas_term_id
74
74
  type: integer
75
- term_id:
76
- database_column_name: term_sis_id
77
- type: string
78
75
  start_date:
79
- database_column_name: start_date
76
+ database_column_name: start_at
80
77
  type: datetime
81
78
  end_date:
82
- database_column_name: end_date
79
+ database_column_name: end_at
83
80
  type: datetime
84
81
  status:
85
- database_column_name: status
82
+ database_column_name: workflow_state
86
83
  type: integer
87
84
 
88
85
  enrollments:
89
86
  conflict_target: canvas_enrollment_id
90
87
  report_columns:
91
88
  canvas_enrollment_id:
92
- database_column_name: canvas_enrollment_id
89
+ database_column_name: canvas_id
93
90
  type: integer
94
91
  canvas_course_id:
95
92
  database_column_name: canvas_course_id
@@ -107,16 +104,13 @@ enrollments:
107
104
  database_column_name: role
108
105
  type: string
109
106
  role_id:
110
- database_column_name: role_id
107
+ database_column_name: canvas_role_id
111
108
  type: integer
112
109
  canvas_section_id:
113
110
  database_column_name: canvas_section_id
114
111
  type: integer
115
- section_id:
116
- database_column_name: section_sis_id
117
- type: string
118
112
  status:
119
- database_column_name: status
113
+ database_column_name: workflow_state
120
114
  type: string
121
115
  base_role_type:
122
116
  database_column_name: base_role_type
@@ -126,7 +120,7 @@ sections:
126
120
  conflict_target: canvas_section_id
127
121
  report_columns:
128
122
  canvas_section_id:
129
- database_column_name: canvas_section_id
123
+ database_column_name: canvas_id
130
124
  type: integer
131
125
  section_id:
132
126
  database_column_name: sis_id
@@ -138,20 +132,20 @@ sections:
138
132
  database_column_name: name
139
133
  type: string
140
134
  status:
141
- database_column_name: status
135
+ database_column_name: workflow_state
142
136
  type: string
143
137
  start_date:
144
- database_column_name: start_date
138
+ database_column_name: start_at
145
139
  type: datetime
146
140
  end_date:
147
- database_column_name: end_date
141
+ database_column_name: end_at
148
142
  type: datetime
149
143
 
150
144
  xlist:
151
145
  conflict_target: canvas_section_id
152
146
  report_columns:
153
147
  canvas_section_id:
154
- database_column_name: canvas_section_id
148
+ database_column_name: canvas_id
155
149
  type: integer
156
150
  canvas_nonxlist_course_id:
157
151
  database_column_name: canvas_nonxlist_course_id
@@ -161,7 +155,7 @@ assignments:
161
155
  conflict_target: id
162
156
  report_columns:
163
157
  id:
164
- database_column_name: :canvas_assignment_id
158
+ database_column_name: canvas_id
165
159
  type: integer
166
160
  title:
167
161
  database_column_name: title
@@ -200,26 +194,26 @@ assignments:
200
194
  database_column_name: workflow_state
201
195
  type: string
202
196
  context_id:
203
- database_column_name: context_id
197
+ database_column_name: canvas_context_id
204
198
  type: integer
205
199
  context_type:
206
- database_column_name: context_type
200
+ database_column_name: canvas_context_type
207
201
  type: string
208
202
  assignment_group_id:
209
203
  database_column_name: canvas_assignment_group_id
210
204
  type: integer
211
205
  grading_scheme_id:
212
- database_column_name: grading_scheme_id
206
+ database_column_name: canvas_grading_scheme_id
213
207
  type: integer
214
208
  grading_standard_id:
215
- database_column_name: grading_standard_id
209
+ database_column_name: canvas_grading_standard_id
216
210
  type: integer
217
211
 
218
212
  submissions:
219
213
  conflict_target: submission_id
220
214
  report_columns:
221
215
  submission_id:
222
- database_column_name: :canvas_submission_id
216
+ database_column_name: canvas_id
223
217
  type: integer
224
218
  canvas_user_id:
225
219
  database_column_name: :canvas_user_id
@@ -253,7 +247,7 @@ assignment_groups:
253
247
  conflict_target: id
254
248
  report_columns:
255
249
  id:
256
- database_column_name: :canvas_assignment_group_id
250
+ database_column_name: canvas_id
257
251
  type: integer
258
252
  canvas_course_id:
259
253
  database_column_name: :canvas_course_id
@@ -284,7 +278,7 @@ context_modules:
284
278
  conflict_target: canvas_context_module_id
285
279
  report_columns:
286
280
  canvas_context_module_id:
287
- database_column_name: canvas_context_module_id
281
+ database_column_name: canvas_id
288
282
  type: integer
289
283
  canvas_context_id:
290
284
  database_column_name: canvas_context_id
@@ -309,7 +303,7 @@ context_module_items:
309
303
  conflict_target: canvas_context_module_item_id
310
304
  report_columns:
311
305
  canvas_context_module_item_id:
312
- database_column_name: canvas_context_module_item_id
306
+ database_column_name: canvas_id
313
307
  type: integer
314
308
  context_module_id:
315
309
  database_column_name: canvas_context_module_id
@@ -317,12 +311,12 @@ context_module_items:
317
311
  position:
318
312
  database_column_name: position
319
313
  type: integer
320
- content_type:
321
- database_column_name: content_type
322
- type: string
323
314
  content_id:
324
- database_column_name: content_id
315
+ database_column_name: canvas_content_id
325
316
  type: integer
317
+ content_type:
318
+ database_column_name: canvas_content_type
319
+ type: string
326
320
  workflow_state:
327
321
  database_column_name: workflow_state
328
322
  type: string