Sha256: 53067cd7e07aa4429715c293c4c390fea3d3c555aaf8b71a7755aa3eb83a7a27

Contents?: true

Size: 994 Bytes

Versions: 3

Compression:

Stored size: 994 Bytes

Contents

<%= autogenerated_model_warning %>

class Course < ApplicationRecord
  include CanvasSync::ApiSyncable

  validates :canvas_course_id, uniqueness: true, presence: true
  belongs_to :term, foreign_key: :canvas_term_id, primary_key: :canvas_term_id, optional: true
  has_many :enrollments, primary_key: :canvas_course_id, foreign_key: :canvas_course_id
  has_many :sections, primary_key: :canvas_course_id, foreign_key: :canvas_course_id
  has_many :assignments, as: :context, primary_key: :canvas_course_id
  has_many :submissions, primary_key: :canvas_course_id, foreign_key: :canvas_course_id
  has_many :assignment_groups, primary_key: :canvas_course_id, foreign_key: :canvas_course_id

  api_syncable({
    sis_id: :sis_course_id,
    short_name: :course_code,
    long_name: :name,
    status: :workflow_state,
    canvas_term_id: :enrollment_term_id,
    canvas_account_id: :account_id,
    start_date: :start_at,
    end_date: :end_at,
  }, -> (api) { api.course(canvas_course_id) })
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
canvas_sync-0.9.4 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.9.3 lib/canvas_sync/generators/templates/models/course.rb
canvas_sync-0.9.2 lib/canvas_sync/generators/templates/models/course.rb