pupilfirst_xapi 0.2.2 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4c1f6e893b9a58bb193b6ddcbdf806ae9c341c3ff5527f3a2ba6a528cda7a05
4
- data.tar.gz: 87858bf6e6a1b2beaa9bc8a85f9e7bc22424788a8011bc1a476f96fcd52d8370
3
+ metadata.gz: 9af22d07f8c93f261b7174d2e9e7c0718556931f7f09ec7e3efe91a20d6d6fa6
4
+ data.tar.gz: 5414db57b6f4f3b6851fc6c1c5938cbe918dab54cbdc3e41666e135fa788f6b3
5
5
  SHA512:
6
- metadata.gz: a9a7da4741a9151c9251e7f9a31dc149d303a213fadb94cbdccd9a65578fb21bc7adfadfec168f30d6dbbf614fdb372aeb8ac2a967547628d427c046c0c3d944
7
- data.tar.gz: 606c6d2f23faccbc6d30ee80e49b912148a862cc9855ea10814e1d64cd18300ece70469daea7f72093d5dad1cc176a1ddb2b5818a850bb9de9e88ab66982356c
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('course_id', course_uri)
16
- obj.with_extension('course_name', course.name)
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
@@ -1,3 +1,3 @@
1
1
  module PupilfirstXapi
2
- VERSION = '0.2.2'
2
+ VERSION = '0.3.1'
3
3
  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({"http://id.tincanapi.com/extension/planned-duration" => duration})
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
- target = double(:target, title: '1st target', course: course, description: 'Seems easy')
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.2.2
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-13 00:00:00.000000000 Z
11
+ date: 2021-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails