pupilfirst_xapi 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pupilfirst_xapi/objects/course.rb +1 -0
- data/lib/pupilfirst_xapi/objects/target.rb +2 -3
- data/lib/pupilfirst_xapi/version.rb +1 -1
- data/spec/outbox_spec.rb +2 -2
- data/spec/statements/course_completed_spec.rb +5 -1
- data/spec/statements/course_registered_spec.rb +14 -3
- data/spec/statements/target_completed_spec.rb +8 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af22d07f8c93f261b7174d2e9e7c0718556931f7f09ec7e3efe91a20d6d6fa6
|
4
|
+
data.tar.gz: 5414db57b6f4f3b6851fc6c1c5938cbe918dab54cbdc3e41666e135fa788f6b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dbadb2c9cbbb1d501162bc3fd325aac8a9f2d44566a870942031fe7dba223292c4afe532a60a21a3eb2afa3393f9adb82277fb073ddb330c7cff8c6fb6482e0
|
7
|
+
data.tar.gz: 8710df83e5839915c2792edb71c9dde22bfb21c52e6aa1ca4b11641e645ee409e30c81011a8b27220d7c84fed0bc4cacf4f34977b1b4272d08aba9ca04d927b4
|
@@ -13,6 +13,7 @@ module PupilfirstXapi
|
|
13
13
|
if course.ends_at.present?
|
14
14
|
duration = ActiveSupport::Duration.build(course.ends_at - course.created_at).iso8601
|
15
15
|
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)
|
16
17
|
end
|
17
18
|
end.call
|
18
19
|
end
|
@@ -4,7 +4,6 @@ module PupilfirstXapi
|
|
4
4
|
def call(target, uri_for)
|
5
5
|
course = target.course
|
6
6
|
target_uri = uri_for.call(target)
|
7
|
-
course_uri = uri_for.call(course)
|
8
7
|
|
9
8
|
Builder.new(
|
10
9
|
id: target_uri,
|
@@ -12,8 +11,8 @@ module PupilfirstXapi
|
|
12
11
|
name: target.title,
|
13
12
|
description: target.description
|
14
13
|
).tap do |obj|
|
15
|
-
obj.with_extension('
|
16
|
-
obj.with_extension('
|
14
|
+
obj.with_extension('http://id.tincanapi.com/extension/host', Objects.course(course, uri_for).as_json)
|
15
|
+
obj.with_extension('http://id.tincanapi.com/extension/position', target.sort_index)
|
17
16
|
end.call
|
18
17
|
end
|
19
18
|
end
|
data/spec/outbox_spec.rb
CHANGED
@@ -4,8 +4,8 @@ module PupilfirstXapi
|
|
4
4
|
RSpec.describe Outbox do
|
5
5
|
let(:timestamp) { Time.now }
|
6
6
|
let(:john) { double(:john, name: 'John Doe', email: 'john@doe.com') }
|
7
|
-
let(:course) { double(:course, id: 32, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil) }
|
8
|
-
let(:target) { double(:target, title: '1st target', description: 'Seems easy', course: course) }
|
7
|
+
let(:course) { double(:course, id: 32, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil, targets: []) }
|
8
|
+
let(:target) { double(:target, title: '1st target', description: 'Seems easy', course: course, sort_index: 7) }
|
9
9
|
let(:good_one) { double(:timeline_event, target: target, passed?: true) }
|
10
10
|
let(:bad_one) { double(:timeline_event, target: target, passed?: false) }
|
11
11
|
|
@@ -5,7 +5,11 @@ module PupilfirstXapi
|
|
5
5
|
RSpec.describe CourseCompleted do
|
6
6
|
it do
|
7
7
|
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
8
|
-
course = double(:course, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil
|
8
|
+
course = double(:course, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil,
|
9
|
+
targets: [
|
10
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
11
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
12
|
+
])
|
9
13
|
data = {
|
10
14
|
course: { 456 => course },
|
11
15
|
user: { 123 => john },
|
@@ -5,7 +5,11 @@ module PupilfirstXapi
|
|
5
5
|
RSpec.describe CourseRegistered do
|
6
6
|
it do
|
7
7
|
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
8
|
-
course = double(:course, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil
|
8
|
+
course = double(:course, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil,
|
9
|
+
targets: [
|
10
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
11
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
12
|
+
])
|
9
13
|
data = {
|
10
14
|
course: { 456 => course },
|
11
15
|
user: { 123 => john },
|
@@ -34,7 +38,11 @@ module PupilfirstXapi
|
|
34
38
|
duration = ActiveSupport::Duration.build(ends_at - starts_at).iso8601
|
35
39
|
|
36
40
|
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
37
|
-
course = double(:course, name: 'Rails for Begginers', description: 'Seems easy', created_at: starts_at, ends_at: ends_at
|
41
|
+
course = double(:course, name: 'Rails for Begginers', description: 'Seems easy', created_at: starts_at, ends_at: ends_at,
|
42
|
+
targets: [
|
43
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
44
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
45
|
+
])
|
38
46
|
data = {
|
39
47
|
course: { 456 => course },
|
40
48
|
user: { 123 => john },
|
@@ -54,7 +62,10 @@ module PupilfirstXapi
|
|
54
62
|
expect(xapi.object.definition.type).to eq 'http://adlnet.gov/expapi/activities/product'
|
55
63
|
expect(xapi.object.definition.name).to eq({'en-US' => 'Rails for Begginers'})
|
56
64
|
expect(xapi.object.definition.description).to eq({'en-US' => 'Seems easy'})
|
57
|
-
expect(xapi.object.definition.extensions).to eq({
|
65
|
+
expect(xapi.object.definition.extensions).to eq({
|
66
|
+
"http://id.tincanapi.com/extension/planned-duration" => duration,
|
67
|
+
"http://id.tincanapi.com/extension/ending-position" => 2
|
68
|
+
})
|
58
69
|
end
|
59
70
|
end
|
60
71
|
end
|
@@ -4,8 +4,12 @@ module PupilfirstXapi
|
|
4
4
|
module Statements
|
5
5
|
RSpec.describe TargetCompleted do
|
6
6
|
it do
|
7
|
-
course = double(:course, id: 17, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil
|
8
|
-
|
7
|
+
course = double(:course, id: 17, name: 'Rails for Begginers', description: 'Seems easy', created_at: 1.week.ago, ends_at: nil,
|
8
|
+
targets: [
|
9
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
10
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
11
|
+
])
|
12
|
+
target = double(:target, title: '1st target', course: course, description: 'Seems easy', sort_index: 5)
|
9
13
|
submission = double(:timeline_event, target: target, passed?: true)
|
10
14
|
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
11
15
|
data = {
|
@@ -27,14 +31,11 @@ module PupilfirstXapi
|
|
27
31
|
expect(xapi.object.definition.type).to eq 'http://activitystrea.ms/schema/1.0/task'
|
28
32
|
expect(xapi.object.definition.name).to eq({'en-US' => '1st target'})
|
29
33
|
expect(xapi.object.definition.description).to eq({'en-US' => 'Seems easy'})
|
30
|
-
expect(xapi.object.definition.extensions).to eq
|
31
|
-
'course_id'=>'course-1',
|
32
|
-
'course_name'=>'Rails for Begginers'
|
33
|
-
})
|
34
|
+
expect(xapi.object.definition.extensions['http://id.tincanapi.com/extension/host']['id']).to eq 'course-1'
|
34
35
|
end
|
35
36
|
|
36
37
|
it 'no-op when submission is not passed' do
|
37
|
-
target = double(:target, title: '1st target', description: 'Seems easy')
|
38
|
+
target = double(:target, title: '1st target', description: 'Seems easy', sort_index: 3)
|
38
39
|
submission = double(:timeline_event, target: target, passed?: false)
|
39
40
|
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
40
41
|
data = {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pupilfirst_xapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GrowthTribe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|