canvas_sync 0.19.2.beta1 → 0.19.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/lib/canvas_sync/concerns/auto_relations.rb +11 -0
  3. data/lib/canvas_sync/generators/templates/migrations/create_rubric_assessments.rb +31 -0
  4. data/lib/canvas_sync/generators/templates/migrations/create_rubric_associations.rb +36 -0
  5. data/lib/canvas_sync/generators/templates/migrations/create_rubrics.rb +38 -0
  6. data/lib/canvas_sync/generators/templates/models/course.rb +1 -0
  7. data/lib/canvas_sync/generators/templates/models/rubric.rb +29 -0
  8. data/lib/canvas_sync/generators/templates/models/rubric_assessment.rb +18 -0
  9. data/lib/canvas_sync/generators/templates/models/rubric_association.rb +14 -0
  10. data/lib/canvas_sync/generators/templates/models/user.rb +1 -0
  11. data/lib/canvas_sync/jobs/sync_rubric_assessments_job.rb +15 -0
  12. data/lib/canvas_sync/jobs/sync_rubric_associations_job.rb +15 -0
  13. data/lib/canvas_sync/jobs/sync_rubrics_job.rb +15 -0
  14. data/lib/canvas_sync/processors/model_mappings.yml +168 -0
  15. data/lib/canvas_sync/processors/rubric_assessments_processor.rb +19 -0
  16. data/lib/canvas_sync/processors/rubric_associations_processor.rb +19 -0
  17. data/lib/canvas_sync/processors/rubrics_processor.rb +19 -0
  18. data/lib/canvas_sync/version.rb +1 -1
  19. data/lib/canvas_sync.rb +12 -0
  20. data/spec/canvas_sync/processors/rubric_assessments_spec.rb +16 -0
  21. data/spec/canvas_sync/processors/rubric_associations_spec.rb +16 -0
  22. data/spec/canvas_sync/processors/rubrics_processor_spec.rb +17 -0
  23. data/spec/dummy/app/models/course.rb +1 -0
  24. data/spec/dummy/app/models/rubric.rb +35 -0
  25. data/spec/dummy/app/models/rubric_assessment.rb +23 -0
  26. data/spec/dummy/app/models/rubric_association.rb +20 -0
  27. data/spec/dummy/db/migrate/20240509105100_create_rubrics.rb +44 -0
  28. data/spec/dummy/db/migrate/20240510094100_create_rubric_associations.rb +42 -0
  29. data/spec/dummy/db/migrate/20240510101100_create_rubric_assessments.rb +37 -0
  30. data/spec/dummy/db/schema.rb +88 -1
  31. data/spec/support/fixtures/reports/rubric_assessments.csv +3 -0
  32. data/spec/support/fixtures/reports/rubric_associations.csv +3 -0
  33. data/spec/support/fixtures/reports/rubrics.csv +3 -0
  34. metadata +200 -163
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecc3c5f4ca20c48e26dec4efb6e884ba190993e803397e787f1b4bd1aeaa396e
4
- data.tar.gz: 96bad6ba987e9d3635f842b6054120b198b0ea13684fef11eb1877e984e2582c
3
+ metadata.gz: aa1d11461d8b642bee1f00367b583b19fee48fcc79e8d51e5c29c638cc5cb5f7
4
+ data.tar.gz: 03e3f794fcab4a3560a61fab8f79f619a7e208d964cfdb7491774ccbf29360c4
5
5
  SHA512:
6
- metadata.gz: fd47f7ab12b496b5c3c39ecce7ec5524659d1687ebb214b02def7d730910aee73dd6cdc0b3fefd9a30c9f9c929b079900abadd09312b508b2f88a58c911cac1b
7
- data.tar.gz: d42419cb02d7419552df33de654e1ec1d5736cf403225e802e778866b7d85a52adf3f1935d3c93e790610cd219d5aa3cc7c96bb1d5bdd2bb3ef7b2bbe1afd611
6
+ metadata.gz: dbd5e3d4afe766b806f9a26cc362af3f7bbc78fec073df299c05c86cfdabebe4096ba8c4a4779db803b5882ac2a6224c8582bdfee058107565cd1397acf68576
7
+ data.tar.gz: 244243d1ce618428fc3a0ac17266de187207643039a13c4f9e2cdaf226f2d4c0a8bbc70fae676cd3621d02e71a3b5a7ff42428d237b3c491a099de4e9e3e33d6
@@ -0,0 +1,11 @@
1
+ module CanvasSync::Concerns
2
+ module AutoRelations
3
+ extend ActiveSupport::Concern
4
+
5
+ # CanvasSync::Record.define_feature self, default: true
6
+
7
+ included do
8
+
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ # <%= autogenerated_migration_warning %>
2
+
3
+ class CreateRubricAssessments < ActiveRecord::Migration[5.1]
4
+ def change
5
+ create_table :rubric_assessments do |t|
6
+ t.bigint :canvas_id
7
+ t.bigint :canvas_user_id
8
+ t.bigint :canvas_rubric_id
9
+ t.bigint :canvas_rubric_association_id
10
+ t.float :score
11
+ t.text :data
12
+ t.bigint :canvas_artifact_id
13
+ t.string :canvas_artifact_type
14
+ t.string :assessment_type
15
+ t.bigint :canvas_assessor_id
16
+ t.integer :artifact_attempt
17
+ t.boolean :hide_points
18
+ t.bigint :canvas_root_account_id
19
+
20
+ t.timestamps
21
+ end
22
+
23
+ add_index :rubric_assessments, [:canvas_id], name: :index_rubric_assessments_on_canvas_id, unique: true
24
+ add_index :rubric_assessments, [:canvas_artifact_id, :canvas_artifact_type], name: :index_rubric_assessments_on_canvas_aid_and_canvas_atype
25
+ add_index :rubric_assessments, [:canvas_assessor_id], name: :index_rubric_assessments_on_canvas_assessor_id
26
+ add_index :rubric_assessments, [:canvas_rubric_association_id], name: :index_rubric_assessments_on_canvas_rubric_association_id
27
+ add_index :rubric_assessments, [:canvas_rubric_id], name: :index_rubric_assessments_on_canvas_rubric_id
28
+ add_index :rubric_assessments, [:canvas_user_id], name: :index_rubric_assessments_on_canvas_user_id
29
+ add_index :rubric_assessments, [:canvas_root_account_id], name: :index_rubric_assessments_on_canvas_root_account_id
30
+ end
31
+ end
@@ -0,0 +1,36 @@
1
+ # <%= autogenerated_migration_warning %>
2
+
3
+ class CreateRubricAssociations < ActiveRecord::Migration[5.1]
4
+ def change
5
+ create_table :rubric_associations do |t|
6
+ t.bigint :canvas_id, null: false
7
+ t.bigint :canvas_rubric_id
8
+ t.bigint :canvas_association_id
9
+ t.string :canvas_association_type
10
+ t.boolean :use_for_grading
11
+ t.string :title
12
+ t.text :description
13
+ t.text :summary_data
14
+ t.string :purpose
15
+ t.string :url
16
+ t.bigint :canvas_context_id
17
+ t.string :canvas_context_type
18
+ t.boolean :hide_score_total
19
+ t.boolean :bookmarked
20
+ t.string :context_code
21
+ t.boolean :hide_points
22
+ t.boolean :hide_outcome_results
23
+ t.bigint :canvas_root_account_id
24
+ t.string :workflow_state
25
+
26
+ t.timestamps
27
+ end
28
+
29
+ add_index :rubric_associations, [:canvas_id], :name => :index_rubric_associations_on_canvas_id, unique: true
30
+ add_index :rubric_associations, [:canvas_association_id, :canvas_association_type], :name => :index_rubric_associations_on_canvas_aid_and_canvas_atype
31
+ add_index :rubric_associations, [:context_code], :name => :index_rubric_associations_on_context_code
32
+ add_index :rubric_associations, [:canvas_context_id, :canvas_context_type], :name => :index_rubric_associations_on_canvas_cid_and_canvas_ctype
33
+ add_index :rubric_associations, [:canvas_rubric_id], :name => :index_rubric_associations_on_canvas_rubric_id
34
+ add_index :rubric_associations, [:canvas_root_account_id], :name => :index_rubric_associations_on_canvas_root_account_id
35
+ end
36
+ end
@@ -0,0 +1,38 @@
1
+ # <%= autogenerated_model_warning %>
2
+
3
+ class CreateRubrics < ActiveRecord::Migration[5.1]
4
+ def change
5
+ create_table :rubrics do |t|
6
+ t.bigint :canvas_id, null: false
7
+ t.bigint :canvas_user_id
8
+ t.bigint :canvas_rubric_id
9
+ t.bigint :canvas_context_id
10
+ t.string :canvas_context_type
11
+ t.text :data
12
+ t.float :points_possible
13
+ t.string :title
14
+ t.text :description
15
+ t.boolean :reusable
16
+ t.boolean :public
17
+ t.boolean :read_only
18
+ t.integer :association_count
19
+ t.boolean :free_form_criterion_comments
20
+ t.string :context_code
21
+ t.string :migration_id
22
+ t.boolean :hide_score_total
23
+ t.string :workflow_state
24
+ t.bigint :canvas_root_account_id
25
+ t.boolean :hide_points
26
+ t.string :rating_order
27
+ t.string :button_display
28
+
29
+ t.timestamps
30
+ end
31
+
32
+ add_index :rubrics, [:canvas_id], unique: true
33
+ add_index :rubrics, [:canvas_context_id, :canvas_context_type]
34
+ add_index :rubrics, [:canvas_rubric_id]
35
+ add_index :rubrics, [:canvas_user_id]
36
+ add_index :rubrics, [:canvas_root_account_id]
37
+ end
38
+ end
@@ -14,6 +14,7 @@ class Course < ApplicationRecord
14
14
  has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_course_id
15
15
  has_many :assignment_groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
16
16
  has_many :groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
17
+ has_many :rubrics, as: :context, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
17
18
 
18
19
  api_syncable({
19
20
  sis_id: :sis_course_id,
@@ -0,0 +1,29 @@
1
+ # <%= autogenerated_model_warning %>
2
+
3
+ class Rubric < ApplicationRecord
4
+ include CanvasSync::Record
5
+ include CanvasSync::Concerns::ApiSyncable
6
+
7
+ canvas_sync_features :defaults
8
+
9
+ validates :canvas_id, uniqueness: true, presence: true
10
+ belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id
11
+ belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id # based on another rubric
12
+ belongs_to :context, polymorphic: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
13
+
14
+ has_many :rubric_associations, primary_key: :canvas_id, foreign_key: :canvas_association_id, foreign_type: :canvas_association_type
15
+ has_many :rubric_assessments, through: :rubric_associations, dependent: :destroy
16
+
17
+ api_syncable({
18
+ canvas_id: :id,
19
+ title: :title,
20
+ canvas_context_id: :context_id,
21
+ canvas_context_type: :context_type,
22
+ points_possible: :points_possible,
23
+ reusable: :reusable,
24
+ read_only: :read_only,
25
+ free_form_criterion_comments: :free_form_criterion_comments,
26
+ hide_score_total: :hide_score_total,
27
+ data: :data,
28
+ }, -> (api) { api.rubrics("self", canvas_id) })
29
+ end
@@ -0,0 +1,18 @@
1
+ # <%= autogenerated_model_warning %>
2
+
3
+ class RubricAssessment < ApplicationRecord
4
+ include CanvasSync::Record
5
+ include CanvasSync::Concerns::ApiSyncable
6
+
7
+ canvas_sync_features :defaults
8
+
9
+ validates :canvas_id, uniqueness: true, presence: true
10
+
11
+ belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id, optional: true
12
+ belongs_to :rubric_association, primary_key: :canvas_id, foreign_key: :canvas_rubric_association_id, optional: true
13
+ belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
14
+ belongs_to :assessor, class_name: "User", primary_key: :canvas_id, foreign_key: :canvas_assessor_id, optional: true
15
+ belongs_to :artifact, polymorphic: true, primary_key: :canvas_id, foreign_type: :canvas_artifact_type, foreign_key: :canvas_artifact_id, optional: true
16
+
17
+ serialize :data
18
+ end
@@ -0,0 +1,14 @@
1
+ # <%= autogenerated_model_warning %>
2
+
3
+ class RubricAssociation < ApplicationRecord
4
+ include CanvasSync::Record
5
+ include CanvasSync::Concerns::ApiSyncable
6
+
7
+ canvas_sync_features :defaults
8
+
9
+ validates :canvas_id, uniqueness: true, presence: true
10
+ belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id, optional: true
11
+ belongs_to :association_object, polymorphic: true, primary_key: :canvas_id, foreign_type: :canvas_association_type, optional: true
12
+ belongs_to :context, polymorphic: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, optional: true
13
+ has_many :rubric_assessments
14
+ end
@@ -13,6 +13,7 @@ class User < ApplicationRecord
13
13
  has_many :admin_roles, through: :admins, source: :role
14
14
  has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_user_id
15
15
  has_many :group_memberships, primary_key: :canvas_id, foreign_key: :canvas_user_id
16
+ has_many :rubrics, primary_key: :canvas_id, foreign_key: :canvas_user_id
16
17
 
17
18
  api_syncable({
18
19
  sis_id: :sis_user_id,
@@ -0,0 +1,15 @@
1
+ module CanvasSync
2
+ module Jobs
3
+ class SyncRubricAssessmentsJob < ReportStarter
4
+ # @param options [Hash]
5
+ def perform(options)
6
+ super(
7
+ "rubric_assessments_csv",
8
+ merge_report_params(options),
9
+ CanvasSync::Processors::RubricAssessmentsProcessor.to_s,
10
+ {},
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module CanvasSync
2
+ module Jobs
3
+ class SyncRubricAssociationsJob < ReportStarter
4
+ # @param options [Hash]
5
+ def perform(options)
6
+ super(
7
+ "rubric_associations_csv",
8
+ merge_report_params(options),
9
+ CanvasSync::Processors::RubricAssociationsProcessor.to_s,
10
+ {},
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module CanvasSync
2
+ module Jobs
3
+ class SyncRubricsJob < ReportStarter
4
+ # @param options [Hash]
5
+ def perform(options)
6
+ super(
7
+ "rubrics_csv",
8
+ merge_report_params(options),
9
+ CanvasSync::Processors::RubricsProcessor.to_s,
10
+ {},
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -583,3 +583,171 @@ course_nicknames:
583
583
  nickname:
584
584
  database_column_name: nickname
585
585
  type: string
586
+
587
+ rubrics:
588
+ conflict_target: id
589
+ report_columns:
590
+ id:
591
+ database_column_name: canvas_id
592
+ type: integer
593
+ user_id:
594
+ database_column_name: canvas_user_id
595
+ type: integer
596
+ rubric_id:
597
+ database_column_name: canvas_rubric_id
598
+ type: integer
599
+ context_id:
600
+ database_column_name: canvas_context_id
601
+ type: integer
602
+ context_type:
603
+ database_column_name: canvas_context_type
604
+ type: string
605
+ data:
606
+ database_column_name: data
607
+ type: text
608
+ points_possible:
609
+ database_column_name: points_possible
610
+ type: float
611
+ title:
612
+ database_column_name: title
613
+ type: string
614
+ description:
615
+ database_column_name: description
616
+ type: text
617
+ created_at:
618
+ database_column_name: created_at
619
+ type: datetime
620
+ reusable:
621
+ database_column_name: reusable
622
+ type: boolean
623
+ public:
624
+ database_column_name: public
625
+ type: boolean
626
+ read_only:
627
+ database_column_name: read_only
628
+ type: boolean
629
+ association_count:
630
+ database_column_name: association_count
631
+ type: integer
632
+ free_form_criterion_comments:
633
+ database_column_name: free_form_criterion_comments
634
+ type: boolean
635
+ context_code:
636
+ database_column_name: context_code
637
+ type: string
638
+ migration_id:
639
+ database_column_name: migration_id
640
+ type: string
641
+ hide_score_total:
642
+ database_column_name: hide_score_total
643
+ type: boolean
644
+ workflow_state:
645
+ database_column_name: workflow_state
646
+ type: string
647
+ root_account_id:
648
+ database_column_name: canvas_root_account_id
649
+ type: integer
650
+
651
+ rubric_associations:
652
+ conflict_target: id
653
+ report_columns:
654
+ id:
655
+ database_column_name: canvas_id
656
+ type: integer
657
+ rubric_id:
658
+ database_column_name: canvas_rubric_id
659
+ type: integer
660
+ association_id:
661
+ database_column_name: canvas_association_id
662
+ type: integer
663
+ association_type:
664
+ database_column_name: canvas_association_type
665
+ type: string
666
+ use_for_grading:
667
+ database_column_name: use_for_grading
668
+ type: boolean
669
+ created_at:
670
+ database_column_name: created_at
671
+ type: datetime
672
+ title:
673
+ database_column_name: title
674
+ type: string
675
+ summary_data:
676
+ database_column_name: summary_data
677
+ type: text
678
+ purpose:
679
+ database_column_name: purpose
680
+ type: string
681
+ url:
682
+ database_column_name: url
683
+ type: string
684
+ context_id:
685
+ database_column_name: canvas_context_id
686
+ type: integer
687
+ context_type:
688
+ database_column_name: canvas_context_type
689
+ type: string
690
+ hide_score_total:
691
+ database_column_name: hide_score_total
692
+ type: boolean
693
+ bookmarked:
694
+ database_column_name: bookmarked
695
+ type: boolean
696
+ context_code:
697
+ database_column_name: context_code
698
+ type: string
699
+ hide_points:
700
+ database_column_name: hide_points
701
+ type: boolean
702
+ hide_outcome_results:
703
+ database_column_name: hide_outcome_results
704
+ type: boolean
705
+ root_account_id:
706
+ database_column_name: canvas_root_account_id
707
+ type: integer
708
+ workflow_state:
709
+ database_column_name: workflow_state
710
+ type: string
711
+
712
+ rubric_assessments:
713
+ conflict_target: id
714
+ report_columns:
715
+ id:
716
+ database_column_name: canvas_id
717
+ type: integer
718
+ user_id:
719
+ database_column_name: canvas_user_id
720
+ type: integer
721
+ rubric_id:
722
+ database_column_name: canvas_rubric_id
723
+ type: integer
724
+ rubric_association_id:
725
+ database_column_name: canvas_rubric_association_id
726
+ type: integer
727
+ score:
728
+ database_column_name: score
729
+ type: float
730
+ created_at:
731
+ database_column_name: created_at
732
+ type: datetime
733
+ artifact_id:
734
+ database_column_name: canvas_artifact_id
735
+ type: integer
736
+ artifact_type:
737
+ database_column_name: canvas_artifact_type
738
+ type: string
739
+ assessment_type:
740
+ database_column_name: assessment_type
741
+ type: string
742
+ assessor_id:
743
+ database_column_name: canvas_assessor_id
744
+ type: integer
745
+ artifact_attempt:
746
+ database_column_name: artifact_attempt
747
+ type: integer
748
+ hide_points:
749
+ database_column_name: hide_points
750
+ type: boolean
751
+ root_account_id:
752
+ database_column_name: canvas_root_account_id
753
+ type: integer
@@ -0,0 +1,19 @@
1
+ require_relative "./report_processor"
2
+
3
+ module CanvasSync
4
+ module Processors
5
+ # Processes a rubric assessments report using the bulk importer.
6
+ #
7
+ # @param report_file_path [String]
8
+ # @param options [Hash]
9
+ class RubricAssessmentsProcessor < ReportProcessor
10
+ def self.process(report_file_path, _options, report_id)
11
+ new(report_file_path, _options)
12
+ end
13
+
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, RubricAssessment, options: options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "./report_processor"
2
+
3
+ module CanvasSync
4
+ module Processors
5
+ # Processes a rubric association report using the bulk importer.
6
+ #
7
+ # @param report_file_path [String]
8
+ # @param options [Hash]
9
+ class RubricAssociationsProcessor < ReportProcessor
10
+ def self.process(report_file_path, _options, report_id)
11
+ new(report_file_path, _options)
12
+ end
13
+
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, RubricAssociation, options: options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ require_relative "./report_processor"
2
+
3
+ module CanvasSync
4
+ module Processors
5
+ # Processes a rubrics report using the bulk importer.
6
+ #
7
+ # @param report_file_path [String]
8
+ # @param options [Hash]
9
+ class RubricsProcessor < ReportProcessor
10
+ def self.process(report_file_path, _options, report_id)
11
+ new(report_file_path, _options)
12
+ end
13
+
14
+ def initialize(report_file_path, options)
15
+ do_bulk_import(report_file_path, Rubric, options: options)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module CanvasSync
2
- VERSION = "0.19.2.beta1".freeze
2
+ VERSION = "0.19.4".freeze
3
3
  end
data/lib/canvas_sync.rb CHANGED
@@ -47,6 +47,9 @@ module CanvasSync
47
47
  content_migrations
48
48
  learning_outcomes
49
49
  course_nicknames
50
+ rubrics
51
+ rubric_associations
52
+ rubric_assessments
50
53
  ].freeze
51
54
 
52
55
  SUPPORTED_TERM_SCOPE_MODELS = %w[
@@ -55,6 +58,9 @@ module CanvasSync
55
58
  assignment_groups
56
59
  context_modules
57
60
  context_module_items
61
+ rubrics
62
+ rubric_associations
63
+ rubric_assessments
58
64
  ].freeze
59
65
 
60
66
  DEFAULT_TERM_SCOPE_MODELS = %w[
@@ -63,6 +69,9 @@ module CanvasSync
63
69
  assignment_groups
64
70
  context_modules
65
71
  context_module_items
72
+ rubrics
73
+ rubric_associations
74
+ rubric_assessments
66
75
  ].freeze
67
76
 
68
77
  SUPPORTED_LIVE_EVENTS = %w[
@@ -154,6 +163,9 @@ module CanvasSync
154
163
  context_modules: CanvasSync::Jobs::SyncContextModulesJob,
155
164
  context_module_items: CanvasSync::Jobs::SyncContextModuleItemsJob,
156
165
  content_migrations: CanvasSync::Jobs::SyncContentMigrationsJob,
166
+ rubrics: CanvasSync::Jobs::SyncRubricsJob,
167
+ rubric_associations: CanvasSync::Jobs::SyncRubricAssociationsJob,
168
+ rubric_assessments: CanvasSync::Jobs::SyncRubricAssessmentsJob,
157
169
  }.with_indifferent_access
158
170
 
159
171
  root_chain = base_canvas_sync_chain(**kwargs, globals: options[:global] || kwargs[:globals])
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe CanvasSync::Processors::RubricAssessmentsProcessor do
4
+ let(:subject) { CanvasSync::Processors::RubricAssessmentsProcessor }
5
+
6
+ describe "#process" do
7
+ it 'processes rubric assessments' do
8
+ expect {
9
+ subject.process('spec/support/fixtures/reports/rubric_assessments.csv', { models: ['rubric_assessments'] }, 1)
10
+ }.to change { RubricAssessment.count }.by(2)
11
+ rubric_assessment = RubricAssessment.first
12
+ expect(rubric_assessment.canvas_rubric_association_id).to eq(1)
13
+ expect(rubric_assessment.score).to eq(10)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe CanvasSync::Processors::RubricAssociationsProcessor do
4
+ let(:subject) { CanvasSync::Processors::RubricAssociationsProcessor }
5
+
6
+ describe "#process" do
7
+ it 'processes rubric associations' do
8
+ expect {
9
+ subject.process('spec/support/fixtures/reports/rubric_associations.csv', { models: ['rubric_associations'] }, 1)
10
+ }.to change { RubricAssociation.count }.by(2)
11
+ rubric_association = RubricAssociation.first
12
+ expect(rubric_association.title).to eq("Rubric Association Title")
13
+ expect(rubric_association.summary_data).to eq("Rubric Association Summary Data")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe CanvasSync::Processors::RubricsProcessor do
4
+ let(:subject) { CanvasSync::Processors::RubricsProcessor }
5
+
6
+ describe "#process" do
7
+ it 'inserts rubrics' do
8
+ expect {
9
+ subject.process('spec/support/fixtures/reports/rubrics.csv', { models: ['rubrics'] }, 1)
10
+ }.to change { Rubric.count }.by(2)
11
+ rubric = Rubric.first
12
+ expect(rubric.title).to eq("Assignment 1")
13
+ expect(rubric.description).to eq("Assignment 1 description")
14
+ end
15
+
16
+ end
17
+ end
@@ -20,6 +20,7 @@ class Course < ApplicationRecord
20
20
  has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_course_id
21
21
  has_many :assignment_groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
22
22
  has_many :groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
23
+ has_many :rubrics, as: :context, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
23
24
 
24
25
  api_syncable({
25
26
  sis_id: :sis_course_id,
@@ -0,0 +1,35 @@
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, optional: true
17
+ belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id , optional: true # based on another rubric
18
+ belongs_to :context, polymorphic: true, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type, optional: true
19
+
20
+ has_many :rubric_associations, primary_key: :canvas_id, foreign_key: :canvas_association_id, foreign_type: :canvas_association_type
21
+ has_many :rubric_assessments, through: :rubric_associations, dependent: :destroy
22
+
23
+ api_syncable({
24
+ canvas_id: :id,
25
+ title: :title,
26
+ canvas_context_id: :context_id,
27
+ canvas_context_type: :context_type,
28
+ points_possible: :points_possible,
29
+ reusable: :reusable,
30
+ read_only: :read_only,
31
+ free_form_criterion_comments: :free_form_criterion_comments,
32
+ hide_score_total: :hide_score_total,
33
+ data: :data,
34
+ }, -> (api) { api.get("api/v1/accounts/#{canvas_root_account_id}/rubrics/#{canvas_id}") })
35
+ end
@@ -0,0 +1,23 @@
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
+
12
+ canvas_sync_features :defaults
13
+
14
+ validates :canvas_id, uniqueness: true, presence: true
15
+
16
+ belongs_to :rubric, primary_key: :canvas_id, foreign_key: :canvas_rubric_id, optional: true
17
+ belongs_to :rubric_association, primary_key: :canvas_id, foreign_key: :canvas_rubric_association_id, optional: true
18
+ belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
19
+ belongs_to :assessor, class_name: "User", primary_key: :canvas_id, foreign_key: :canvas_assessor_id, optional: true
20
+ belongs_to :artifact, polymorphic: true, primary_key: :canvas_id, foreign_type: :canvas_artifact_type, foreign_key: :canvas_artifact_id, optional: true
21
+
22
+ serialize :data
23
+ end