Class: ScormEngine::Models::RegistrationRuntimeInteraction
- Defined in:
- lib/scorm_engine/models/registration_runtime_interaction.rb
Instance Attribute Summary collapse
- 
  
    
      #correct_responses  ⇒ Array<String> 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The correct responses to this interaction. 
- 
  
    
      #description  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    A textual description of the interaction. 
- 
  
    
      #id  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The interaction ID. 
- 
  
    
      #latency  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    Iso8601TimeSpan representing the amount of time it took for the learner to make the interaction, i.e. 
- 
  
    
      #learner_response  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The correct responses to this interaction. 
- #result ⇒ String
- 
  
    
      #timestamp  ⇒ Time 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The timestamp of when the interaction was reported, in the format provided by the SCO. 
- 
  
    
      #type  ⇒ String 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The interaction type. 
- 
  
    
      #weighting  ⇒ Float 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    The weight this interaction carries relative to the other interactions in the SCO. 
Class Method Summary collapse
- .get_description_from_api(options) ⇒ Object
- .get_learner_response_from_api(options) ⇒ Object
- .get_timestamp_from_api(options) ⇒ Object
- .new_from_api(options = {}) ⇒ Object
Instance Method Summary collapse
- 
  
    
      #latency_in_seconds  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    The amount of time it took for the learner to make the interaction, i.e. 
Methods inherited from Base
Instance Attribute Details
#correct_responses ⇒ Array<String>
The correct responses to this interaction.
| 28 29 30 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 28 def correct_responses @correct_responses end | 
#description ⇒ String
A textual description of the interaction.
| 17 18 19 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 17 def description @description end | 
#id ⇒ String
The interaction ID.
| 7 8 9 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 7 def id @id end | 
#latency ⇒ String
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.
| 51 52 53 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 51 def latency @latency end | 
#learner_response ⇒ String
The correct responses to this interaction.
| 33 34 35 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 33 def learner_response @learner_response end | 
#result ⇒ String
| 38 39 40 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 38 def result @result end | 
#timestamp ⇒ Time
The timestamp of when the interaction was reported, in the format provided by the SCO.
| 23 24 25 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 23 def @timestamp end | 
#type ⇒ String
The interaction type.
| 12 13 14 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 12 def type @type end | 
#weighting ⇒ Float
The weight this interaction carries relative to the other interactions in the SCO.
| 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() description = ["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() ["learnerResponse"].to_s.gsub(/\s+/, " ").strip end | 
.get_timestamp_from_api(options) ⇒ Object
| 89 90 91 92 93 94 95 | # File 'lib/scorm_engine/models/registration_runtime_interaction.rb', line 89 def self.() # Handle both API v1 (timestampUtc) and API v2 (timestamp) key names = ["timestamp"] || ["timestampUtc"] return if .nil? || .empty? Time.parse() 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( = {}) this = new this. = .dup this.id = ["id"] this.type = ["type"]&.upcase this.description = get_description_from_api() this. = () this.correct_responses = ["correctResponses"] this.learner_response = get_learner_response_from_api() this.result = ["result"] this.weighting = ["weighting"].to_f this.latency = ["latency"] this end | 
Instance Method Details
#latency_in_seconds ⇒ Integer
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.
| 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 |