Sha256: 0f08fc2b66ad97fd2af3f727d7d4d2f186b02e18fe15cb0c096fce8097b73754
Contents?: true
Size: 1.72 KB
Versions: 27
Compression:
Stored size: 1.72 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 SubmissionEvent < LiveEvents::BaseEvent # The following is provided in the live events call: # { # submission_id: submission.global_id, # assignment_id: submission.global_assignment_id, # user_id: submission.global_user_id, # submitted_at: submission.submitted_at, # graded_at: submission.graded_at, # updated_at: submission.updated_at, # score: submission.score, # grade: submission.grade, # submission_type: submission.submission_type, # body: LiveEvents.truncate(submission.body), # url: submission.url, # attempt: submission.attempt # } def perform(event_payload) super return if assignment.nil? || user.nil? attrs = { canvas_submission_id: local_canvas_id(payload[:submission_id]), canvas_assignment_id: assignment.try(:id), canvas_user_id: user.try(:id), submitted_at: payload[:submitted_at], graded_at: payload[:graded_at], score: payload[:score], } create_or_update(attrs) end end private def create_or_update(attrs) submission = Submission.where(canvas_submission_id: attrs[:canvas_submission_id]).first_or_initialize submission.assign_attributes(attrs) submission.save! submission end def assignment @assignment ||= Assignment.find_by(canvas_assignment_id: local_canvas_id(payload[:assignment_id])) end def user @user ||= User.find_by(canvas_user_id: local_canvas_id(payload[:user_id])) end end
Version data entries
27 entries across 27 versions & 1 rubygems