Sha256: fe74f36a38fab8dbb3c98c18b15549a9f83480a6e718686ad5811d7f10d9aadb

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

module AbsorbApi
  class Course < Base
    include Relations

    attr_accessor :id, :name, :description, :notes, :external_id, :access_date, :expire_type, :expire_duration, :expiry_date, :active_status, :tag_ids, :resource_ids, :editor_ids, :prices, :competency_definition_ids, :prerequisite_course_ids, :post_enrollment_course_ids, :allow_course_evaluation, :category_id, :certificate_url, :audience, :goals, :vendor, :company_cost, :learner_cost, :company_time, :learner_time

    has_many :certificates
    has_many :chapters
    has_many :enrollments, :course_enrollment
    has_many :resources
    has_many :prerequisites
    has_many :lessons

    # gets all associated enrollments given a collection of courses
    # all calls are called in parallel
    def self.enrollments_from_collection(courses, **conditions)
      enrollments = []
      AbsorbApi.api.in_parallel do
        courses.reject { |course| AbsorbApi.configuration.ignored_course_ids.include? course.id }.each do |course|
          enrollments << AbsorbApi.api.get("courses/#{course.id}/enrollments", conditions)
        end
      end
      enrollments.map { |response| response.body.map { |attrs| CourseEnrollment.new(attrs) } }.flatten
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
absorb_api-0.1.11 lib/absorb_api/course.rb
absorb_api-0.1.10 lib/absorb_api/course.rb
absorb_api-0.1.9 lib/absorb_api/course.rb
absorb_api-0.1.8 lib/absorb_api/course.rb
absorb_api-0.1.7 lib/absorb_api/course.rb