Class: ScormEngine::Models::RegistrationRuntimeInteraction

Inherits:
Object
  • 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

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

def learner_response
  @learner_response
end

#options=(value) ⇒ Object

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



4
5
6
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 4

def options=(value)
  @options = value
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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

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.



10
11
12
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 10

def weighting
  @weighting
end

Class Method Details

.get_description_from_api(options) ⇒ Object



30
31
32
33
34
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 30

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



36
37
38
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 36

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

.get_timestamp_from_api(options) ⇒ Object



40
41
42
43
44
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 40

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



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

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



46
47
48
49
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 46

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