pupilfirst_xapi 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pupilfirst_xapi.rb +2 -0
- data/lib/pupilfirst_xapi/lrs.rb +24 -0
- data/lib/pupilfirst_xapi/outbox.rb +2 -12
- data/lib/pupilfirst_xapi/version.rb +1 -1
- data/spec/spec_helper.rb +3 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6435e3040cef3863e99115b8a474bf193c05484c7c9048701425827b27353188
|
4
|
+
data.tar.gz: 412e2b47cc25daa790d214d111d8a7bf4645050dd2294c110859129b695bbee1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c44119ab5421640425e20e55629d7281e68d284f72c9ccceaa5ee66c1e50f35776aad758a8f5a7f39d5b72215ba5f00185ad64385f23617cecc70d0aea66476
|
7
|
+
data.tar.gz: 776ae2649f8d242ad26a32b798373186df902855079a75668d50a3e9c6af25536abfc9e827e2ca5af0a4e429fbfb5309edcb7ac5910bbce624da641350b6d950
|
data/lib/pupilfirst_xapi.rb
CHANGED
@@ -2,6 +2,7 @@ require "action_controller/railtie"
|
|
2
2
|
require "active_job/railtie"
|
3
3
|
require "growthtribe_xapi"
|
4
4
|
require "pupilfirst_xapi/version"
|
5
|
+
require "pupilfirst_xapi/lrs"
|
5
6
|
require "pupilfirst_xapi/outbox"
|
6
7
|
require "pupilfirst_xapi/actors"
|
7
8
|
require "pupilfirst_xapi/objects"
|
@@ -11,6 +12,7 @@ require "pupilfirst_xapi/statements"
|
|
11
12
|
module PupilfirstXapi
|
12
13
|
mattr_accessor :uri_for
|
13
14
|
mattr_accessor :repository
|
15
|
+
mattr_accessor :lrs
|
14
16
|
|
15
17
|
Statements.subscribe do |event_type|
|
16
18
|
ActiveSupport::Notifications.subscribe("#{event_type}.pupilfirst") do |_name, _start, finish, _id, payload|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'xapi'
|
2
|
+
|
3
|
+
module PupilfirstXapi
|
4
|
+
class Lrs
|
5
|
+
def initialize(
|
6
|
+
end_point: ENV['LRS_ENDPOINT'],
|
7
|
+
key: ENV['LRS_KEY'],
|
8
|
+
secret: ENV['LRS_SECRET']
|
9
|
+
)
|
10
|
+
@lrs = end_point && key && secret &&
|
11
|
+
Xapi.create_remote_lrs(
|
12
|
+
end_point: end_point,
|
13
|
+
user_name: key,
|
14
|
+
password: secret
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(statement)
|
19
|
+
return unless statement && @lrs
|
20
|
+
|
21
|
+
Xapi.post_statement(remote_lrs: @lrs, statement: statement)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "active_job"
|
2
|
-
require 'xapi'
|
3
2
|
|
4
3
|
module PupilfirstXapi
|
5
4
|
class Outbox
|
@@ -14,19 +13,11 @@ module PupilfirstXapi
|
|
14
13
|
|
15
14
|
def outbox
|
16
15
|
Outbox.new(
|
17
|
-
lrs:
|
16
|
+
lrs: PupilfirstXapi.lrs || PupilfirstXapi::Lrs.new,
|
18
17
|
repository: PupilfirstXapi.repository,
|
19
18
|
uri_for: PupilfirstXapi.uri_for
|
20
19
|
)
|
21
20
|
end
|
22
|
-
|
23
|
-
def remote_lrs
|
24
|
-
Xapi.create_remote_lrs(
|
25
|
-
end_point: ENV['LRS_ENDPOINT'],
|
26
|
-
user_name: ENV['LRS_KEY'],
|
27
|
-
password: ENV['LRS_SECRET']
|
28
|
-
)
|
29
|
-
end
|
30
21
|
end
|
31
22
|
|
32
23
|
class << self
|
@@ -42,8 +33,7 @@ module PupilfirstXapi
|
|
42
33
|
end
|
43
34
|
|
44
35
|
def call(**payload)
|
45
|
-
|
46
|
-
Xapi.post_statement(remote_lrs: @lrs, statement: statement) if statement
|
36
|
+
@lrs.call(statement_for(**payload))
|
47
37
|
end
|
48
38
|
|
49
39
|
private
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pupilfirst_xapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GrowthTribe
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- Rakefile
|
99
99
|
- lib/pupilfirst_xapi.rb
|
100
100
|
- lib/pupilfirst_xapi/actors.rb
|
101
|
+
- lib/pupilfirst_xapi/lrs.rb
|
101
102
|
- lib/pupilfirst_xapi/objects.rb
|
102
103
|
- lib/pupilfirst_xapi/objects/builder.rb
|
103
104
|
- lib/pupilfirst_xapi/objects/course.rb
|