Sha256: 75eb982eaaa6c38eb762706a679279103f9b180070148dc3335635ee8e77291e
Contents?: true
Size: 1.62 KB
Versions: 19
Compression:
Stored size: 1.62 KB
Contents
<%= autogenerated_event_warning %> class LiveEvents::EnrollmentEvent < LiveEvents::BaseEvent # The following is provided in the live events call: # { # # enrollment_id: enrollment.global_id, # course_id: enrollment.global_course_id, # user_id: enrollment.global_user_id, # user_name: enrollment.user_name, # type: enrollment.type, # created_at: enrollment.created_at, # updated_at: enrollment.updated_at, # limit_privileges_to_course_section: enrollment.limit_privileges_to_course_section, # course_section_id: enrollment.global_course_section_id, # workflow_state: enrollment.workflow_state # } def perform(paload) super return if course.nil? || section.nil? || user.nil? attrs = { canvas_enrollment_id: local_canvas_id(payload[:enrollment_id]), course_id: course.try(:id), user_id: user.try(:id), type: payload[:type], section_id: section.try(:id), workflow_state: payload[:workflow_state] } create_or_update(attrs) rescue => e log_error e ensure true end private def create_or_update(attrs) enrollment = Enrollment.where(canvas_enrollment_id: attrs[:canvas_enrollment_id]).first_or_initialize enrollment.assign_attributes(attrs) enrollment.save! enrollment end def course @course ||= Course.find_by(canvas_course_id: local_canvas_id(payload[:course_id])) end def section @section ||= Section.find_by(canvas_section_id: local_canvas_id(payload[:section_id])) end def user @user ||= User.find_by(canvas_user_id: local_canvas_id(payload[:user_id])) end end
Version data entries
19 entries across 19 versions & 1 rubygems