canvas_sync 0.23.1 → 0.23.3
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_courses.rb +2 -0
- data/lib/canvas_sync/generators/templates/models/course.rb +3 -0
- data/lib/canvas_sync/processors/model_mappings.yml +3 -0
- data/lib/canvas_sync/processors/provisioning_report_processor.rb +12 -6
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/dummy/app/models/course.rb +4 -0
- data/spec/dummy/db/migrate/20190702203621_create_courses.rb +2 -0
- data/spec/dummy/db/schema.rb +4 -3
- data/spec/support/fixtures/reports/courses.csv +3 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87dcb3a29883abf28f3be7ef70a6aaa6b8b303c7115d5a52e8a7ae9785c1ba3d
|
4
|
+
data.tar.gz: ac6c904f3ce0af3e8cdcd32dea735b69dbb856a21c6a2122a0cf9a4d6fe910cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 398b3bf5a5da8cc4709c49a69587000a48d56cf86e9b46b5ada2768dab58f2b8dc14125c70885074dc4311c4b0aa818105283b6c0d3edc820e5c1e092b1e38d7
|
7
|
+
data.tar.gz: b89d3d9d41fd62f9c017742ee7b08c5b50ca0e379dfa3bd48e9e78598dfd7b113917666211c146efa9b471b2a9827d4acb6e8620c0da4806d9c99dd0a51f314c
|
@@ -34,7 +34,10 @@ class Course < ApplicationRecord
|
|
34
34
|
canvas_account_id: :account_id,
|
35
35
|
start_at: :start_at,
|
36
36
|
end_at: :end_at,
|
37
|
+
# If opting in the public_description, make sure to also add the 'include' array in the api call
|
38
|
+
# public_description: :public_description,
|
37
39
|
}, -> (api) { api.course(canvas_id) })
|
40
|
+
# }, -> (api) { api.course(canvas_id, { include: ['public_description'] }) })
|
38
41
|
|
39
42
|
scope :active, -> { where(workflow_state: 'active') }
|
40
43
|
|
@@ -24,8 +24,8 @@ module CanvasSync
|
|
24
24
|
if options[:models].length == 1
|
25
25
|
run_import(options[:models][0], report_file_path)
|
26
26
|
else
|
27
|
-
|
28
|
-
Dir[
|
27
|
+
unzipped_file_dir = extract(report_file_path)
|
28
|
+
Dir[unzipped_file_dir + "/*.csv"].sort.each do |file_path|
|
29
29
|
model_name = file_path.split("/").last.split(".").first
|
30
30
|
run_import(model_name, file_path)
|
31
31
|
end
|
@@ -35,17 +35,23 @@ module CanvasSync
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def extract(file_path)
|
38
|
-
|
38
|
+
unzipped_file_dir = "#{file_path}_unzipped"
|
39
39
|
|
40
40
|
Zip::File.open(file_path) do |zip_file|
|
41
41
|
zip_file.each do |f|
|
42
|
-
f_path = File.join(
|
42
|
+
f_path = File.join(unzipped_file_dir, f.name)
|
43
43
|
FileUtils.mkdir_p(File.dirname(f_path))
|
44
|
-
|
44
|
+
next if File.exist?(f_path)
|
45
|
+
|
46
|
+
if Zip::VERSION < "3.0.0"
|
47
|
+
zip_file.extract(f, destination_directory: unzipped_file_dir)
|
48
|
+
else
|
49
|
+
zip_file.extract(f, f_path)
|
50
|
+
end
|
45
51
|
end
|
46
52
|
end
|
47
53
|
|
48
|
-
|
54
|
+
unzipped_file_dir
|
49
55
|
end
|
50
56
|
|
51
57
|
def run_import(model_name, report_file_path)
|
data/lib/canvas_sync/version.rb
CHANGED
@@ -40,7 +40,11 @@ class Course < ApplicationRecord
|
|
40
40
|
canvas_account_id: :account_id,
|
41
41
|
start_at: :start_at,
|
42
42
|
end_at: :end_at,
|
43
|
+
# If opting in the public_description, make sure to also add the 'include' array in the api call
|
44
|
+
# public_description: :public_description,
|
43
45
|
}, -> (api) { api.course(canvas_id) })
|
46
|
+
# }, -> (api) { api.course(canvas_id, { include: ['public_description'] }) })
|
47
|
+
|
44
48
|
|
45
49
|
scope :active, -> { where(workflow_state: 'active') }
|
46
50
|
|
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[7.1].define(version:
|
13
|
+
ActiveRecord::Schema[7.1].define(version: 2025_07_30_124426) do
|
14
14
|
# These are extensions that must be enabled in order to support this database
|
15
15
|
enable_extension "plpgsql"
|
16
16
|
|
@@ -214,6 +214,7 @@ ActiveRecord::Schema[7.1].define(version: 2025_06_26_194330) do
|
|
214
214
|
t.datetime "start_at", precision: nil
|
215
215
|
t.datetime "end_at", precision: nil
|
216
216
|
t.bigint "grading_standard_id"
|
217
|
+
t.string "public_description"
|
217
218
|
t.datetime "created_at", precision: nil, null: false
|
218
219
|
t.datetime "updated_at", precision: nil, null: false
|
219
220
|
t.index ["canvas_id"], name: "index_courses_on_canvas_id", unique: true
|
@@ -363,10 +364,10 @@ ActiveRecord::Schema[7.1].define(version: 2025_06_26_194330) do
|
|
363
364
|
end
|
364
365
|
|
365
366
|
create_table "roles", force: :cascade do |t|
|
366
|
-
t.
|
367
|
+
t.bigint "canvas_id", null: false
|
367
368
|
t.string "label"
|
368
369
|
t.string "base_role_type"
|
369
|
-
t.
|
370
|
+
t.bigint "canvas_account_id"
|
370
371
|
t.string "workflow_state"
|
371
372
|
t.json "permissions"
|
372
373
|
t.datetime "created_at", precision: nil, null: false
|
@@ -1,3 +1,3 @@
|
|
1
|
-
canvas_course_id,course_id,integration_id,short_name,long_name,canvas_account_id,account_id,canvas_term_id,term_id,status,start_date,end_date,course_format,created_by_sis
|
2
|
-
1,course_sis_id_1,,C1,Course #1,1,,1,term_sis_id_1,active,2017-03-27T15:53:18-06:00,2017-04-27T06:21:18-06:00,,FALSE
|
3
|
-
2,course_sis_id_2,,C2,Course #2,1,,1,term_sis_id_2,unpublished,2017-03-27T15:53:18-06:00,2017-04-27T06:21:18-06:00,,FALSE,5
|
1
|
+
canvas_course_id,course_id,integration_id,short_name,long_name,canvas_account_id,account_id,canvas_term_id,term_id,status,start_date,end_date,course_format,created_by_sis,public_description
|
2
|
+
1,course_sis_id_1,,C1,Course #1,1,,1,term_sis_id_1,active,2017-03-27T15:53:18-06:00,2017-04-27T06:21:18-06:00,,FALSE,"Description 1"
|
3
|
+
2,course_sis_id_2,,C2,Course #2,1,,1,term_sis_id_2,unpublished,2017-03-27T15:53:18-06:00,2017-04-27T06:21:18-06:00,,FALSE,5,"Description 2"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.23.
|
4
|
+
version: 0.23.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure CustomDev
|
@@ -289,6 +289,20 @@ dependencies:
|
|
289
289
|
- - ">="
|
290
290
|
- !ruby/object:Gem::Version
|
291
291
|
version: '0'
|
292
|
+
- !ruby/object:Gem::Dependency
|
293
|
+
name: csv
|
294
|
+
requirement: !ruby/object:Gem::Requirement
|
295
|
+
requirements:
|
296
|
+
- - ">="
|
297
|
+
- !ruby/object:Gem::Version
|
298
|
+
version: '0'
|
299
|
+
type: :runtime
|
300
|
+
prerelease: false
|
301
|
+
version_requirements: !ruby/object:Gem::Requirement
|
302
|
+
requirements:
|
303
|
+
- - ">="
|
304
|
+
- !ruby/object:Gem::Version
|
305
|
+
version: '0'
|
292
306
|
- !ruby/object:Gem::Dependency
|
293
307
|
name: open-uri
|
294
308
|
requirement: !ruby/object:Gem::Requirement
|
@@ -884,7 +898,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
884
898
|
- !ruby/object:Gem::Version
|
885
899
|
version: '0'
|
886
900
|
requirements: []
|
887
|
-
rubygems_version: 3.6.
|
901
|
+
rubygems_version: 3.6.9
|
888
902
|
specification_version: 4
|
889
903
|
summary: Gem for generating Canvas models and migrations and syncing data from Canvas
|
890
904
|
test_files:
|