Class: ActiveLrs::Xapi::Statement
- Inherits:
-
#StatementBase
- Object
- ActiveLrs::Xapi::Statement
- Defined in:
- lib/active_lrs/xapi/statement.rb
Overview
Represents a full xAPI Statement.
A Statement captures a single learning experience or action. It consists of an actor (who performed the action), a verb (the action), and an object (the target of the action). Optionally, it may include result, context, timestamp, attachments, and other metadata.
Instance Attribute Summary collapse
-
#authority ⇒ Agent?
Authority responsible for the statement.
-
#id ⇒ String?
Optional UUID for the statement.
-
#raw_stored ⇒ String?
The original stored string from the xAPI statement.
-
#raw_xapi ⇒ Hash?
Raw xAPI payload from the LRS.
-
#stored ⇒ Time?
The timestamp when the xAPI statement was received by the LRS, parsed as a Time object.
-
#version ⇒ String?
XAPI version string.
-
#voided ⇒ Boolean
True if the statement has been voided.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ void
constructor
Initializes a new Statement.
-
#to_h ⇒ Hash{String => Object}
Converts the Statement into a hash suitable for sending to an LRS.
Constructor Details
#initialize(attributes = {}) ⇒ void
Initializes a new Statement.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/active_lrs/xapi/statement.rb', line 51 def initialize(attributes = {}) super(attributes) self.raw_xapi = attributes self.id = attributes["id"] if attributes["id"] self.stored = Time.parse(attributes["stored"]) if attributes["stored"] self.raw_stored = attributes["stored"] if attributes["stored"] self. = Xapi::Agent.new(attributes["authority"]) if attributes["authority"] self.version = attributes["version"] if attributes["version"] self.voided = attributes["voided"] if attributes["voided"] end |
Instance Attribute Details
#authority ⇒ Agent?
Returns Authority responsible for the statement.
28 29 30 |
# File 'lib/active_lrs/xapi/statement.rb', line 28 def @authority end |
#id ⇒ String?
Returns Optional UUID for the statement.
18 19 20 |
# File 'lib/active_lrs/xapi/statement.rb', line 18 def id @id end |
#raw_stored ⇒ String?
Returns The original stored string from the xAPI statement.
25 26 27 |
# File 'lib/active_lrs/xapi/statement.rb', line 25 def raw_stored @raw_stored end |
#raw_xapi ⇒ Hash?
Returns Raw xAPI payload from the LRS.
15 16 17 |
# File 'lib/active_lrs/xapi/statement.rb', line 15 def raw_xapi @raw_xapi end |
#stored ⇒ Time?
Returns The timestamp when the xAPI statement was received by the LRS, parsed as a Time object.
22 23 24 |
# File 'lib/active_lrs/xapi/statement.rb', line 22 def stored @stored end |
#version ⇒ String?
Returns xAPI version string.
31 32 33 |
# File 'lib/active_lrs/xapi/statement.rb', line 31 def version @version end |
#voided ⇒ Boolean
Returns True if the statement has been voided.
34 35 36 |
# File 'lib/active_lrs/xapi/statement.rb', line 34 def voided @voided end |
Instance Method Details
#to_h ⇒ Hash{String => Object}
Converts the Statement into a hash suitable for sending to an LRS.
82 83 84 85 86 87 88 89 90 |
# File 'lib/active_lrs/xapi/statement.rb', line 82 def to_h node = super node["id"] = id if id node["stored"] = raw_stored || stored.strftime("%FT%T%:z") if stored node["authority"] = .to_h if node["voided"] = voided if voided node["version"] = version.to_s if version node end |