Sha256: a87bdef121c6249ba20ecbd23a1702f6213b4c0dbe56c33ae6810b24e61eeb00

Contents?: true

Size: 1.46 KB

Versions: 25

Compression:

Stored size: 1.46 KB

Contents

# <%= autogenerated_model_warning %>

class Course < ApplicationRecord
  include CanvasSync::Record
  include CanvasSync::Concerns::ApiSyncable

  canvas_sync_features :defaults

  # include CanvasSync::Concerns::LiveEventSync
  # after_process_live_event do
  #   if account.nil?
  #     acc = Account.new(canvas_id: canvas_account_id)
  #     acc.sync_from_api
  #   end
  # end

  validates :canvas_id, uniqueness: true, presence: true
  belongs_to :term, foreign_key: :canvas_term_id, primary_key: :canvas_id, optional: true
  has_many :enrollments, primary_key: :canvas_id, foreign_key: :canvas_course_id
  has_many :sections, primary_key: :canvas_id, foreign_key: :canvas_course_id
  has_many :assignments, as: :context, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type
  has_many :submissions, primary_key: :canvas_id, foreign_key: :canvas_course_id
  has_many :assignment_groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
  has_many :groups, primary_key: :canvas_id, foreign_key: :canvas_course_id
  has_many :rubrics, as: :context, primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type

  api_syncable({
    sis_id: :sis_course_id,
    course_code: :course_code,
    name: :name,
    workflow_state: :workflow_state,
    canvas_term_id: :enrollment_term_id,
    canvas_account_id: :account_id,
    start_at: :start_at,
    end_at: :end_at,
  }, -> (api) { api.course(canvas_id) })
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.8 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.6 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.5 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.4 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.3 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.2 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.1 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta8 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta7 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta6 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta5 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta4 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta3 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta2 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.22.0.beta1 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.21.1 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.21.1.beta1 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.21.0 lib/canvas_sync/generators/templates/models/course.rb