Sha256: 0d4e03db02725429aec60ec25de634b1da087dfca5b1b1d3d6cc7c481f9e559c

Contents?: true

Size: 1.75 KB

Versions: 27

Compression:

Stored size: 1.75 KB

Contents

# #
# AUTO GENERATED LIVE EVENT
# This was auto generated by the CanvasSync Gem.
# You can customize it as needed, but make sure you test
# any changes you make to the auto generated methods.
#


module LiveEvents
  class 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)
    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
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
canvas_sync-0.10.2 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.10.0 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.9.4 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.9.3 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.9.2 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.9.1 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.9.0 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.8.4 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.8.3 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.8.2 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.8.1 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.8.0 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.7.3 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.7.2 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.7.1 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.7.0 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.6.4 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.6.3 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.6.2 spec/dummy/app/services/live_events/grade_event.rb
canvas_sync-0.6.1 spec/dummy/app/services/live_events/grade_event.rb