Sha256: 6858c680508c8afca88fec40a77aaf3ac448a817791515c3f8060450595184d2

Contents?: true

Size: 1.94 KB

Versions: 28

Compression:

Stored size: 1.94 KB

Contents

# frozen_string_literal: true

# # <%= autogenerated_model_warning %>

class LearningOutcomeResult < ActiveRecord::Base
  include CanvasSync::Record
  include CanvasSync::Concerns::ApiSyncable

  belongs_to :user, primary_key: :canvas_id, foreign_key: :canvas_user_id, optional: true
  belongs_to :learning_outcome, primary_key: :canvas_id, foreign_key: :canvas_learning_outcome_id, optional: true
  belongs_to :alignment, class_name: "ContentTag", primary_key: :canvas_id, foreign_key: :canvas_content_tag_id, optional: true
  belongs_to :association_object,
             polymorphic: [:rubric_association, :assignment],
             foreign_key: :association_id,
             foreign_type: :association_type,
             optional: true
  belongs_to :artifact,
            polymorphic: [:rubric_assessment, :submission],
            primary_key: :canvas_artifact_id,
            foreign_key: :canvas_artifact_id,
            foreign_type: :canvas_artifact_type,
            optional: true

  belongs_to :context, polymorphic: [:course], primary_key: :canvas_id, foreign_key: :canvas_context_id, foreign_type: :canvas_context_type, optional: true

  # Not yet implemented in CanvasSync
  # belongs_to :associated_asset,
  #           polymorphic:
  #                 [:assessment_question,
  #                  :assignment,
  #                  { quiz: "Quizzes::Quiz", assessment: "LiveAssessments::Assessment" }],
  #           polymorphic_prefix: true

  # Not yet implemented in CanvasSync
  # has_many :learning_outcome_question_results, dependent: :destroy

  api_syncable({
    canvas_id: :id,
    canvas_content_tag_id: :links&.[]("alignment"),
    canvas_learning_outcome_id: :links&.[]("learning_outcome"),
    canvas_user_id: :links&.[]("user"),
    score: :score,
    assessed_at: :submitted_or_assessed_at,
    percent: :percent
  }, ->(api) {
    api.get("/api/v1/courses/#{self.canvas_context_id}/#{self.canvas_id}")&.find { |item| item[:id] == self.canvas_id }
  })
end

Version data entries

28 entries across 28 versions & 1 rubygems

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