pupilfirst_xapi 0.3.2 → 0.3.8
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.rb +30 -0
- data/lib/pupilfirst_xapi/objects/answer.rb +18 -0
- data/lib/pupilfirst_xapi/objects/survey.rb +16 -0
- data/lib/pupilfirst_xapi/objects/survey_end.rb +18 -0
- data/lib/pupilfirst_xapi/objects/survey_start.rb +18 -0
- 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 +12 -0
- data/lib/pupilfirst_xapi/statements/capability_result_viewed.rb +20 -0
- data/lib/pupilfirst_xapi/statements/question_answered.rb +21 -0
- data/lib/pupilfirst_xapi/statements/survey_ended.rb +21 -0
- data/lib/pupilfirst_xapi/statements/survey_started.rb +21 -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 +5 -0
- data/lib/pupilfirst_xapi/version.rb +1 -1
- data/spec/integration_spec.rb +8 -6
- data/spec/statements/capability_result_viewed_spec.rb +43 -0
- data/spec/statements/question_answered_spec.rb +50 -0
- data/spec/statements/survey_ended_spec.rb +45 -0
- data/spec/statements/survey_started_spec.rb +45 -0
- metadata +27 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9671a7b657ac2a6a5db9b4988b50f069d24bde84e08f722e17c9e510f0990f88
|
4
|
+
data.tar.gz: 1eb93f047df91dc644ee65372d6a163d732c1d64e3763189de793fdd60ccbe2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69254b39c819d27d967c005fb6a91f648527cd78abadd17a2ae8b1e51294d56d2a1e9392d58671b2eb617511cfe5884a2565e73ca26f35304c0f68463c814db1
|
7
|
+
data.tar.gz: 9bf904d914c4ad290be96ca7a17fbae1d0cf0aec40f0dfe50e31201291c86942741d010b2cc17c3a103303aa6c776ceb4f2a7f5d550026b49b12b5b4b6f40cf6
|
@@ -1,6 +1,12 @@
|
|
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'
|
6
|
+
require_relative 'objects/survey_start'
|
7
|
+
require_relative 'objects/survey_end'
|
8
|
+
require_relative 'objects/survey'
|
9
|
+
require_relative 'objects/answer'
|
4
10
|
|
5
11
|
module PupilfirstXapi
|
6
12
|
module Objects
|
@@ -11,5 +17,29 @@ module PupilfirstXapi
|
|
11
17
|
def self.target(target, uri_for)
|
12
18
|
Target.new.call(target, uri_for)
|
13
19
|
end
|
20
|
+
|
21
|
+
def self.video_start(target, uri_for)
|
22
|
+
VideoStart.new.call(target, uri_for)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.video_end(target, uri_for)
|
26
|
+
VideoEnd.new.call(target, uri_for)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.survey_start(survey, uri_for)
|
30
|
+
SurveyStart.new.call(survey, uri_for)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.survey_end(survey, uri_for)
|
34
|
+
SurveyEnd.new.call(survey, uri_for)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.capability_result_viewed(survey, uri_for)
|
38
|
+
Survey.new.call(survey, uri_for)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.answer(question, uri_for)
|
42
|
+
Answer.new.call(question, uri_for)
|
43
|
+
end
|
14
44
|
end
|
15
45
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Objects
|
3
|
+
class Answer
|
4
|
+
def call(answer, uri_for)
|
5
|
+
target_uri = uri_for.call(answer)
|
6
|
+
|
7
|
+
Builder.new(
|
8
|
+
id: target_uri,
|
9
|
+
type: 'http://adlnet.gov/expapi/activities/assessment',
|
10
|
+
name: answer.question.description,
|
11
|
+
description: answer.question.description
|
12
|
+
).with_extension('http://adlnet.gov/expapi/activities/question', answer.question.description)
|
13
|
+
.with_extension('http://adlnet.gov/expapi/activities/answer', answer.content || answer.alternatives.as_json)
|
14
|
+
.call
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Objects
|
3
|
+
class Survey
|
4
|
+
def call(survey, uri_for)
|
5
|
+
target_uri = uri_for.call(survey)
|
6
|
+
|
7
|
+
Builder.new(
|
8
|
+
id: target_uri,
|
9
|
+
type: 'http://id.tincanapi.com/activitytype/survey',
|
10
|
+
name: survey.name,
|
11
|
+
description: survey.external_name
|
12
|
+
).call
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Objects
|
3
|
+
class SurveyEnd
|
4
|
+
def call(survey, uri_for)
|
5
|
+
target_uri = uri_for.call(survey)
|
6
|
+
|
7
|
+
Builder.new(
|
8
|
+
id: target_uri,
|
9
|
+
type: 'http://adlnet.gov/expapi/activities/assessment',
|
10
|
+
name: survey.name,
|
11
|
+
description: survey.external_name
|
12
|
+
).with_extension(
|
13
|
+
'http://id.tincanapi.com/extension/target', survey.slug
|
14
|
+
).call
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Objects
|
3
|
+
class SurveyStart
|
4
|
+
def call(survey, uri_for)
|
5
|
+
target_uri = uri_for.call(survey)
|
6
|
+
|
7
|
+
Builder.new(
|
8
|
+
id: target_uri,
|
9
|
+
type: 'http://adlnet.gov/expapi/activities/assessment',
|
10
|
+
name: survey.name,
|
11
|
+
description: survey.external_name
|
12
|
+
).with_extension(
|
13
|
+
'http://id.tincanapi.com/extension/target', survey.slug
|
14
|
+
).call
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
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,12 @@
|
|
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"
|
6
|
+
require "pupilfirst_xapi/statements/survey_started"
|
7
|
+
require "pupilfirst_xapi/statements/survey_ended"
|
8
|
+
require "pupilfirst_xapi/statements/capability_result_viewed"
|
9
|
+
require "pupilfirst_xapi/statements/question_answered"
|
4
10
|
|
5
11
|
module PupilfirstXapi
|
6
12
|
module Statements
|
@@ -17,6 +23,12 @@ module PupilfirstXapi
|
|
17
23
|
:student_added => CourseRegistered,
|
18
24
|
:submission_graded => TargetCompleted,
|
19
25
|
:submission_automatically_verified => TargetCompleted,
|
26
|
+
:video_started => VideoStarted,
|
27
|
+
:video_ended => VideoEnded,
|
28
|
+
:survey_started => SurveyStarted,
|
29
|
+
:survey_ended => SurveyEnded,
|
30
|
+
:capability_result_viewed => CapabilityResultViewed,
|
31
|
+
:question_answered => QuestionAnswered
|
20
32
|
}
|
21
33
|
end
|
22
34
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Statements
|
3
|
+
class CapabilityResultViewed
|
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
|
+
survey = @repository.call(:survey, resource_id)
|
12
|
+
Xapi.create_statement(
|
13
|
+
actor: Actors.agent(actor),
|
14
|
+
verb: Verbs::VIEWED,
|
15
|
+
object: Objects.capability_result_viewed(survey, @uri_for)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Statements
|
3
|
+
class QuestionAnswered
|
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
|
+
answer = @repository.call(:answer, resource_id)
|
12
|
+
|
13
|
+
Xapi.create_statement(
|
14
|
+
actor: Actors.agent(actor),
|
15
|
+
verb: Verbs::ANSWERED,
|
16
|
+
object: Objects.answer(answer, @uri_for)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Statements
|
3
|
+
class SurveyEnded
|
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
|
+
survey = @repository.call(:survey, resource_id)
|
12
|
+
|
13
|
+
Xapi.create_statement(
|
14
|
+
actor: Actors.agent(actor),
|
15
|
+
verb: Verbs::COMPLETED,
|
16
|
+
object: Objects.survey_end(survey, @uri_for)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PupilfirstXapi
|
2
|
+
module Statements
|
3
|
+
class SurveyStarted
|
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
|
+
survey = @repository.call(:survey, resource_id)
|
12
|
+
|
13
|
+
Xapi.create_statement(
|
14
|
+
actor: Actors.agent(actor),
|
15
|
+
verb: Verbs::STARTED,
|
16
|
+
object: Objects.survey_start(survey, @uri_for)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
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,10 @@ 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')
|
8
|
+
STARTED = Xapi.create_verb(id: 'http://adlnet.gov/expapi/verbs/initialized', name: 'initialized')
|
9
|
+
VIEWED = Xapi.create_verb(id: 'http://id.tincanapi.com/verb/viewed', name: 'viewed')
|
10
|
+
ANSWERED = Xapi.create_verb(id: 'https://w3id.org/xapi/dod-isd/verbs/answered', name: 'answered')
|
6
11
|
end
|
7
12
|
end
|
data/spec/integration_spec.rb
CHANGED
@@ -108,12 +108,14 @@ RSpec.describe "#xapi", type: :job, perform_jobs: true do
|
|
108
108
|
resource_id: ror_guides.id,
|
109
109
|
actor_id: john.id,
|
110
110
|
)
|
111
|
-
expect(PupilfirstXapi::Outbox::Job).to have_been_performed.with(
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
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
|
+
|
117
119
|
expect(request).to have_been_requested
|
118
120
|
end
|
119
121
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module PupilfirstXapi
|
4
|
+
module Statements
|
5
|
+
RSpec.describe CapabilityResultViewed do
|
6
|
+
it do
|
7
|
+
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
8
|
+
survey = double(
|
9
|
+
:survey,
|
10
|
+
name: 'Rails for Beginners',
|
11
|
+
external_name: 'Seems easy',
|
12
|
+
created_at: 1.week.ago,
|
13
|
+
ends_at: nil,
|
14
|
+
targets: [
|
15
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
16
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
17
|
+
]
|
18
|
+
)
|
19
|
+
|
20
|
+
data = {
|
21
|
+
survey: { 456 => survey },
|
22
|
+
user: { 123 => john }
|
23
|
+
}
|
24
|
+
|
25
|
+
repository = ->(klass, resource_id) { data.dig(klass, resource_id) }
|
26
|
+
uri_for = ->(obj) { obj == survey ? 'rails-for-begginers' : nil }
|
27
|
+
|
28
|
+
xapi = CapabilityResultViewed.new(repository, uri_for).call(actor_id: 123, resource_id: 456)
|
29
|
+
|
30
|
+
expect(xapi).to be_a Xapi::Statement
|
31
|
+
expect_actor(xapi.actor, name: 'John Doe', email: 'john@doe.com')
|
32
|
+
expect(xapi.verb).to eq Verbs::VIEWED
|
33
|
+
|
34
|
+
expect(xapi.object).to be_a Xapi::Activity
|
35
|
+
expect(xapi.object.object_type).to eq 'Activity'
|
36
|
+
expect(xapi.object.id).to eq 'rails-for-begginers'
|
37
|
+
expect(xapi.object.definition.type).to eq 'http://id.tincanapi.com/activitytype/survey'
|
38
|
+
expect(xapi.object.definition.name).to eq({'en-US' => 'Rails for Beginners'})
|
39
|
+
expect(xapi.object.definition.description).to eq({'en-US' => 'Seems easy'})
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module PupilfirstXapi
|
4
|
+
module Statements
|
5
|
+
RSpec.describe QuestionAnswered do
|
6
|
+
it do
|
7
|
+
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
8
|
+
question = double(:question, description: "What is your favorite animal?")
|
9
|
+
answer = double(
|
10
|
+
:answer,
|
11
|
+
answer_id: 42,
|
12
|
+
question_id: 4,
|
13
|
+
question: question,
|
14
|
+
alternative_id: nil,
|
15
|
+
survey_group_id:7,
|
16
|
+
user_external_id: 'a6ad5226-7d8b-4108-9cc9-f0821de150f5',
|
17
|
+
answer_type: 'open_ended',
|
18
|
+
content: 'Content',
|
19
|
+
score: 0.0,
|
20
|
+
level: 1.0,
|
21
|
+
language: 'en',
|
22
|
+
created_at: 1.week.ago,
|
23
|
+
ends_at: nil
|
24
|
+
)
|
25
|
+
|
26
|
+
data = {
|
27
|
+
answer: { 456 => answer },
|
28
|
+
user: { 123 => john }
|
29
|
+
}
|
30
|
+
|
31
|
+
repository = ->(klass, resource_id) { data.dig(klass, resource_id) }
|
32
|
+
uri_for = ->(obj) { obj == answer ? 'rails-for-begginers' : nil }
|
33
|
+
|
34
|
+
xapi = QuestionAnswered.new(repository, uri_for).call(actor_id: 123, resource_id: 456)
|
35
|
+
|
36
|
+
expect(xapi).to be_a Xapi::Statement
|
37
|
+
expect_actor(xapi.actor, name: 'John Doe', email: 'john@doe.com')
|
38
|
+
expect(xapi.verb).to eq Verbs::ANSWERED
|
39
|
+
|
40
|
+
expect(xapi.object).to be_a Xapi::Activity
|
41
|
+
expect(xapi.object.object_type).to eq 'Activity'
|
42
|
+
expect(xapi.object.id).to eq 'rails-for-begginers'
|
43
|
+
expect(xapi.object.definition.type).to eq 'http://adlnet.gov/expapi/activities/assessment'
|
44
|
+
expect(xapi.object.definition.name).to eq({'en-US' => 'What is your favorite animal?'})
|
45
|
+
expect(xapi.object.definition.description).to eq({'en-US' => 'What is your favorite animal?'})
|
46
|
+
expect(xapi.object.definition.extensions.fetch('http://adlnet.gov/expapi/activities/question')).to eq("What is your favorite animal?")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module PupilfirstXapi
|
4
|
+
module Statements
|
5
|
+
RSpec.describe SurveyEnded do
|
6
|
+
it do
|
7
|
+
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
8
|
+
survey = double(
|
9
|
+
:survey,
|
10
|
+
name: 'Rails for Beginners',
|
11
|
+
external_name: 'Seems easy',
|
12
|
+
slug: 'a6ad5226-7d8b-4108-9cc9-f0821de150f5',
|
13
|
+
created_at: 1.week.ago,
|
14
|
+
ends_at: nil,
|
15
|
+
targets: [
|
16
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
17
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
18
|
+
]
|
19
|
+
)
|
20
|
+
|
21
|
+
data = {
|
22
|
+
survey: { 456 => survey },
|
23
|
+
user: { 123 => john }
|
24
|
+
}
|
25
|
+
|
26
|
+
repository = ->(klass, resource_id) { data.dig(klass, resource_id) }
|
27
|
+
uri_for = ->(obj) { obj == survey ? 'rails-for-begginers' : nil }
|
28
|
+
|
29
|
+
xapi = SurveyEnded.new(repository, uri_for).call(actor_id: 123, resource_id: 456)
|
30
|
+
|
31
|
+
expect(xapi).to be_a Xapi::Statement
|
32
|
+
expect_actor(xapi.actor, name: 'John Doe', email: 'john@doe.com')
|
33
|
+
expect(xapi.verb).to eq Verbs::COMPLETED
|
34
|
+
|
35
|
+
expect(xapi.object).to be_a Xapi::Activity
|
36
|
+
expect(xapi.object.object_type).to eq 'Activity'
|
37
|
+
expect(xapi.object.id).to eq 'rails-for-begginers'
|
38
|
+
expect(xapi.object.definition.type).to eq 'http://adlnet.gov/expapi/activities/assessment'
|
39
|
+
expect(xapi.object.definition.name).to eq({'en-US' => 'Rails for Beginners'})
|
40
|
+
expect(xapi.object.definition.description).to eq({'en-US' => 'Seems easy'})
|
41
|
+
expect(xapi.object.definition.extensions.fetch('http://id.tincanapi.com/extension/target')).to eq('a6ad5226-7d8b-4108-9cc9-f0821de150f5')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module PupilfirstXapi
|
4
|
+
module Statements
|
5
|
+
RSpec.describe SurveyStarted do
|
6
|
+
it do
|
7
|
+
john = double(:john, name: 'John Doe', email: 'john@doe.com')
|
8
|
+
survey = double(
|
9
|
+
:survey,
|
10
|
+
name: 'Rails for Beginners',
|
11
|
+
external_name: 'Seems easy',
|
12
|
+
slug: 'a6ad5226-7d8b-4108-9cc9-f0821de150f5',
|
13
|
+
created_at: 1.week.ago,
|
14
|
+
ends_at: nil,
|
15
|
+
targets: [
|
16
|
+
double(:target, title: '1st target', description: 'Seems easy'),
|
17
|
+
double(:target, title: '2nd target', description: 'Seems not easy')
|
18
|
+
]
|
19
|
+
)
|
20
|
+
|
21
|
+
data = {
|
22
|
+
survey: { 456 => survey },
|
23
|
+
user: { 123 => john }
|
24
|
+
}
|
25
|
+
|
26
|
+
repository = ->(klass, resource_id) { data.dig(klass, resource_id) }
|
27
|
+
uri_for = ->(obj) { obj == survey ? 'rails-for-begginers' : nil }
|
28
|
+
|
29
|
+
xapi = SurveyStarted.new(repository, uri_for).call(actor_id: 123, resource_id: 456)
|
30
|
+
|
31
|
+
expect(xapi).to be_a Xapi::Statement
|
32
|
+
expect_actor(xapi.actor, name: 'John Doe', email: 'john@doe.com')
|
33
|
+
expect(xapi.verb).to eq Verbs::STARTED
|
34
|
+
|
35
|
+
expect(xapi.object).to be_a Xapi::Activity
|
36
|
+
expect(xapi.object.object_type).to eq 'Activity'
|
37
|
+
expect(xapi.object.id).to eq 'rails-for-begginers'
|
38
|
+
expect(xapi.object.definition.type).to eq 'http://adlnet.gov/expapi/activities/assessment'
|
39
|
+
expect(xapi.object.definition.name).to eq({'en-US' => 'Rails for Beginners'})
|
40
|
+
expect(xapi.object.definition.description).to eq({'en-US' => 'Seems easy'})
|
41
|
+
expect(xapi.object.definition.extensions.fetch('http://id.tincanapi.com/extension/target')).to eq('a6ad5226-7d8b-4108-9cc9-f0821de150f5')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
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.8
|
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-08-06 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: []
|
@@ -100,14 +94,26 @@ files:
|
|
100
94
|
- lib/pupilfirst_xapi/actors.rb
|
101
95
|
- lib/pupilfirst_xapi/lrs.rb
|
102
96
|
- lib/pupilfirst_xapi/objects.rb
|
97
|
+
- lib/pupilfirst_xapi/objects/answer.rb
|
103
98
|
- lib/pupilfirst_xapi/objects/builder.rb
|
104
99
|
- lib/pupilfirst_xapi/objects/course.rb
|
100
|
+
- lib/pupilfirst_xapi/objects/survey.rb
|
101
|
+
- lib/pupilfirst_xapi/objects/survey_end.rb
|
102
|
+
- lib/pupilfirst_xapi/objects/survey_start.rb
|
105
103
|
- lib/pupilfirst_xapi/objects/target.rb
|
104
|
+
- lib/pupilfirst_xapi/objects/video_end.rb
|
105
|
+
- lib/pupilfirst_xapi/objects/video_start.rb
|
106
106
|
- lib/pupilfirst_xapi/outbox.rb
|
107
107
|
- lib/pupilfirst_xapi/statements.rb
|
108
|
+
- lib/pupilfirst_xapi/statements/capability_result_viewed.rb
|
108
109
|
- lib/pupilfirst_xapi/statements/course_completed.rb
|
109
110
|
- lib/pupilfirst_xapi/statements/course_registered.rb
|
111
|
+
- lib/pupilfirst_xapi/statements/question_answered.rb
|
112
|
+
- lib/pupilfirst_xapi/statements/survey_ended.rb
|
113
|
+
- lib/pupilfirst_xapi/statements/survey_started.rb
|
110
114
|
- lib/pupilfirst_xapi/statements/target_completed.rb
|
115
|
+
- lib/pupilfirst_xapi/statements/video_ended.rb
|
116
|
+
- lib/pupilfirst_xapi/statements/video_started.rb
|
111
117
|
- lib/pupilfirst_xapi/verbs.rb
|
112
118
|
- lib/pupilfirst_xapi/version.rb
|
113
119
|
- spec/integration_spec.rb
|
@@ -116,8 +122,12 @@ files:
|
|
116
122
|
- spec/outbox_spec.rb
|
117
123
|
- spec/rails_helper.rb
|
118
124
|
- spec/spec_helper.rb
|
125
|
+
- spec/statements/capability_result_viewed_spec.rb
|
119
126
|
- spec/statements/course_completed_spec.rb
|
120
127
|
- spec/statements/course_registered_spec.rb
|
128
|
+
- spec/statements/question_answered_spec.rb
|
129
|
+
- spec/statements/survey_ended_spec.rb
|
130
|
+
- spec/statements/survey_started_spec.rb
|
121
131
|
- spec/statements/target_completed_spec.rb
|
122
132
|
homepage: https://github.com/growthtribeacademy/pupilfirst-xapi
|
123
133
|
licenses:
|
@@ -126,7 +136,7 @@ metadata:
|
|
126
136
|
homepage_uri: https://github.com/growthtribeacademy/pupilfirst-xapi
|
127
137
|
source_code_uri: https://github.com/growthtribeacademy/pupilfirst-xapi/pupilfirst_xapi
|
128
138
|
changelog_uri: https://github.com/growthtribeacademy/pupilfirst-xapi/pupilfirst_xapi/CHANGELOG.md
|
129
|
-
post_install_message:
|
139
|
+
post_install_message:
|
130
140
|
rdoc_options: []
|
131
141
|
require_paths:
|
132
142
|
- lib
|
@@ -141,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
151
|
- !ruby/object:Gem::Version
|
142
152
|
version: '0'
|
143
153
|
requirements: []
|
144
|
-
rubygems_version: 3.2.
|
145
|
-
signing_key:
|
154
|
+
rubygems_version: 3.2.15
|
155
|
+
signing_key:
|
146
156
|
specification_version: 4
|
147
157
|
summary: XAPI statements generator and publisher to LRS for Pupilfirst
|
148
158
|
test_files:
|
@@ -152,6 +162,10 @@ test_files:
|
|
152
162
|
- spec/outbox_spec.rb
|
153
163
|
- spec/rails_helper.rb
|
154
164
|
- spec/spec_helper.rb
|
165
|
+
- spec/statements/capability_result_viewed_spec.rb
|
155
166
|
- spec/statements/course_completed_spec.rb
|
156
167
|
- spec/statements/course_registered_spec.rb
|
168
|
+
- spec/statements/question_answered_spec.rb
|
169
|
+
- spec/statements/survey_ended_spec.rb
|
170
|
+
- spec/statements/survey_started_spec.rb
|
157
171
|
- spec/statements/target_completed_spec.rb
|