Class: AbsorbApi::CourseEnrollment

Inherits:
Base
  • Object
show all
Defined in:
lib/absorb_api/course_enrollment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from AbsorbApi::Base

Instance Attribute Details

#accepted_terms_and_conditionsObject

Returns the value of attribute accepted_terms_and_conditions.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def accepted_terms_and_conditions
  @accepted_terms_and_conditions
end

#certificate_idObject

Returns the value of attribute certificate_id.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def certificate_id
  @certificate_id
end

#course_idObject

Returns the value of attribute course_id.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def course_id
  @course_id
end

#course_nameObject

Returns the value of attribute course_name.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def course_name
  @course_name
end

#course_version_idObject

Returns the value of attribute course_version_id.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def course_version_id
  @course_version_id
end

#creditsObject

Returns the value of attribute credits.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def credits
  @credits
end

#date_completedObject

Returns the value of attribute date_completed.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def date_completed
  @date_completed
end

#date_startedObject

Returns the value of attribute date_started.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def date_started
  @date_started
end

#enrollment_key_idObject

Returns the value of attribute enrollment_key_id.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def enrollment_key_id
  @enrollment_key_id
end

#full_nameObject

Returns the value of attribute full_name.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def full_name
  @full_name
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def id
  @id
end

#progressObject

Returns the value of attribute progress.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def progress
  @progress
end

#scoreObject

Returns the value of attribute score.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def score
  @score
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def status
  @status
end

#time_spentObject

Returns the value of attribute time_spent.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def time_spent
  @time_spent
end

#user_idObject

Returns the value of attribute user_id.



3
4
5
# File 'lib/absorb_api/course_enrollment.rb', line 3

def user_id
  @user_id
end

Class Method Details

.lessons_from_collection(course_enrollments, **filters) ⇒ Object

gets all associated lessons given a collection of enrollments all calls are called in parallel enrollments are chunked in groups of 105 to keep typhoeus from getting bogged down modifiedSince must be a DateTime object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/absorb_api/course_enrollment.rb', line 15

def self.lessons_from_collection(course_enrollments, **filters)
  lessons = []
  course_enrollments.each_slice(105) do |enrollment_slice|
    AbsorbApi.api.in_parallel do
      enrollment_slice.each do |enrollment|
        lessons << AbsorbApi.api.get("users/#{enrollment.user_id}/enrollments/#{enrollment.course_id}/lessons", filters)
      end
    end
  end
  lessons.map { |response| response.body.map { |body| LessonEnrollment.new(body) } }.flatten.reject { |lesson| AbsorbApi.configuration.ignored_lesson_types.include? lesson.type }
end

Instance Method Details

#lessons(**conditions) ⇒ Object



5
6
7
8
9
# File 'lib/absorb_api/course_enrollment.rb', line 5

def lessons(**conditions)
  AbsorbApi.api.get("users/#{self.user_id}/enrollments/#{self.course_id}/lessons", conditions).body.map! do |lesson_attributes|
    LessonEnrollment.new(lesson_attributes)
  end
end