Class: ScormEngine::Models::RegistrationActivityDetail
- Defined in:
- lib/scorm_engine/models/registration_activity_detail.rb
Instance Attribute Summary collapse
-
#activity_completion ⇒ String
Represents whether the current attempt on the activity has been completed.
-
#activity_success ⇒ String
Pass/fail status of primary objective for this activity.
-
#children ⇒ Array<ScormEngine::Models::RegistrationActivityDetail>
A nested array of activity details.
-
#id ⇒ String
The external identification of the registration.
-
#previous_attempt_completion ⇒ String
Represents whether the previous attempt on the activity has been completed.
- #runtime_interactions ⇒ Array<ScormEngine::Models::RegistrationRuntimeInteraction>
Class Method Summary collapse
Instance Method Summary collapse
-
#all_runtime_interactions ⇒ Array<RegistrationRuntimeInteraction>
Return a flattened array of all runtime interactions.
-
#complete? ⇒ Boolean
Has this activity been completed?.
-
#failed? ⇒ Boolean
Has this activity failed?.
-
#incomplete? ⇒ Boolean
Is this activity incomplete?.
-
#passed? ⇒ Boolean
Has this activity been passed?.
-
#previous_attempt_complete? ⇒ Boolean
Has the previous attempt of this activity been completed?.
-
#previous_attempt_incomplete? ⇒ Boolean
Is the previous attempt of this previous_attempt incomplete?.
Methods inherited from Base
Instance Attribute Details
#activity_completion ⇒ String
Represents whether the current attempt on the activity has been completed.
22 23 24 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 22 def activity_completion @activity_completion end |
#activity_success ⇒ String
Pass/fail status of primary objective for this activity.
32 33 34 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 32 def activity_success @activity_success end |
#children ⇒ Array<ScormEngine::Models::RegistrationActivityDetail>
A nested array of activity details
12 13 14 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 12 def children @children end |
#id ⇒ String
The external identification of the registration.
7 8 9 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 7 def id @id end |
#previous_attempt_completion ⇒ String
Represents whether the previous attempt on the activity has been completed.
27 28 29 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 27 def previous_attempt_completion @previous_attempt_completion end |
#runtime_interactions ⇒ Array<ScormEngine::Models::RegistrationRuntimeInteraction>
17 18 19 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 17 def runtime_interactions @runtime_interactions end |
Class Method Details
.get_runtime_interactions_from_api(options) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 59 def self.get_runtime_interactions_from_api() .fetch("runtime", {}) .fetch("runtimeInteractions", []) .map { |e| RegistrationRuntimeInteraction.new_from_api(e) } end |
.new_from_api(options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 34 def self.new_from_api( = {}) this = new this. = .dup this.id = ["id"] this.activity_completion = ["activityCompletion"]&.upcase this.previous_attempt_completion = ["previousAttemptCompletion"]&.upcase this.activity_success = ["activitySuccess"]&.upcase this.runtime_interactions = get_runtime_interactions_from_api() this.children = .fetch("children", []).map { |e| new_from_api(e) } this end |
Instance Method Details
#all_runtime_interactions ⇒ Array<RegistrationRuntimeInteraction>
Return a flattened array of all runtime interactions
55 56 57 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 55 def all_runtime_interactions (runtime_interactions + children.map(&:all_runtime_interactions)).flatten end |
#complete? ⇒ Boolean
Has this activity been completed?
72 73 74 75 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 72 def complete? return nil if activity_completion == "UNKNOWN" activity_completion == "COMPLETED" end |
#failed? ⇒ Boolean
Has this activity failed?
127 128 129 130 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 127 def failed? return nil if activity_success == "UNKNOWN" activity_success == "FAILED" end |
#incomplete? ⇒ Boolean
Is this activity incomplete?
83 84 85 86 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 83 def incomplete? return nil if activity_completion == "UNKNOWN" activity_completion == "INCOMPLETE" end |
#passed? ⇒ Boolean
Has this activity been passed?
116 117 118 119 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 116 def passed? return nil if activity_success == "UNKNOWN" activity_success == "PASSED" end |
#previous_attempt_complete? ⇒ Boolean
Has the previous attempt of this activity been completed?
94 95 96 97 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 94 def previous_attempt_complete? return nil if previous_attempt_completion == "UNKNOWN" previous_attempt_completion == "COMPLETED" end |
#previous_attempt_incomplete? ⇒ Boolean
Is the previous attempt of this previous_attempt incomplete?
105 106 107 108 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 105 def previous_attempt_incomplete? return nil if previous_attempt_completion == "UNKNOWN" previous_attempt_completion == "INCOMPLETE" end |