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_responsesArray<String>

The correct responses to this interaction.

Returns:

  • (Array<String>)

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

def correct_responses
  @correct_responses
end

#descriptionString

A textual description of the interaction.

Returns:

  • (String)

17
18
19
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 17

def description
  @description
end

#idString

The interaction ID.

Returns:

  • (String)

7
8
9
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 7

def id
  @id
end

#latencyString

Iso8601TimeSpan representing the amount of time it took for the learner to make the interaction, i.e. how long it took the learner to answer the question.

Returns:

  • (String)

51
52
53
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 51

def latency
  @latency
end

#learner_responseString

The correct responses to this interaction.

Returns:

  • (String)

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

def learner_response
  @learner_response
end

#resultString

Returns:

  • (String)

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

def result
  @result
end

#timestampTime

The timestamp of when the interaction was reported, in the format provided by the SCO.

Returns:

  • (Time)

23
24
25
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 23

def timestamp
  @timestamp
end

#typeString

The interaction type.

Returns:

  • (String)

    (Undefined, TrueFalse, Choice, FillIn, LongFillIn, Likert, Matching, Performance, Sequencing, Numeric, Other)


12
13
14
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 12

def type
  @type
end

#weightingFloat

The weight this interaction carries relative to the other interactions in the SCO.

Returns:

  • (Float)

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

def weighting
  @weighting
end

Class Method Details

.get_description_from_api(options) ⇒ Object


79
80
81
82
83
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 79

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


85
86
87
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 85

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

.get_timestamp_from_api(options) ⇒ Object


89
90
91
92
93
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 89

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


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 53

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

  this.options = options.dup
  this.id = options["id"]
  this.type = options["type"]&.upcase
  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_secondsInteger

The amount of time it took for the learner to make the interaction, i.e. how long it took the learner to answer the question. In seconds.

Returns:

  • (Integer)

74
75
76
77
# File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 74

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