Class: ScormEngine::Models::Dispatch
- Defined in:
- lib/scorm_engine/models/dispatch.rb
Instance Attribute Summary collapse
-
#allow_new_registrations ⇒ Boolean
If true, then new registrations can be created for this dispatch.
-
#course_id ⇒ String
The external identification of the course.
-
#destination_id ⇒ String
The external identification of the destination.
-
#enabled ⇒ Boolean
If true, then this dispatch can be launched.
-
#expiration_date ⇒ Time
The date after which this dispatch will be disabled as an ISO 8601 string, or “none” for no expiration date.
-
#external_config ⇒ String
Serialized external configuration information to include when launching the dispatched package.
-
#id ⇒ String
The external identification of this dispatch.
-
#instanced ⇒ Boolean
If true, then a new registration instance will be created if the client LMS doesn’t provide launch data for an existing one.
-
#registration_cap ⇒ Integer
The maximum number of registrations that can be created for this dispatch, where ‘0’ means ‘unlimited registrations’.
-
#registration_count ⇒ Integer
The number of registrations created for this dispatch.
Class Method Summary collapse
-
.get_expiration_date(options = {}) ⇒ Time
Extract and normalize the expiration date from the API options.
- .new_from_api(options = {}) ⇒ Object
Methods inherited from Base
Instance Attribute Details
#allow_new_registrations ⇒ Boolean
If true, then new registrations can be created for this dispatch.
24 25 26 |
# File 'lib/scorm_engine/models/dispatch.rb', line 24 def allow_new_registrations @allow_new_registrations end |
#course_id ⇒ String
The external identification of the course.
19 20 21 |
# File 'lib/scorm_engine/models/dispatch.rb', line 19 def course_id @course_id end |
#destination_id ⇒ String
The external identification of the destination.
14 15 16 |
# File 'lib/scorm_engine/models/dispatch.rb', line 14 def destination_id @destination_id end |
#enabled ⇒ Boolean
If true, then this dispatch can be launched.
53 54 55 |
# File 'lib/scorm_engine/models/dispatch.rb', line 53 def enabled @enabled end |
#expiration_date ⇒ Time
The date after which this dispatch will be disabled as an ISO 8601 string, or “none” for no expiration date.
48 49 50 |
# File 'lib/scorm_engine/models/dispatch.rb', line 48 def expiration_date @expiration_date end |
#external_config ⇒ String
Serialized external configuration information to include when launching the dispatched package.
59 60 61 |
# File 'lib/scorm_engine/models/dispatch.rb', line 59 def external_config @external_config end |
#id ⇒ String
The external identification of this dispatch.
9 10 11 |
# File 'lib/scorm_engine/models/dispatch.rb', line 9 def id @id end |
#instanced ⇒ Boolean
If true, then a new registration instance will be created if the client LMS doesn’t provide launch data for an existing one. Otherwise, the same instance will always be used for the given cmi.learner_id.
31 32 33 |
# File 'lib/scorm_engine/models/dispatch.rb', line 31 def instanced @instanced end |
#registration_cap ⇒ Integer
The maximum number of registrations that can be created for this dispatch, where ‘0’ means ‘unlimited registrations’.
37 38 39 |
# File 'lib/scorm_engine/models/dispatch.rb', line 37 def registration_cap @registration_cap end |
#registration_count ⇒ Integer
The number of registrations created for this dispatch.
42 43 44 |
# File 'lib/scorm_engine/models/dispatch.rb', line 42 def registration_count @registration_count end |
Class Method Details
.get_expiration_date(options = {}) ⇒ Time
Extract and normalize the expiration date from the API options.
92 93 94 95 96 |
# File 'lib/scorm_engine/models/dispatch.rb', line 92 def self.get_expiration_date( = {}) expiration_date = ["expirationDate"] return if expiration_date.nil? || expiration_date == "none" Time.parse(expiration_date) end |
.new_from_api(options = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/scorm_engine/models/dispatch.rb', line 61 def self.new_from_api( = {}) this = new this. = .dup this.id = ["id"] # get_dispatches (plural) returns values in a nested 'data' field. # get_dispatches (singular) does not. data = ["data"] || this.destination_id = data["destinationId"] this.course_id = data["courseId"] this.allow_new_registrations = data["allowNewRegistrations"] this.instanced = data["instanced"] this.registration_cap = data["registrationCap"]&.to_i this.registration_count = data["registrationCount"]&.to_i this.expiration_date = get_expiration_date(data) this.enabled = data["enabled"] this.external_config = data["externalConfig"] this end |