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 ⇒ Object
TODO: Not sure we want this to be settable.
-
#id ⇒ Object
TODO: Not sure we want this to be settable.
-
#previous_attempt_completion ⇒ String
Represents whether the previous attempt on the activity has been completed.
-
#runtime_interactions ⇒ Object
TODO: Not sure we want this to be settable.
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.
12 13 14 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 12 def activity_completion @activity_completion end |
#activity_success ⇒ String
Pass/fail status of primary objective for this activity.
22 23 24 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 22 def activity_success @activity_success end |
#children ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
7 8 9 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 7 def children @children end |
#id ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
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.
17 18 19 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 17 def previous_attempt_completion @previous_attempt_completion end |
#runtime_interactions ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
7 8 9 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 7 def runtime_interactions @runtime_interactions end |
Class Method Details
.get_runtime_interactions_from_api(options) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 49 def self.get_runtime_interactions_from_api() .fetch("runtime", {}) .fetch("runtimeInteractions", []) .map { |e| RegistrationRuntimeInteraction.new_from_api(e) } end |
.new_from_api(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 24 def self.new_from_api( = {}) this = new this. = .dup this.id = ["id"] this.activity_completion = ["activityCompletion"] this.previous_attempt_completion = ["previousAttemptCompletion"] this.activity_success = ["activitySuccess"] 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
45 46 47 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 45 def all_runtime_interactions (runtime_interactions + children.map(&:all_runtime_interactions)).flatten end |
#complete? ⇒ Boolean
Has this activity been completed?
62 63 64 65 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 62 def complete? return nil if activity_completion == "UNKNOWN" activity_completion == "COMPLETED" end |
#failed? ⇒ Boolean
Has this activity failed?
117 118 119 120 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 117 def failed? return nil if activity_success == "UNKNOWN" activity_success == "FAILED" end |
#incomplete? ⇒ Boolean
Is this activity incomplete?
73 74 75 76 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 73 def incomplete? return nil if activity_completion == "UNKNOWN" activity_completion == "INCOMPLETE" end |
#passed? ⇒ Boolean
Has this activity been passed?
106 107 108 109 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 106 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?
84 85 86 87 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 84 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?
95 96 97 98 |
# File 'lib/scorm_engine/models/registration_activity_detail.rb', line 95 def previous_attempt_incomplete? return nil if previous_attempt_completion == "Unknown" previous_attempt_completion == "Incomplete" end |