Sha256: e2a0aaf04a09d09a6daa922d606a7adacfb6897c3f88af714fea82a15478e65c

Contents?: true

Size: 1.54 KB

Versions: 19

Compression:

Stored size: 1.54 KB

Contents

<%= autogenerated_event_warning %>

class LiveEvents::GradeEvent < LiveEvents::BaseEvent
  # The following is provided in the live events call:
  # {
  #   submission_id: submission.global_id,
  #   assignment_id: submission.global_assignment_id,
  #   grade: submission.grade,
  #   old_grade: old_submission.try(:grade),
  #   score: submission.score,
  #   old_score: old_submission.try(:score),
  #   points_possible: submission.assignment.points_possible,
  #   old_points_possible: old_assignment.points_possible,
  #   grader_id: grader_id,
  #   student_id: submission.global_user_id,
  #   user_id: submission.global_user_id,
  #   grading_complete: submission.graded?,
  #   muted: submission.muted_assignment?
  # }

  def perform(event_payload)
    super
    attrs = {
      submission_id: submission.try(:id),
      assignment_id: assignment.try(:id),
      score: payload[:score],
      points_possible: payload[:points_possible],
      grader_id: payload[:grader_id],
      user_id: user.try(:id),
      grading_complete: payload[:grading_complete],
      muted: payload[:muted]
    }
    create_or_update(attrs)
  rescue => e
    log_error e
  ensure
    true
  end

  private
  def create_or_update(attrs)
    # Todo: add your code here
  end

  def submission
    Submission.find_by(canvas_submission_id: local_canvas_id(payload[:submission_id]))
  end

  def assignment
    Assignment.find_by(canvas_assignment_id: local_canvas_id(payload[:assignment_id]))
  end

  def user
    User.find_by(canvas_user_id: local_canvas_id(payload[:user_id]))
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
canvas_sync-0.3.23 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.22 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.21 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.20 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.19 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.18 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.17 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.16 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.15 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.14 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.13 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.12 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.11 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.10 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.9 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.8 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.7 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.6 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.3.5 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb