Sha256: d031586737526c41d41d53d7ae3685266b484ea804a1d28a871feb1cd637c6bb
Contents?: true
Size: 1.99 KB
Versions: 27
Compression:
Stored size: 1.99 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 AssignmentEvent < LiveEvents::BaseEvent # The following is provided in the live events call: # { # assignment_id: assignment.global_id, # context_id: assignment.global_context_id, # context_type: assignment.context_type, # workflow_state: assignment.workflow_state, # title: LiveEvents.truncate(assignment.title), # description: LiveEvents.truncate(assignment.description), # due_at: assignment.due_at, # unlock_at: assignment.unlock_at, # lock_at: assignment.lock_at, # updated_at: assignment.updated_at, # points_possible: assignment.points_possible # } def perform(event_payload) super attrs = { canvas_assignment_id: local_canvas_id(payload[:assignment_id]), title: payload[:title], workflow_state: payload[:workflow_state], description: payload[:description], due_at: payload[:due_at], unlock_at: payload[:unlock_at], lock_at: payload[:lock_at], points_possible: payload[:points_possible], } create_or_update(attrs) end private def create_or_update(attrs) assignment = Assignment.where(canvas_assignment_id: attrs[:canvas_assignment_id]).first_or_initialize assignment.assign_attributes(attrs) assignment.save! assignment end # This could be nil if the context type for this assignment is not 'Course' of if a local course was not found def canvas_course_id payload[:context_type] == "Course" ? local_canvas_id(payload[:context_id]) : nil end # This could be nil if the context type for this assignment is not 'Course' of if a local course was not found def course @course ||= Course.find_by(canvas_course_id: canvas_course_id) end end end
Version data entries
27 entries across 27 versions & 1 rubygems