Class: ScormEngine::Models::RegistrationRuntimeInteraction

Inherits:
Base
  • Object
show all
Defined in:
lib/scorm_engine/models/registration_runtime_interaction.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_hash

Instance Attribute Details

#correct_responsesObject

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_runtime_interaction.rb', line 7

def correct_responses
  @correct_responses
end

#descriptionObject

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_runtime_interaction.rb', line 7

def description
  @description
end

#idObject

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_runtime_interaction.rb', line 7

def id
  @id
end

#latencyObject

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_runtime_interaction.rb', line 7

def latency
  @latency
end

#learner_responseObject

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_runtime_interaction.rb', line 7

def learner_response
  @learner_response
end

#resultObject

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_runtime_interaction.rb', line 7

def result
  @result
end

#timestampObject

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_runtime_interaction.rb', line 7

def timestamp
  @timestamp
end

#typeObject

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_runtime_interaction.rb', line 7

def type
  @type
end

#weightingObject

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_runtime_interaction.rb', line 7

def weighting
  @weighting
end

Class Method Details

.get_description_from_api(options) ⇒ Object



27
28
29
30
31
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 27

def self.get_description_from_api(options)
  description = options["description"].to_s.gsub(/\s+/, " ").strip
  description = nil if description.empty? || description == "null"
  description
end

.get_learner_response_from_api(options) ⇒ Object



33
34
35
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 33

def self.get_learner_response_from_api(options)
  options["learnerResponse"].to_s.gsub(/\s+/, " ").strip
end

.get_timestamp_from_api(options) ⇒ Object



37
38
39
40
41
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 37

def self.get_timestamp_from_api(options)
  timestamp = options["timestampUtc"]
  return if timestamp.nil? || timestamp.empty?
  Time.parse(timestamp)
end

.new_from_api(options = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

def self.new_from_api(options = {})
  this = new

  this.options = options.dup
  this.id = options["id"]
  this.type = options["type"]
  this.description = get_description_from_api(options)
  this.timestamp = get_timestamp_from_api(options)
  this.correct_responses = options["correctResponses"]
  this.learner_response = get_learner_response_from_api(options)
  this.result = options["result"]
  this.weighting = options["weighting"].to_f
  this.latency = options["latency"]

  this
end

Instance Method Details

#latency_in_secondsObject



43
44
45
46
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 43

def latency_in_seconds
  h, m, s = latency.split(":")
  h.to_i * 3600 + m.to_i * 60 + s.to_i
end