pupilfirst_xapi 0.3.1 → 0.3.5
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/objects.rb +11 -0
- data/lib/pupilfirst_xapi/objects/course.rb +1 -1
- data/lib/pupilfirst_xapi/objects/video_end.rb +16 -0
- data/lib/pupilfirst_xapi/objects/video_start.rb +16 -0
- data/lib/pupilfirst_xapi/statements.rb +4 -0
- data/lib/pupilfirst_xapi/statements/video_ended.rb +20 -0
- data/lib/pupilfirst_xapi/statements/video_started.rb +20 -0
- data/lib/pupilfirst_xapi/verbs.rb +2 -0
- data/lib/pupilfirst_xapi/version.rb +1 -1
- data/spec/integration_spec.rb +15 -7
- data/spec/statements/course_registered_spec.rb +3 -1
- metadata +16 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f5c38a8fbf57be11cda1429b9cffc1ed6d818ca11a69d220305a2cd0e954125
|
4
|
+
data.tar.gz: c018dae18cd439930c6d70eba6fb60bafe8014d01a5ce2ae5be6ca3d5556f88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3d62b03c85f3610a50d7cb3aa0bbbed2fad9ad4d6c3c9aa67fac48f972a64e9a08fdc6d59cc38a7b75e2400efecd2f555d2d6d960c7c889be617432ea347800
|
7
|
+
data.tar.gz: e525ac790f096b0b70a82727901cc88bacee1aeff9b44ecbca7e227e7d0e52bb2aeb39a3007af0b22b3345f05c54204d930523ec9f374f8d8fdde4650ecc246e
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative 'objects/builder'
|
2
2
|
require_relative 'objects/course'
|
3
3
|
require_relative 'objects/target'
|
4
|
+
require_relative 'objects/video_start'
|
5
|
+
require_relative 'objects/video_end'
|
4
6
|
|
5
7
|
module PupilfirstXapi
|
6
8
|
module Objects
|
@@ -11,5 +13,14 @@ module PupilfirstXapi
|
|
11
13
|
def self.target(target, uri_for)
|
12
14
|
Target.new.call(target, uri_for)
|
13
15
|
end
|
16
|
+
|
17
|
+
def self.video_start(target, uri_for)
|
18
|
+
VideoStart.new.call(target, uri_for)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def self.video_end(target, uri_for)
|
23
|
+
VideoEnd.new.call(target, uri_for)
|
24
|
+
end
|
14
25
|
end
|
15
26
|
end
|
@@ -10,10 +10,10 @@ module PupilfirstXapi
|
|
10
10
|
name: course.name,
|
11
11
|
description: course.description
|
12
12
|
).tap do |obj|
|
13
|
+
obj.with_extension('http://id.tincanapi.com/extension/ending-position', course.targets.count)
|
13
14
|
if course.ends_at.present?
|
14
15
|
duration = ActiveSupport::Duration.build(course.ends_at - course.created_at).iso8601
|
15
16
|
obj.with_extension("http://id.tincanapi.com/extension/planned-duration", duration)
|
16
|
-
obj.with_extension('http://id.tincanapi.com/extension/ending-position', course.targets.count)
|
17
17
|
end
|
18
18
|
end.call
|
19
19
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Objects
|
3
|
+
class VideoEnd
|
4
|
+
def call(target, uri_for)
|
5
|
+
target_uri = uri_for.call(target)
|
6
|
+
|
7
|
+
Builder.new(
|
8
|
+
id: target_uri,
|
9
|
+
type: "http://activitystrea.ms/schema/1.0/event",
|
10
|
+
name: "video in #{target.title}",
|
11
|
+
description: target.description
|
12
|
+
).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Objects
|
3
|
+
class VideoStart
|
4
|
+
def call(target, uri_for)
|
5
|
+
target_uri = uri_for.call(target)
|
6
|
+
|
7
|
+
Builder.new(
|
8
|
+
id: target_uri,
|
9
|
+
type: "http://activitystrea.ms/schema/1.0/event",
|
10
|
+
name: "video in #{target.title}",
|
11
|
+
description: target.description
|
12
|
+
).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require "pupilfirst_xapi/statements/course_completed"
|
2
2
|
require "pupilfirst_xapi/statements/course_registered"
|
3
3
|
require "pupilfirst_xapi/statements/target_completed"
|
4
|
+
require "pupilfirst_xapi/statements/video_started"
|
5
|
+
require "pupilfirst_xapi/statements/video_ended"
|
4
6
|
|
5
7
|
module PupilfirstXapi
|
6
8
|
module Statements
|
@@ -17,6 +19,8 @@ module PupilfirstXapi
|
|
17
19
|
:student_added => CourseRegistered,
|
18
20
|
:submission_graded => TargetCompleted,
|
19
21
|
:submission_automatically_verified => TargetCompleted,
|
22
|
+
:video_started => VideoStarted,
|
23
|
+
:video_ended => VideoEnded
|
20
24
|
}
|
21
25
|
end
|
22
26
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Statements
|
3
|
+
class VideoEnded
|
4
|
+
def initialize(repository, uri_for)
|
5
|
+
@repository = repository
|
6
|
+
@uri_for = uri_for
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(actor_id:, resource_id:)
|
10
|
+
actor = @repository.call(:user, actor_id)
|
11
|
+
target = @repository.call(:target, resource_id)
|
12
|
+
Xapi.create_statement(
|
13
|
+
actor: Actors.agent(actor),
|
14
|
+
verb: Verbs::VIDEO_ENDED,
|
15
|
+
object: Objects.video_end(target, @uri_for)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Statements
|
3
|
+
class VideoStarted
|
4
|
+
def initialize(repository, uri_for)
|
5
|
+
@repository = repository
|
6
|
+
@uri_for = uri_for
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(actor_id:, resource_id:)
|
10
|
+
actor = @repository.call(:user, actor_id)
|
11
|
+
target = @repository.call(:target, resource_id)
|
12
|
+
Xapi.create_statement(
|
13
|
+
actor: Actors.agent(actor),
|
14
|
+
verb: Verbs::VIDEO_STARTED,
|
15
|
+
object: Objects.video_start(target, @uri_for)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,5 +3,7 @@ module PupilfirstXapi
|
|
3
3
|
COMPLETED = Xapi.create_verb(id: 'http://adlnet.gov/expapi/verbs/completed', name: 'completed')
|
4
4
|
COMPLETED_ASSIGNMENT = Xapi.create_verb(id: 'https://w3id.org/xapi/dod-isd/verbs/completed-assignment', name: 'completed assignment')
|
5
5
|
REGISTERED = Xapi.create_verb(id: 'http://adlnet.gov/expapi/verbs/registered', name: 'registered')
|
6
|
+
VIDEO_STARTED = Xapi.create_verb(id: 'http://activitystrea.ms/schema/1.0/start', name: 'start')
|
7
|
+
VIDEO_ENDED = Xapi.create_verb(id: 'http://activitystrea.ms/schema/1.0/consume', name: 'consumed')
|
6
8
|
end
|
7
9
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -15,7 +15,12 @@ RSpec.describe "#xapi", type: :job, perform_jobs: true do
|
|
15
15
|
description: 'These guides are designed to make you immediately productive with Rails',
|
16
16
|
created_at: Time.new(2021,01,01),
|
17
17
|
ends_at: nil,
|
18
|
-
uri: 'https://guides.rubyonrails.org/'
|
18
|
+
uri: 'https://guides.rubyonrails.org/',
|
19
|
+
targets: [
|
20
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
21
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
22
|
+
]
|
23
|
+
)
|
19
24
|
}
|
20
25
|
let(:getting_started) {
|
21
26
|
double(:target,
|
@@ -77,6 +82,7 @@ RSpec.describe "#xapi", type: :job, perform_jobs: true do
|
|
77
82
|
name: {'en-US' => 'Ruby on Rails Guides'},
|
78
83
|
description: {'en-US' => 'These guides are designed to make you immediately productive with Rails'},
|
79
84
|
type: 'http://adlnet.gov/expapi/activities/product',
|
85
|
+
extensions: {"http://id.tincanapi.com/extension/ending-position"=>2}
|
80
86
|
},
|
81
87
|
},
|
82
88
|
timestamp: timestamp.iso8601,
|
@@ -102,12 +108,14 @@ RSpec.describe "#xapi", type: :job, perform_jobs: true do
|
|
102
108
|
resource_id: ror_guides.id,
|
103
109
|
actor_id: john.id,
|
104
110
|
)
|
105
|
-
expect(PupilfirstXapi::Outbox::Job).to have_been_performed.with(
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
+
expect(PupilfirstXapi::Outbox::Job).to have_been_performed.with(
|
112
|
+
hash_including({
|
113
|
+
event_type: :course_completed,
|
114
|
+
actor_id: 123,
|
115
|
+
resource_id: 1234,
|
116
|
+
})
|
117
|
+
)
|
118
|
+
|
111
119
|
expect(request).to have_been_requested
|
112
120
|
end
|
113
121
|
end
|
@@ -29,7 +29,9 @@ module PupilfirstXapi
|
|
29
29
|
expect(xapi.object.definition.type).to eq 'http://adlnet.gov/expapi/activities/product'
|
30
30
|
expect(xapi.object.definition.name).to eq({'en-US' => 'Rails for Begginers'})
|
31
31
|
expect(xapi.object.definition.description).to eq({'en-US' => 'Seems easy'})
|
32
|
-
expect(xapi.object.definition.extensions).to eq
|
32
|
+
expect(xapi.object.definition.extensions).to eq ({
|
33
|
+
"http://id.tincanapi.com/extension/ending-position" => 2
|
34
|
+
})
|
33
35
|
end
|
34
36
|
|
35
37
|
it do
|
metadata
CHANGED
@@ -1,22 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pupilfirst_xapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GrowthTribe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 6.0.3
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 6.0.3.4
|
@@ -24,9 +21,6 @@ dependencies:
|
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 6.0.3
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
26
|
version: 6.0.3.4
|
@@ -86,7 +80,7 @@ dependencies:
|
|
86
80
|
- - ">="
|
87
81
|
- !ruby/object:Gem::Version
|
88
82
|
version: '0'
|
89
|
-
description:
|
83
|
+
description:
|
90
84
|
email:
|
91
85
|
- devs@growthtribe.io
|
92
86
|
executables: []
|
@@ -103,11 +97,15 @@ files:
|
|
103
97
|
- lib/pupilfirst_xapi/objects/builder.rb
|
104
98
|
- lib/pupilfirst_xapi/objects/course.rb
|
105
99
|
- lib/pupilfirst_xapi/objects/target.rb
|
100
|
+
- lib/pupilfirst_xapi/objects/video_end.rb
|
101
|
+
- lib/pupilfirst_xapi/objects/video_start.rb
|
106
102
|
- lib/pupilfirst_xapi/outbox.rb
|
107
103
|
- lib/pupilfirst_xapi/statements.rb
|
108
104
|
- lib/pupilfirst_xapi/statements/course_completed.rb
|
109
105
|
- lib/pupilfirst_xapi/statements/course_registered.rb
|
110
106
|
- lib/pupilfirst_xapi/statements/target_completed.rb
|
107
|
+
- lib/pupilfirst_xapi/statements/video_ended.rb
|
108
|
+
- lib/pupilfirst_xapi/statements/video_started.rb
|
111
109
|
- lib/pupilfirst_xapi/verbs.rb
|
112
110
|
- lib/pupilfirst_xapi/version.rb
|
113
111
|
- spec/integration_spec.rb
|
@@ -126,7 +124,7 @@ metadata:
|
|
126
124
|
homepage_uri: https://github.com/growthtribeacademy/pupilfirst-xapi
|
127
125
|
source_code_uri: https://github.com/growthtribeacademy/pupilfirst-xapi/pupilfirst_xapi
|
128
126
|
changelog_uri: https://github.com/growthtribeacademy/pupilfirst-xapi/pupilfirst_xapi/CHANGELOG.md
|
129
|
-
post_install_message:
|
127
|
+
post_install_message:
|
130
128
|
rdoc_options: []
|
131
129
|
require_paths:
|
132
130
|
- lib
|
@@ -141,17 +139,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
139
|
- !ruby/object:Gem::Version
|
142
140
|
version: '0'
|
143
141
|
requirements: []
|
144
|
-
rubygems_version: 3.
|
145
|
-
signing_key:
|
142
|
+
rubygems_version: 3.1.6
|
143
|
+
signing_key:
|
146
144
|
specification_version: 4
|
147
145
|
summary: XAPI statements generator and publisher to LRS for Pupilfirst
|
148
146
|
test_files:
|
149
|
-
- spec/integration_spec.rb
|
150
147
|
- spec/objects/builder_spec.rb
|
151
|
-
- spec/outbox_job_spec.rb
|
152
|
-
- spec/outbox_spec.rb
|
153
148
|
- spec/rails_helper.rb
|
154
|
-
- spec/
|
149
|
+
- spec/statements/target_completed_spec.rb
|
155
150
|
- spec/statements/course_completed_spec.rb
|
156
151
|
- spec/statements/course_registered_spec.rb
|
157
|
-
- spec/
|
152
|
+
- spec/spec_helper.rb
|
153
|
+
- spec/outbox_spec.rb
|
154
|
+
- spec/integration_spec.rb
|
155
|
+
- spec/outbox_job_spec.rb
|