Class: RailsXapi::Statement

Inherits:
ApplicationRecord show all
Defined in:
app/models/rails_xapi/statement.rb

Overview

Statements are the evidence for any sort of experience or event which is to be tracked in xAPI. See: github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#20-statements

Instance Method Summary collapse

Instance Method Details

#as_jsonObject



20
21
22
23
24
25
26
27
28
29
# File 'app/models/rails_xapi/statement.rb', line 20

def as_json
  {
    actor: actor.as_json,
    verb: verb.as_json,
    object: object.as_json
  }.tap do |hash|
    hash[:result] = result.as_json if result.present?
    hash[:context] = context.as_json if context.present?
  end
end