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.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/canvas_sync/api_syncable.rb +1 -0
- data/lib/canvas_sync/generators/install_generator.rb +3 -3
- data/lib/canvas_sync/generators/templates/migrations/create_accounts.rb +17 -0
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_admins.rb +2 -2
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_assignment_groups.rb +2 -2
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_assignments.rb +7 -7
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_context_module_items.rb +4 -4
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_context_modules.rb +2 -2
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_courses.rb +7 -8
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_enrollments.rb +4 -6
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_roles.rb +2 -2
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_sections.rb +5 -5
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_submissions.rb +2 -2
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_terms.rb +2 -2
- data/lib/canvas_sync/generators/templates/{models → migrations}/create_users.rb +4 -4
- data/lib/canvas_sync/generators/templates/models/account.rb +4 -4
- data/lib/canvas_sync/generators/templates/models/admin.rb +4 -4
- data/lib/canvas_sync/generators/templates/models/assignment.rb +10 -9
- data/lib/canvas_sync/generators/templates/models/assignment_group.rb +5 -5
- data/lib/canvas_sync/generators/templates/models/context_module.rb +2 -2
- data/lib/canvas_sync/generators/templates/models/context_module_item.rb +3 -2
- data/lib/canvas_sync/generators/templates/models/course.rb +14 -14
- data/lib/canvas_sync/generators/templates/models/enrollment.rb +10 -9
- data/lib/canvas_sync/generators/templates/models/role.rb +3 -3
- data/lib/canvas_sync/generators/templates/models/section.rb +6 -6
- data/lib/canvas_sync/generators/templates/models/submission.rb +5 -5
- data/lib/canvas_sync/generators/templates/models/term.rb +4 -3
- data/lib/canvas_sync/generators/templates/models/user.rb +6 -6
- data/lib/canvas_sync/generators/templates/services/live_events/base_event.rb +4 -0
- data/lib/canvas_sync/generators/templates/services/live_events/course/course_event.rb +1 -1
- data/lib/canvas_sync/generators/templates/services/live_events/course_section/course_section_event.rb +4 -4
- data/lib/canvas_sync/generators/templates/services/live_events/module/module_event.rb +1 -1
- data/lib/canvas_sync/generators/templates/services/live_events/module_item/module_item_event.rb +3 -3
- data/lib/canvas_sync/generators/templates/services/live_events/user/user_event.rb +1 -1
- data/lib/canvas_sync/jobs/sync_provisioning_report_job.rb +7 -2
- data/lib/canvas_sync/jobs/sync_simple_table_job.rb +7 -2
- data/lib/canvas_sync/processors/model_mappings.yml +35 -41
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/canvas_sync/jobs/sync_provisioning_report_job_spec.rb +4 -4
- data/spec/canvas_sync/jobs/sync_simple_table_job_spec.rb +3 -3
- data/spec/canvas_sync/models/accounts_spec.rb +2 -2
- data/spec/canvas_sync/models/admins_spec.rb +3 -3
- data/spec/canvas_sync/models/assignment_group_spec.rb +4 -4
- data/spec/canvas_sync/models/assignment_spec.rb +8 -8
- data/spec/canvas_sync/models/context_module_spec.rb +2 -2
- data/spec/canvas_sync/models/course_spec.rb +7 -8
- data/spec/canvas_sync/models/enrollment_spec.rb +5 -5
- data/spec/canvas_sync/models/roles_spec.rb +3 -3
- data/spec/canvas_sync/models/section_spec.rb +4 -4
- data/spec/canvas_sync/models/submission_spec.rb +5 -5
- data/spec/canvas_sync/models/term_spec.rb +7 -7
- data/spec/canvas_sync/models/user_spec.rb +4 -4
- data/spec/canvas_sync/processors/provisioning_report_processor_spec.rb +5 -5
- data/spec/canvas_sync/services/module_event_spec.rb +1 -1
- data/spec/canvas_sync/services/module_item_event_spec.rb +7 -7
- data/spec/dummy/app/models/account.rb +9 -1
- data/spec/dummy/app/models/admin.rb +4 -4
- data/spec/dummy/app/models/assignment.rb +23 -5
- data/spec/dummy/app/models/assignment_group.rb +15 -3
- data/spec/dummy/app/models/context_module.rb +2 -2
- data/spec/dummy/app/models/context_module_item.rb +3 -2
- data/spec/dummy/app/models/course.rb +20 -7
- data/spec/dummy/app/models/enrollment.rb +20 -4
- data/spec/dummy/app/models/role.rb +3 -3
- data/spec/dummy/app/models/section.rb +14 -3
- data/spec/dummy/app/models/submission.rb +16 -4
- data/spec/dummy/app/models/term.rb +4 -3
- data/spec/dummy/app/models/user.rb +15 -4
- data/spec/dummy/app/services/live_events/base_event.rb +4 -0
- data/spec/dummy/app/services/live_events/course_event.rb +1 -1
- data/spec/dummy/app/services/live_events/course_section_event.rb +4 -4
- data/spec/dummy/app/services/live_events/module_event.rb +1 -1
- data/spec/dummy/app/services/live_events/module_item_event.rb +3 -3
- data/spec/dummy/app/services/live_events/user_event.rb +1 -1
- data/spec/dummy/db/migrate/{20180216171618_create_submissions.rb → 20190521003447_create_submissions.rb} +4 -4
- data/spec/dummy/db/migrate/{20180103162102_create_roles.rb → 20190521003448_create_roles.rb} +2 -2
- data/spec/dummy/db/migrate/{20180109210452_create_admins.rb → 20190521003449_create_admins.rb} +2 -2
- data/spec/dummy/db/migrate/{20180222163506_create_assignment_groups.rb → 20190521003450_create_assignment_groups.rb} +2 -2
- data/spec/dummy/db/migrate/{20180411215348_create_context_modules.rb → 20190521003451_create_context_modules.rb} +2 -2
- data/spec/dummy/db/migrate/{20180215214227_create_assignments.rb → 20190603192310_create_assignments.rb} +11 -11
- data/spec/dummy/db/migrate/{20180605172338_create_context_module_items.rb → 20190603193502_create_context_module_items.rb} +4 -4
- data/spec/dummy/db/migrate/{20180509194201_create_users.rb → 20190603215718_create_users.rb} +4 -4
- data/spec/dummy/db/migrate/{20170906193506_create_terms.rb → 20190603215721_create_terms.rb} +2 -2
- data/spec/dummy/db/migrate/{20171107213207_create_sections.rb → 20190603215722_create_sections.rb} +5 -5
- data/spec/dummy/db/migrate/{20170914181345_create_courses.rb → 20190603220011_create_courses.rb} +7 -8
- data/spec/dummy/db/migrate/{20170905192509_create_enrollments.rb → 20190603220013_create_enrollments.rb} +4 -6
- data/spec/dummy/db/migrate/{20180220172559_create_accounts.rb → 20190604193942_create_accounts.rb} +6 -6
- data/spec/dummy/db/schema.rb +56 -58
- data/spec/dummy/log/test.log +1350 -0
- data/spec/factories/account_factory.rb +5 -5
- data/spec/factories/admin_factory.rb +1 -1
- data/spec/factories/assignment_factory.rb +1 -1
- data/spec/factories/assignment_group_factory.rb +1 -1
- data/spec/factories/context_module_factory.rb +2 -2
- data/spec/factories/context_module_item_factory.rb +1 -1
- data/spec/factories/course_factory.rb +5 -5
- data/spec/factories/enrollment_factory.rb +1 -1
- data/spec/factories/role_factory.rb +1 -1
- data/spec/factories/section_factory.rb +1 -1
- data/spec/factories/submission_factory.rb +1 -1
- data/spec/factories/term_factory.rb +1 -1
- data/spec/factories/user_factory.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- metadata +41 -41
- data/lib/canvas_sync/generators/templates/models/create_accounts.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efb7341f8d1643d211f53ffde7c7fbaf9c7e0b89359d83ffa12e293f8e977863
|
4
|
+
data.tar.gz: 4919a841fc27a2b85cb0049f03a18a46f27d1c5928345eaf2dd3460fba764f06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae1217a2ab3c9f5168cd759372ac0d306e906bf185a3f6684c208443f9611ce494d7cd8d6ccd732e11425ddf3711c5886fb43b7caa881d1d9064ab10e6d85c9c
|
7
|
+
data.tar.gz: 619b4f60710761a1381074d1d058fb49e6b09f79264b7ed57f97143f2bcab468fb0e1eb0571591aaedd7b9536b5318acc7463a01a3732014b974fc33457c5dc0
|
data/README.md
CHANGED
@@ -237,6 +237,14 @@ end
|
|
237
237
|
|
238
238
|
## Legacy Support
|
239
239
|
|
240
|
+
### Legacy Mappings
|
241
|
+
|
242
|
+
CanvasSync 0.10.0+, by default, changes Canvas primary-keys from `:canvas_MODEL_id` to just `:canvas_id`.
|
243
|
+
Because CanvasSync primarily consists of templates, this change shouldn't require any large changes in your app, but you will need to
|
244
|
+
apply the `model_mappings_legacy.yml` (located in the root of this repo) to your model mappings - see [Mapping Overrides](#mapping-overrides).
|
245
|
+
|
246
|
+
### Row-by-Row Syncing
|
247
|
+
|
240
248
|
If you have an old style tool that needs to sync data on a row by row basis, you can pass in the `legacy_support: true` option. In order for this to work, your models must have a `create_or_update_from_csv` class method defined that accepts a row argument. This method will get passed each row from the CSV, and it's up to you to persist it.
|
241
249
|
|
242
250
|
Example:
|
@@ -4,7 +4,7 @@ require "rails/generators/migration"
|
|
4
4
|
module CanvasSync
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
6
|
include Rails::Generators::Migration
|
7
|
-
source_root File.expand_path("../templates
|
7
|
+
source_root File.expand_path("../templates", __FILE__)
|
8
8
|
class_option :models, type: :string, required: true
|
9
9
|
|
10
10
|
def self.next_migration_number(path)
|
@@ -46,8 +46,8 @@ module CanvasSync
|
|
46
46
|
CanvasSync.validate_models!(models)
|
47
47
|
|
48
48
|
models.each do |model|
|
49
|
-
migration_template "create_#{model}.rb", "db/migrate/create_#{model}.rb"
|
50
|
-
template "
|
49
|
+
migration_template "migrations/create_#{model}.rb", "db/migrate/create_#{model}.rb"
|
50
|
+
template "models/#{model.singularize}.rb", "app/models/#{model.singularize}.rb"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= autogenerated_migration_warning %>
|
2
|
+
|
3
|
+
class CreateAccounts < ActiveRecord::Migration[5.1]
|
4
|
+
def change
|
5
|
+
create_table :accounts do |t|
|
6
|
+
t.bigint :canvas_id, null: false
|
7
|
+
t.string :sis_id
|
8
|
+
t.bigint :canvas_parent_account_id
|
9
|
+
t.string :sis_parent_account_id
|
10
|
+
t.string :name
|
11
|
+
t.string :workflow_state
|
12
|
+
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
add_index :accounts, :canvas_id, unique: true
|
16
|
+
end
|
17
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateAdmins < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :admins do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.string :role_name
|
8
8
|
t.bigint :canvas_role_id, null: false
|
9
9
|
t.json :user_data
|
@@ -12,6 +12,6 @@ class CreateAdmins < ActiveRecord::Migration[5.1]
|
|
12
12
|
|
13
13
|
t.timestamps
|
14
14
|
end
|
15
|
-
add_index :admins, :
|
15
|
+
add_index :admins, :canvas_id, unique: true
|
16
16
|
end
|
17
17
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateAssignmentGroups < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :assignment_groups do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.bigint :canvas_course_id
|
8
8
|
t.string :name
|
9
9
|
t.text :rules
|
@@ -16,7 +16,7 @@ class CreateAssignmentGroups < ActiveRecord::Migration[5.1]
|
|
16
16
|
t.timestamps
|
17
17
|
end
|
18
18
|
|
19
|
-
add_index :assignment_groups, :
|
19
|
+
add_index :assignment_groups, :canvas_id, unique: true
|
20
20
|
add_index :assignment_groups, :canvas_course_id
|
21
21
|
end
|
22
22
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateAssignments < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :assignments do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.string :title
|
8
8
|
t.text :description
|
9
9
|
t.datetime :due_at
|
@@ -16,16 +16,16 @@ class CreateAssignments < ActiveRecord::Migration[5.1]
|
|
16
16
|
t.string :grading_type
|
17
17
|
t.string :submission_types
|
18
18
|
t.string :workflow_state
|
19
|
-
t.integer :
|
20
|
-
t.string :
|
19
|
+
t.integer :canvas_context_id
|
20
|
+
t.string :canvas_context_type
|
21
21
|
t.integer :canvas_assignment_group_id
|
22
|
-
t.integer :
|
23
|
-
t.integer :
|
22
|
+
t.integer :canvas_grading_scheme_id
|
23
|
+
t.integer :canvas_grading_standard_id
|
24
24
|
|
25
25
|
t.timestamps
|
26
26
|
end
|
27
27
|
|
28
|
-
add_index :assignments, :
|
29
|
-
add_index :assignments, [:
|
28
|
+
add_index :assignments, :canvas_id, unique: true
|
29
|
+
add_index :assignments, [:canvas_context_id, :canvas_context_type]
|
30
30
|
end
|
31
31
|
end
|
data/lib/canvas_sync/generators/templates/{models → migrations}/create_context_module_items.rb
RENAMED
@@ -3,18 +3,18 @@
|
|
3
3
|
class CreateContextModuleItems < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :context_module_items do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id
|
7
7
|
t.bigint :canvas_context_module_id
|
8
8
|
t.integer :position
|
9
|
-
t.
|
10
|
-
t.
|
9
|
+
t.bigint :canvas_content_id
|
10
|
+
t.string :canvas_content_type
|
11
11
|
t.bigint :canvas_assignment_id
|
12
12
|
t.string :workflow_state
|
13
13
|
|
14
14
|
t.timestamps
|
15
15
|
end
|
16
16
|
|
17
|
-
add_index :context_module_items, :
|
17
|
+
add_index :context_module_items, :canvas_id, unique: true
|
18
18
|
add_index :context_module_items, :canvas_context_module_id
|
19
19
|
end
|
20
20
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateContextModules < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :context_modules do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id
|
7
7
|
t.bigint :canvas_context_id
|
8
8
|
t.string :canvas_context_type
|
9
9
|
t.integer :position
|
@@ -14,7 +14,7 @@ class CreateContextModules < ActiveRecord::Migration[5.1]
|
|
14
14
|
t.timestamps
|
15
15
|
end
|
16
16
|
|
17
|
-
add_index :context_modules, :
|
17
|
+
add_index :context_modules, :canvas_id, unique: true
|
18
18
|
add_index :context_modules, [:canvas_context_id, :canvas_context_type], name: "index_context_modules_on_context"
|
19
19
|
end
|
20
20
|
end
|
@@ -3,20 +3,19 @@
|
|
3
3
|
class CreateCourses < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :courses do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.string :sis_id
|
8
|
-
t.string :
|
9
|
-
t.string :
|
10
|
-
t.string :
|
8
|
+
t.string :course_code
|
9
|
+
t.string :name
|
10
|
+
t.string :workflow_state
|
11
11
|
t.integer :canvas_account_id
|
12
12
|
t.integer :canvas_term_id
|
13
|
-
t.
|
14
|
-
t.datetime :
|
15
|
-
t.datetime :end_date
|
13
|
+
t.datetime :start_at
|
14
|
+
t.datetime :end_at
|
16
15
|
|
17
16
|
t.timestamps
|
18
17
|
end
|
19
18
|
|
20
|
-
add_index :courses, :
|
19
|
+
add_index :courses, :canvas_id, unique: true
|
21
20
|
end
|
22
21
|
end
|
@@ -3,23 +3,21 @@
|
|
3
3
|
class CreateEnrollments < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :enrollments do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.bigint :canvas_course_id
|
8
8
|
t.string :course_sis_id
|
9
9
|
t.bigint :canvas_user_id
|
10
10
|
t.string :user_sis_id
|
11
11
|
t.string :role
|
12
|
-
t.integer :
|
12
|
+
t.integer :canvas_role_id
|
13
13
|
t.bigint :canvas_section_id
|
14
|
-
t.string :
|
15
|
-
t.string :status
|
14
|
+
t.string :workflow_state
|
16
15
|
t.string :base_role_type
|
17
16
|
|
18
|
-
|
19
17
|
t.timestamps
|
20
18
|
end
|
21
19
|
|
22
|
-
add_index :enrollments, :
|
20
|
+
add_index :enrollments, :canvas_id, unique: true
|
23
21
|
add_index :enrollments, :canvas_course_id
|
24
22
|
add_index :enrollments, :canvas_user_id
|
25
23
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateRoles < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :roles do |t|
|
6
|
-
t.integer :
|
6
|
+
t.integer :canvas_id, null: false
|
7
7
|
t.string :label, null: false
|
8
8
|
t.string :base_role_type, null: false
|
9
9
|
t.json :account
|
@@ -12,6 +12,6 @@ class CreateRoles < ActiveRecord::Migration[5.1]
|
|
12
12
|
|
13
13
|
t.timestamps
|
14
14
|
end
|
15
|
-
add_index :roles, :
|
15
|
+
add_index :roles, :canvas_id, unique: true
|
16
16
|
end
|
17
17
|
end
|
@@ -3,19 +3,19 @@
|
|
3
3
|
class CreateSections < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :sections do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.string :sis_id
|
8
8
|
t.bigint :canvas_course_id
|
9
9
|
t.bigint :canvas_nonxlist_course_id
|
10
10
|
t.string :name
|
11
|
-
t.string :
|
12
|
-
t.datetime :
|
13
|
-
t.datetime :
|
11
|
+
t.string :workflow_state
|
12
|
+
t.datetime :start_at
|
13
|
+
t.datetime :end_at
|
14
14
|
|
15
15
|
t.timestamps
|
16
16
|
end
|
17
17
|
|
18
|
-
add_index :sections, :
|
18
|
+
add_index :sections, :canvas_id, unique: true
|
19
19
|
add_index :sections, :canvas_course_id
|
20
20
|
end
|
21
21
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateSubmissions < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :submissions do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.bigint :canvas_course_id
|
8
8
|
t.bigint :canvas_assignment_id
|
9
9
|
t.bigint :canvas_user_id
|
@@ -17,7 +17,7 @@ class CreateSubmissions < ActiveRecord::Migration[5.1]
|
|
17
17
|
t.timestamps
|
18
18
|
end
|
19
19
|
|
20
|
-
add_index :submissions, :
|
20
|
+
add_index :submissions, :canvas_id, unique: true
|
21
21
|
add_index :submissions, :canvas_assignment_id
|
22
22
|
add_index :submissions, :canvas_course_id
|
23
23
|
add_index :submissions, :canvas_user_id
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class CreateTerms < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :terms do |t|
|
6
|
-
t.integer :
|
6
|
+
t.integer :canvas_id, null: false
|
7
7
|
t.string :name
|
8
8
|
t.datetime :start_at
|
9
9
|
t.datetime :end_at
|
@@ -13,6 +13,6 @@ class CreateTerms < ActiveRecord::Migration[5.1]
|
|
13
13
|
|
14
14
|
t.timestamps
|
15
15
|
end
|
16
|
-
add_index :terms, :
|
16
|
+
add_index :terms, :canvas_id, unique: true
|
17
17
|
end
|
18
18
|
end
|
@@ -3,19 +3,19 @@
|
|
3
3
|
class CreateUsers < ActiveRecord::Migration[5.1]
|
4
4
|
def change
|
5
5
|
create_table :users do |t|
|
6
|
-
t.bigint :
|
6
|
+
t.bigint :canvas_id, null: false
|
7
7
|
t.string :sis_id
|
8
8
|
t.string :email
|
9
9
|
t.string :first_name
|
10
10
|
t.string :last_name
|
11
|
-
t.string :
|
11
|
+
t.string :workflow_state
|
12
12
|
t.string :login_id
|
13
|
-
t.string :
|
13
|
+
t.string :name
|
14
14
|
t.string :sortable_name
|
15
15
|
|
16
16
|
t.timestamps
|
17
17
|
end
|
18
18
|
|
19
|
-
add_index :users, :
|
19
|
+
add_index :users, :canvas_id, unique: true
|
20
20
|
end
|
21
21
|
end
|
@@ -3,11 +3,11 @@
|
|
3
3
|
class Account < ApplicationRecord
|
4
4
|
include CanvasSync::ApiSyncable
|
5
5
|
|
6
|
-
validates :
|
6
|
+
validates :canvas_id, uniqueness: true, presence: true
|
7
7
|
|
8
8
|
api_syncable({
|
9
9
|
name: :name,
|
10
|
-
|
11
|
-
|
12
|
-
}, -> (api) { api.account(
|
10
|
+
workflow_state: :workflow_state,
|
11
|
+
canvas_parent_account_id: :parent_account_id,
|
12
|
+
}, -> (api) { api.account(canvas_id) })
|
13
13
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<%= autogenerated_model_warning %>
|
2
2
|
|
3
3
|
class Admin < ApplicationRecord
|
4
|
-
validates :
|
5
|
-
belongs_to :user, primary_key: :
|
6
|
-
belongs_to :role, primary_key: :
|
4
|
+
validates :canvas_id, uniqueness: true, presence: true
|
5
|
+
belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
|
6
|
+
belongs_to :role, primary_key: :canvas_id, foreign_key: :canvas_role_id, optional: true
|
7
7
|
|
8
8
|
def self.create_or_update(admin_params)
|
9
|
-
admin = Admin.find_or_initialize_by(
|
9
|
+
admin = Admin.find_or_initialize_by(canvas_id: admin_params['id'])
|
10
10
|
|
11
11
|
admin.assign_attributes(role_name: admin_params['role'],
|
12
12
|
canvas_role_id: admin_params['role_id'],
|
@@ -3,11 +3,12 @@
|
|
3
3
|
class Assignment < ApplicationRecord
|
4
4
|
include CanvasSync::ApiSyncable
|
5
5
|
|
6
|
-
validates :
|
7
|
-
belongs_to :context, polymorphic: true, optional: true, primary_key: :
|
8
|
-
belongs_to :assignment_group, optional: true, primary_key: :
|
9
|
-
has_many :submissions, primary_key: :
|
10
|
-
|
6
|
+
validates :canvas_id, uniqueness: true, presence: true
|
7
|
+
belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
|
8
|
+
belongs_to :assignment_group, optional: true, primary_key: :canvas_id, foreign_key: :canvas_assignment_group_id
|
9
|
+
has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_assignment_id
|
10
|
+
|
11
|
+
has_many :context_module_items, as: :content, primary_key: :canvas_id, foreign_key: :canvas_content_id, foreign_type: :canvas_content_type, dependent: :destroy
|
11
12
|
has_many :context_modules, through: :context_module_items
|
12
13
|
|
13
14
|
api_syncable({
|
@@ -19,9 +20,9 @@ class Assignment < ApplicationRecord
|
|
19
20
|
points_possible: :points_possible,
|
20
21
|
grading_type: :grading_type,
|
21
22
|
submission_types: lambda { |p| p["submission_types"].join(",") },
|
22
|
-
|
23
|
-
|
23
|
+
canvas_context_id: :course_id,
|
24
|
+
canvas_context_type: lambda { |_p| "Course" },
|
24
25
|
canvas_assignment_group_id: :assignment_group_id,
|
25
|
-
|
26
|
-
}, -> (api) { api.assignment(
|
26
|
+
canvas_grading_standard_id: :grading_standard_id,
|
27
|
+
}, -> (api) { api.assignment(canvas_context_id, canvas_id) })
|
27
28
|
end
|
@@ -3,17 +3,17 @@
|
|
3
3
|
class AssignmentGroup < ApplicationRecord
|
4
4
|
include CanvasSync::ApiSyncable
|
5
5
|
|
6
|
-
validates :
|
7
|
-
belongs_to :course, primary_key: :
|
8
|
-
has_many :assignments, primary_key: :
|
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 :assignments, primary_key: :canvas_id, foreign_key: :canvas_assignment_group_id
|
9
9
|
|
10
10
|
serialize :rules
|
11
11
|
|
12
12
|
api_syncable({
|
13
|
-
|
13
|
+
canvas_id: :id,
|
14
14
|
name: :name,
|
15
15
|
position: :position,
|
16
16
|
rules: :rules,
|
17
17
|
group_weight: :group_weight,
|
18
|
-
}, -> (api) { api.assignment(course_id,
|
18
|
+
}, -> (api) { api.assignment(course_id, canvas_id) })
|
19
19
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# 1 - Module is a reserved word in Rails and you can't call a model a Module
|
5
5
|
# 2 - Canvas calls them ContextModules
|
6
6
|
class ContextModule < ApplicationRecord
|
7
|
-
belongs_to :
|
8
|
-
has_many :context_module_items, primary_key: :
|
7
|
+
belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
|
8
|
+
has_many :context_module_items, primary_key: :canvas_id, foreign_key: :canvas_context_module_id
|
9
9
|
has_many :assignments, through: :context_module_items
|
10
10
|
end
|