Class: ScormEngine::Models::RegistrationLaunchHistory
- Inherits:
-
Object
- Object
- ScormEngine::Models::RegistrationLaunchHistory
- Defined in:
- lib/scorm_engine/models/registration_launch_history.rb
Instance Attribute Summary collapse
-
#completion_status ⇒ Object
TODO: Not sure we want this to be settable.
-
#exit_time ⇒ Object
TODO: Not sure we want this to be settable.
-
#id ⇒ Object
TODO: Not sure we want this to be settable.
-
#instance_id ⇒ Object
TODO: Not sure we want this to be settable.
-
#last_runtime_update ⇒ Object
TODO: Not sure we want this to be settable.
-
#launch_time ⇒ Object
TODO: Not sure we want this to be settable.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#score ⇒ Object
TODO: Not sure we want this to be settable.
-
#success_status ⇒ Object
TODO: Not sure we want this to be settable.
-
#total_seconds_tracked ⇒ Object
TODO: Not sure we want this to be settable.
Class Method Summary collapse
-
.get_score_from_api(options = {}) ⇒ Float
Extract and normalize the scaled passing score from the API options.
-
.get_total_seconds_tracked_from_api(options = {}) ⇒ Time
Extract and normalize the completed date from the API options.
- .new_from_api(options = {}) ⇒ Object
-
.parse_time(string) ⇒ Time
Extract and convert various time formats.
Instance Attribute Details
#completion_status ⇒ 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def completion_status @completion_status end |
#exit_time ⇒ 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def exit_time @exit_time 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def id @id end |
#instance_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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def instance_id @instance_id end |
#last_runtime_update ⇒ 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def last_runtime_update @last_runtime_update end |
#launch_time ⇒ 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def launch_time @launch_time end |
#options=(value) ⇒ Object
Sets the attribute options
9 10 11 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 9 def (value) @options = value end |
#score ⇒ 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def score @score end |
#success_status ⇒ 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def success_status @success_status end |
#total_seconds_tracked ⇒ 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.
15 16 17 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 15 def total_seconds_tracked @total_seconds_tracked end |
Class Method Details
.get_score_from_api(options = {}) ⇒ Float
Extract and normalize the scaled passing score from the API options.
64 65 66 67 68 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 64 def self.get_score_from_api( = {}) score = .fetch("score", {})["scaled"] return if score.nil? score.to_f end |
.get_total_seconds_tracked_from_api(options = {}) ⇒ Time
Extract and normalize the completed date from the API options.
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 80 def self.get_total_seconds_tracked_from_api( = {}) # There is a bug in the API that returns a trailing space sometimes. # I swear I also saw `totalSecondsTracked` as part of `score`, but can't find it now. # However, since I intentionally did it I'm going to leave it for now. seconds = ["totalSecondsTracked"] seconds ||= ["totalSecondsTracked "] score = .fetch("score", {}) seconds ||= score["totalSecondsTracked"] seconds ||= score["totalSecondsTracked "] return if seconds.nil? [seconds.to_f, 0].max end |
.new_from_api(options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 19 def self.new_from_api( = {}) this = new this. = .dup this.id = ["id"] this.instance_id = ["instanceId"].to_i this.launch_time = parse_time(["launchTimeUtc"]) this.exit_time = parse_time(["exitTimeUtc"]) this.completion_status = ["completionStatus"] this.success_status = ["successStatus"] this.last_runtime_update = parse_time(["lastRuntimeUpdateUtc"]) this.score = get_score_from_api() this.total_seconds_tracked = get_total_seconds_tracked_from_api() this end |
.parse_time(string) ⇒ Time
Extract and convert various time formats.
48 49 50 51 52 53 |
# File 'lib/scorm_engine/models/registration_launch_history.rb', line 48 def self.parse_time(string) return nil if string.nil? || string.empty? Time.strptime("#{string} UTC", "%m/%d/%Y %H:%M:%S %p %Z") rescue StandardError Time.parse(string) end |