Sha256: 0f4aa0e412d6bd2246949ebe686694b85a27685361411911c305620b323dab53

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

<%= autogenerated_model_warning %>

class Assignment < ApplicationRecord
  include CanvasSync::ApiSyncable

  validates :canvas_assignment_id, uniqueness: true, presence: true
  belongs_to :context, polymorphic: true, optional: true, primary_key: :canvas_course_id
  belongs_to :assignment_group, optional: true, primary_key: :canvas_assignment_group_id, foreign_key: :canvas_assignment_group_id
  has_many :submissions, primary_key: :canvas_assignment_id, foreign_key: :canvas_assignment_id
  has_many :context_module_items, primary_key: :canvas_assignment_id, foreign_key: :content_id, dependent: :destroy
  has_many :context_modules, through: :context_module_items

  api_syncable({
    title: :name,
    description: :description,
    due_at: :due_at,
    unlock_at: :unlock_at,
    points_possible: :points_possible,
    min_score: :min_score,
    max_score: :max_score,
    mastery_score: :mastery_score,
    grading_type: :grading_type,
    submission_types: lambda { |p| p["submission_types"].join(",") },
    workflow_state: :workflow_state,
    context_id: :course_id,
    context_type: lambda { |_p| "Course" },
    canvas_assignment_group_id: :canvas_assignment_group_id,
    grading_scheme_id: :grading_scheme_id,
    grading_standard_id: :grading_standard_id,
  }, -> (api) { api.assignment(context_id, canvas_assignment_id) })
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
canvas_sync-0.9.1 lib/canvas_sync/generators/templates/models/assignment.rb
canvas_sync-0.9.0 lib/canvas_sync/generators/templates/models/assignment.rb
canvas_sync-0.8.4 lib/canvas_sync/generators/templates/models/assignment.rb