Sha256: ac7699ab1c037c27228354526f8628ff1ac1ca6d127faccf4b5566103c97a1b8

Contents?: true

Size: 1.1 KB

Versions: 81

Compression:

Stored size: 1.1 KB

Contents

# <%= autogenerated_model_warning %>

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

  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

  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

81 entries across 81 versions & 1 rubygems

Version Path
canvas_sync-0.14.0 lib/canvas_sync/generators/templates/models/course.rb