Sha256: 390065e6b3a04d642267885e8d36c43c938750bf46b7af5ed6e420e7759568d9

Contents?: true

Size: 1.81 KB

Versions: 23

Compression:

Stored size: 1.81 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 CourseSectionEvent < LiveEvents::BaseEvent
    # The following is provided in the live events call:
    # {
    #   course_section_id: section.id,
    #   sis_source_id: section.sis_source_id,
    #   sis_batch_id: section.sis_batch_id,
    #   course_id: section.course_id,
    #   root_account_id: section.root_account_id,
    #   enrollment_term_id: section.enrollment_term_id,
    #   name: section.name,
    #   default_section: section.default_section,
    #   accepting_enrollments: section.accepting_enrollments,
    #   can_manually_enroll: section.can_manually_enroll,
    #   start_at: section.start_at,
    #   end_at: section.end_at,
    #   workflow_state: section.workflow_state,
    #   restrict_enrollments_to_section_dates: section.restrict_enrollments_to_section_dates,
    #   nonxlist_course_id: section.nonxlist_course_id,
    #   stuck_sis_fields: section.stuck_sis_fields,
    #   integration_id: section.integration_id
    # }

    def perform(_event_payload)
      super
      attrs = {
        canvas_section_id: local_canvas_id(payload[:course_section_id]),
        canvas_course_id: local_canvas_id(payload[:course_id]),
        name: payload[:name],
        status: payload[:workflow_state],
        start_date: payload[:start_at],
        end_date: payload[:end_at],
        canvas_nonxlist_course_id: payload[:nonxlist_course_id],
      }
      create_or_update(attrs)
    end

    private

    def create_or_update(attrs)
      section = Section.where(canvas_section_id: attrs[:canvas_section_id]).first_or_initialize
      section.assign_attributes(attrs)
      section.save!
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
canvas_sync-0.9.4 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.9.3 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.9.2 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.9.1 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.9.0 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.8.4 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.8.3 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.8.2 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.8.1 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.8.0 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.7.3 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.7.2 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.7.1 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.7.0 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.6.4 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.6.3 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.6.2 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.6.1 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.6.0 spec/dummy/app/services/live_events/course_section_event.rb
canvas_sync-0.5.4 spec/dummy/app/services/live_events/course_section_event.rb