class ScormEngine::Models::RegistrationRuntimeInteraction

Attributes

correct_responses[RW]

@attr The correct responses to this interaction. @return [Array<String>]

description[RW]

@attr A textual description of the interaction. @return [String]

id[RW]

@attr The interaction ID. @return [String]

latency[RW]

@attr 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. @return [String]

learner_response[RW]

@attr The correct responses to this interaction. @return [String]

result[RW]

@attr

@return [String]

timestamp[RW]

@attr The timestamp of when the interaction was reported, in the format provided by the SCO. @return [Time]

type[RW]

@attr The interaction type. @return [String] (Undefined, TrueFalse, Choice, FillIn, LongFillIn, Likert, Matching, Performance, Sequencing, Numeric, Other)

weighting[RW]

@attr The weight this interaction carries relative to the other interactions in the SCO. @return [Float]

Public Class Methods

get_description_from_api(options) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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 = {}) click to toggle source
# 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

Public Instance Methods

latency_in_seconds() click to toggle source

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.

@return [Integer]

# 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