Sha256: 4054de43b4c1448c0b066fa4faf9dc62e07fafd9e286aebadc591e0954ac70e1
Contents?: true
Size: 1.84 KB
Versions: 27
Compression:
Stored size: 1.84 KB
Contents
# <%= autogenerated_event_warning %> 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