canvas_sync 0.17.33 → 0.17.34
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.
- checksums.yaml +4 -4
- data/lib/canvas_sync/generators/templates/migrations/create_learning_outcomes.rb +30 -0
- data/lib/canvas_sync/generators/templates/models/learning_outcome.rb +22 -0
- data/lib/canvas_sync/processors/model_mappings.yml +55 -0
- data/lib/canvas_sync/processors/provisioning_report_processor.rb +7 -0
- data/lib/canvas_sync/processors/report_processor.rb +3 -2
- data/lib/canvas_sync/version.rb +1 -1
- data/lib/canvas_sync.rb +1 -0
- data/spec/canvas_sync/processors/provisioning_report_processor_spec.rb +6 -0
- data/spec/dummy/app/models/learning_outcome.rb +28 -0
- data/spec/dummy/db/migrate/20220712210559_create_learning_outcomes.rb +36 -0
- data/spec/dummy/db/schema.rb +25 -1
- data/spec/dummy/log/development.log +148 -2028
- data/spec/dummy/log/test.log +4654 -101591
- data/spec/support/fixtures/reports/learning_outcomes.csv +3 -0
- metadata +14 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8029fc55239810f8064f8d1c9fb4cd1f1756a7605581e7aced13e150e69c8b6b
|
|
4
|
+
data.tar.gz: 2deac9eb222ed8c636159c8100e8aa6cd59d2fa26d3b13b83c7be31cf7cbc0bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1d70b6a2493a49a9eeb48532e9438d02209d3de9609afa0a9bd09a5fe4c9816dcd9b3d7724ffa2385cd65f19b873901cce5fe5b733fa534e4c96ce785146f91
|
|
7
|
+
data.tar.gz: c985b3da6ca96c4120b852f0b4df938a6393a797dd8365ce3c9e61404b67623484930b9001e13172309399e745774bd63208097954d569e094f86c4a56e94e38
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# <%= autogenerated_migration_warning %>
|
|
2
|
+
|
|
3
|
+
class CreateLearningOutcomes < ActiveRecord::Migration[5.1]
|
|
4
|
+
def change
|
|
5
|
+
create_table :learning_outcomes do |t|
|
|
6
|
+
t.bigint :canvas_id, null: false
|
|
7
|
+
t.integer :canvas_context_id
|
|
8
|
+
t.string :canvas_context_type
|
|
9
|
+
t.string :name
|
|
10
|
+
t.string :friendly_name
|
|
11
|
+
t.string :workflow_state
|
|
12
|
+
t.datetime :canvas_created_at
|
|
13
|
+
t.datetime :canvas_updated_at
|
|
14
|
+
t.string :migration_id
|
|
15
|
+
t.string :vendor_guid
|
|
16
|
+
t.string :low_grade
|
|
17
|
+
t.string :high_grade
|
|
18
|
+
t.string :calculation_method
|
|
19
|
+
t.string :calculation_int
|
|
20
|
+
t.integer :outcome_import_id
|
|
21
|
+
t.integer :root_account_ids, array: true, default: []
|
|
22
|
+
t.text :description
|
|
23
|
+
|
|
24
|
+
t.timestamps
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
add_index :learning_outcomes, :canvas_id, unique: true
|
|
28
|
+
add_index :learning_outcomes, [:canvas_context_id, :canvas_context_type], name: "index_learning_outcomes_on_context"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# # <%= autogenerated_migration_warning %>
|
|
4
|
+
|
|
5
|
+
class LearningOutcome < ApplicationRecord
|
|
6
|
+
include CanvasSync::Record
|
|
7
|
+
include CanvasSync::Concerns::ApiSyncable
|
|
8
|
+
|
|
9
|
+
belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
|
|
10
|
+
|
|
11
|
+
api_syncable({
|
|
12
|
+
canvas_id: :id,
|
|
13
|
+
canvas_context_id: :context_id,
|
|
14
|
+
canvas_context_type: :context_type,
|
|
15
|
+
name: :title,
|
|
16
|
+
friendly_name: :display_name,
|
|
17
|
+
vendor_guid: :vendor_guid,
|
|
18
|
+
calculation_method: :calculation_method,
|
|
19
|
+
calculation_int: :calculation_int,
|
|
20
|
+
description: :description
|
|
21
|
+
}, ->(api) { api.get("/api/v1/outcomes/#{canvas_id}") })
|
|
22
|
+
end
|
|
@@ -509,3 +509,58 @@ content_migrations:
|
|
|
509
509
|
canvas_root_account_id:
|
|
510
510
|
database_column_name: canvas_root_account_id
|
|
511
511
|
type: integer
|
|
512
|
+
|
|
513
|
+
learning_outcomes:
|
|
514
|
+
conflict_target: learning_outcome_id
|
|
515
|
+
report_columns:
|
|
516
|
+
learning_outcome_id:
|
|
517
|
+
database_column_name: canvas_id
|
|
518
|
+
type: integer
|
|
519
|
+
context_id:
|
|
520
|
+
database_column_name: canvas_context_id
|
|
521
|
+
type: integer
|
|
522
|
+
context_type:
|
|
523
|
+
database_column_name: canvas_context_type
|
|
524
|
+
type: string
|
|
525
|
+
name:
|
|
526
|
+
database_column_name: name
|
|
527
|
+
type: string
|
|
528
|
+
friendly_name:
|
|
529
|
+
database_column_name: friendly_name
|
|
530
|
+
type: string
|
|
531
|
+
workflow_state:
|
|
532
|
+
database_column_name: workflow_state
|
|
533
|
+
type: string
|
|
534
|
+
created_at:
|
|
535
|
+
database_column_name: canvas_created_at
|
|
536
|
+
type: datetime
|
|
537
|
+
updated_at:
|
|
538
|
+
database_column_name: canvas_updated_at
|
|
539
|
+
type: datetime
|
|
540
|
+
migration_id:
|
|
541
|
+
database_column_name: migration_id
|
|
542
|
+
type: string
|
|
543
|
+
vendor_guid:
|
|
544
|
+
database_column_name: vendor_guid
|
|
545
|
+
type: string
|
|
546
|
+
low_grade:
|
|
547
|
+
database_column_name: low_grade
|
|
548
|
+
type: string
|
|
549
|
+
high_grade:
|
|
550
|
+
database_column_name: high_grade
|
|
551
|
+
type: string
|
|
552
|
+
calculation_method:
|
|
553
|
+
database_column_name: calculation_method
|
|
554
|
+
type: string
|
|
555
|
+
calculation_int:
|
|
556
|
+
database_column_name: calculation_int
|
|
557
|
+
type: integer
|
|
558
|
+
outcome_import_id:
|
|
559
|
+
database_column_name: outcome_import_id
|
|
560
|
+
type: integer
|
|
561
|
+
root_account_ids:
|
|
562
|
+
database_column_name: root_account_ids
|
|
563
|
+
type: integer
|
|
564
|
+
description:
|
|
565
|
+
database_column_name: description
|
|
566
|
+
type: string
|
|
@@ -116,6 +116,13 @@ module CanvasSync
|
|
|
116
116
|
def bulk_process_group_membership(report_file_path)
|
|
117
117
|
do_bulk_import(report_file_path, GroupMembership, options: @options)
|
|
118
118
|
end
|
|
119
|
+
|
|
120
|
+
def bulk_process_learning_outcomes(report_file_path)
|
|
121
|
+
do_bulk_import(report_file_path, LearningOutcome, options: @options) do |row|
|
|
122
|
+
row[:root_account_ids] = JSON.parse row[:root_account_ids]
|
|
123
|
+
row
|
|
124
|
+
end
|
|
125
|
+
end
|
|
119
126
|
end
|
|
120
127
|
end
|
|
121
128
|
end
|
|
@@ -12,14 +12,15 @@ module CanvasSync
|
|
|
12
12
|
model.try(:get_sync_mapping, key) || mapping[key || CanvasSync::Concerns::SyncMapping::Mapping.normalize_model_name(model)]
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def do_bulk_import(report_file_path, model, options: {}, mapping_key: nil)
|
|
15
|
+
def do_bulk_import(report_file_path, model, options: {}, mapping_key: nil, &blk)
|
|
16
16
|
m = mapping_for(model, mapping_key)
|
|
17
17
|
CanvasSync::Importers::BulkImporter.import(
|
|
18
18
|
report_file_path,
|
|
19
19
|
m[:report_columns],
|
|
20
20
|
model,
|
|
21
21
|
m[:conflict_target],
|
|
22
|
-
import_args: options
|
|
22
|
+
import_args: options,
|
|
23
|
+
&blk
|
|
23
24
|
)
|
|
24
25
|
end
|
|
25
26
|
end
|
data/lib/canvas_sync/version.rb
CHANGED
data/lib/canvas_sync.rb
CHANGED
|
@@ -104,6 +104,12 @@ RSpec.describe CanvasSync::Processors::ProvisioningReportProcessor do
|
|
|
104
104
|
expect(obj.workflow_state).to eq 'active'
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
it 'processes learning_outcomes' do
|
|
108
|
+
expect {
|
|
109
|
+
subject.process('spec/support/fixtures/reports/learning_outcomes.csv', { models: ['learning_outcomes'] }, 1)
|
|
110
|
+
}.to change { LearningOutcome.count }.by(2)
|
|
111
|
+
end
|
|
112
|
+
|
|
107
113
|
it 'model with composite key behaves as expected' do
|
|
108
114
|
expect {
|
|
109
115
|
subject.process('spec/support/fixtures/reports/user_observers.csv', { models: ['user_observers'] }, 1)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# # #
|
|
4
|
+
# AUTO GENERATED MIGRATION
|
|
5
|
+
# This migration was auto generated by the CanvasSync Gem.
|
|
6
|
+
# You can add new columns to this table, but removing or
|
|
7
|
+
# re-naming ones created here may break Canvas Syncing.
|
|
8
|
+
#
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LearningOutcome < ApplicationRecord
|
|
12
|
+
include CanvasSync::Record
|
|
13
|
+
include CanvasSync::Concerns::ApiSyncable
|
|
14
|
+
|
|
15
|
+
belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
|
|
16
|
+
|
|
17
|
+
api_syncable({
|
|
18
|
+
canvas_id: :id,
|
|
19
|
+
canvas_context_id: :context_id,
|
|
20
|
+
canvas_context_type: :context_type,
|
|
21
|
+
name: :title,
|
|
22
|
+
friendly_name: :display_name,
|
|
23
|
+
vendor_guid: :vendor_guid,
|
|
24
|
+
calculation_method: :calculation_method,
|
|
25
|
+
calculation_int: :calculation_int,
|
|
26
|
+
description: :description
|
|
27
|
+
}, ->(api) { api.get("/api/v1/outcomes/#{canvas_id}") })
|
|
28
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
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 CreateLearningOutcomes < ActiveRecord::Migration[5.1]
|
|
10
|
+
def change
|
|
11
|
+
create_table :learning_outcomes do |t|
|
|
12
|
+
t.bigint :canvas_id, null: false
|
|
13
|
+
t.integer :canvas_context_id
|
|
14
|
+
t.string :canvas_context_type
|
|
15
|
+
t.string :name
|
|
16
|
+
t.string :friendly_name
|
|
17
|
+
t.string :workflow_state
|
|
18
|
+
t.datetime :canvas_created_at
|
|
19
|
+
t.datetime :canvas_updated_at
|
|
20
|
+
t.string :migration_id
|
|
21
|
+
t.string :vendor_guid
|
|
22
|
+
t.string :low_grade
|
|
23
|
+
t.string :high_grade
|
|
24
|
+
t.string :calculation_method
|
|
25
|
+
t.string :calculation_int
|
|
26
|
+
t.integer :outcome_import_id
|
|
27
|
+
t.integer :root_account_ids, array: true, default: []
|
|
28
|
+
t.text :description
|
|
29
|
+
|
|
30
|
+
t.timestamps
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
add_index :learning_outcomes, :canvas_id, unique: true
|
|
34
|
+
add_index :learning_outcomes, [:canvas_context_id, :canvas_context_type], name: "index_learning_outcomes_on_context"
|
|
35
|
+
end
|
|
36
|
+
end
|
data/spec/dummy/db/schema.rb
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
|
13
|
+
ActiveRecord::Schema.define(version: 2022_07_12_210559) do
|
|
14
14
|
|
|
15
15
|
# These are extensions that must be enabled in order to support this database
|
|
16
16
|
enable_extension "plpgsql"
|
|
@@ -246,6 +246,30 @@ ActiveRecord::Schema.define(version: 2022_03_08_072643) do
|
|
|
246
246
|
t.index ["canvas_id"], name: "index_groups_on_canvas_id", unique: true
|
|
247
247
|
end
|
|
248
248
|
|
|
249
|
+
create_table "learning_outcomes", force: :cascade do |t|
|
|
250
|
+
t.bigint "canvas_id", null: false
|
|
251
|
+
t.integer "canvas_context_id"
|
|
252
|
+
t.string "canvas_context_type"
|
|
253
|
+
t.string "name"
|
|
254
|
+
t.string "friendly_name"
|
|
255
|
+
t.string "workflow_state"
|
|
256
|
+
t.datetime "canvas_created_at"
|
|
257
|
+
t.datetime "canvas_updated_at"
|
|
258
|
+
t.string "migration_id"
|
|
259
|
+
t.string "vendor_guid"
|
|
260
|
+
t.string "low_grade"
|
|
261
|
+
t.string "high_grade"
|
|
262
|
+
t.string "calculation_method"
|
|
263
|
+
t.string "calculation_int"
|
|
264
|
+
t.integer "outcome_import_id"
|
|
265
|
+
t.integer "root_account_ids", default: [], array: true
|
|
266
|
+
t.text "description"
|
|
267
|
+
t.datetime "created_at", null: false
|
|
268
|
+
t.datetime "updated_at", null: false
|
|
269
|
+
t.index ["canvas_context_id", "canvas_context_type"], name: "index_learning_outcomes_on_context"
|
|
270
|
+
t.index ["canvas_id"], name: "index_learning_outcomes_on_canvas_id", unique: true
|
|
271
|
+
end
|
|
272
|
+
|
|
249
273
|
create_table "pseudonyms", force: :cascade do |t|
|
|
250
274
|
t.bigint "canvas_id", null: false
|
|
251
275
|
t.bigint "canvas_user_id"
|