Sha256: 1a71fa7abb24921902d78bc2f11d21c7d54ab5f99e3910a668c5f9846f1682b6

Contents?: true

Size: 1.59 KB

Versions: 27

Compression:

Stored size: 1.59 KB

Contents

# <%= autogenerated_event_warning %>

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 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.10.0 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.9.4 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.9.3 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.9.2 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.9.1 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.9.0 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.8.4 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.8.3 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.8.2 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.8.1 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.8.0 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.7.3 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.7.2 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.7.1 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.7.0 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.6.4 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.6.3 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.6.2 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb
canvas_sync-0.6.1 lib/canvas_sync/generators/templates/services/live_events/grade/grade_event.rb