ims_caliper 0.9.3.15 → 1.0.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/README.md +10 -5
- data/lib/caliper/{profiles/annotation_profile.rb → actions/annotation_actions.rb} +3 -41
- data/lib/caliper/{profiles/assessment_profile.rb → actions/assessment_actions.rb} +3 -19
- data/lib/caliper/actions/assessment_item_actions.rb +31 -0
- data/lib/caliper/{profiles/assignable_profile.rb → actions/assignable_actions.rb} +3 -28
- data/lib/caliper/{profiles/media_profile.rb → actions/media_actions.rb} +4 -29
- data/lib/caliper/{event/view_event.rb → actions/navigation_actions.rb} +5 -11
- data/lib/caliper/{validators/event_validator_context.rb → actions/outcome_actions.rb} +7 -15
- data/lib/caliper/{event/navigation_event.rb → actions/reading_actions.rb} +6 -14
- data/lib/caliper/actions/session_actions.rb +30 -0
- data/lib/caliper/context/context.rb +31 -0
- data/lib/caliper/entities/agent/organization.rb +4 -3
- data/lib/caliper/entities/agent/person.rb +4 -3
- data/lib/caliper/entities/agent/software_application.rb +4 -3
- data/lib/caliper/entities/annotation/annotation.rb +4 -12
- data/lib/caliper/entities/annotation/annotation_type.rb +32 -0
- data/lib/caliper/entities/annotation/bookmark_annotation.rb +3 -1
- data/lib/caliper/entities/annotation/highlight_annotation.rb +4 -4
- data/lib/caliper/entities/annotation/shared_annotation.rb +3 -1
- data/lib/caliper/entities/annotation/tag_annotation.rb +3 -1
- data/lib/caliper/entities/assessment/assessment.rb +1 -1
- data/lib/caliper/entities/assessment/assessment_item.rb +2 -0
- data/lib/caliper/entities/assignable/assignable_digital_resource.rb +3 -13
- data/lib/caliper/{event/session_event.rb → entities/assignable/assignable_digital_resource_type.rb} +7 -11
- data/lib/caliper/entities/assignable/attempt.rb +8 -9
- data/lib/caliper/entities/digital_resource.rb +5 -22
- data/lib/caliper/entities/digital_resource_type.rb +33 -0
- data/lib/caliper/entities/entity.rb +7 -37
- data/lib/caliper/entities/{learning_context.rb → entity_base.rb} +19 -15
- data/lib/caliper/entities/entity_type.rb +39 -0
- data/lib/caliper/entities/foaf/agent.rb +0 -2
- data/lib/caliper/entities/jsonable.rb +14 -3
- data/lib/caliper/entities/learning_objective.rb +4 -3
- data/lib/caliper/entities/lis/course_offering.rb +9 -6
- data/lib/caliper/entities/lis/course_section.rb +3 -1
- data/lib/caliper/entities/lis/group.rb +5 -3
- data/lib/caliper/entities/lis/membership.rb +5 -7
- data/lib/caliper/entities/media/audio_object.rb +2 -1
- data/lib/caliper/entities/media/image_object.rb +2 -1
- data/lib/caliper/entities/media/media_location.rb +2 -1
- data/lib/caliper/entities/media/media_object.rb +2 -9
- data/lib/caliper/entities/media/media_object_type.rb +31 -0
- data/lib/caliper/entities/media/video_object.rb +2 -1
- data/lib/caliper/entities/outcome/result.rb +23 -16
- data/lib/caliper/entities/reading/epub_chapter.rb +2 -1
- data/lib/caliper/entities/reading/epub_part.rb +2 -1
- data/lib/caliper/entities/reading/epub_sub_chapter.rb +2 -1
- data/lib/caliper/entities/reading/epub_volume.rb +2 -1
- data/lib/caliper/entities/reading/frame.rb +4 -3
- data/lib/caliper/entities/reading/web_page.rb +3 -2
- data/lib/caliper/entities/response/fillin_blank_response.rb +3 -3
- data/lib/caliper/entities/response/multiple_choice_response.rb +3 -3
- data/lib/caliper/entities/response/multiple_response_response.rb +3 -3
- data/lib/caliper/entities/response/response.rb +8 -10
- data/lib/caliper/entities/response/response_type.rb +5 -5
- data/lib/caliper/entities/response/select_type_response.rb +3 -3
- data/lib/caliper/entities/response/true_false_response.rb +2 -3
- data/lib/caliper/entities/session/session.rb +8 -7
- data/lib/caliper/{event → events}/annotation_event.rb +11 -3
- data/lib/caliper/{event → events}/assessment_event.rb +11 -8
- data/lib/caliper/{event → events}/assessment_item_event.rb +11 -8
- data/lib/caliper/{event → events}/assignable_event.rb +11 -8
- data/lib/caliper/{profiles/profile.rb → events/event.rb} +15 -15
- data/lib/caliper/events/event_context.rb +24 -0
- data/lib/caliper/events/event_type.rb +33 -0
- data/lib/caliper/{event → events}/jsonable.rb +2 -2
- data/lib/caliper/{event → events}/media_event.rb +11 -8
- data/lib/caliper/events/navigation_event.rb +47 -0
- data/lib/caliper/events/outcome_event.rb +44 -0
- data/lib/caliper/{event/outcome_event.rb → events/reading_event.rb} +13 -10
- data/lib/caliper/events/session_event.rb +42 -0
- data/lib/caliper/events/view_event.rb +44 -0
- data/lib/caliper/request/envelope.rb +4 -15
- data/lib/caliper/request/event_store_requestor.rb +1 -1
- data/lib/caliper/request/{envelope_jsonable.rb → jsonable.rb} +9 -11
- data/lib/caliper/sensor.rb +1 -1
- data/lib/caliper/version.rb +1 -1
- data/lib/caliper.rb +1 -1
- data/spec/lib/entities/agent/{student.json → person.json} +4 -3
- data/spec/lib/entities/agent/person_spec.rb +5 -6
- data/spec/lib/entities/assessment/assessment.json +23 -0
- data/spec/lib/entities/assessment/assessment_spec.rb +54 -0
- data/spec/lib/event_helper.rb +33 -41
- data/spec/lib/{event/annotation_event_bookmark_spec.rb → events/annotation_bookmarked_event_spec.rb} +36 -46
- data/spec/lib/{event/annotation_event_highlight_spec.rb → events/annotation_highlighted_event_spec.rb} +36 -46
- data/spec/lib/{event/annotation_event_shared_spec.rb → events/annotation_shared_event_spec.rb} +42 -52
- data/spec/lib/{event/annotation_event_tag_spec.rb → events/annotation_tagged_event_spec.rb} +36 -46
- data/spec/lib/{event → events}/assessment_item_completed_event_spec.rb +41 -65
- data/spec/lib/{event → events}/assessment_item_started_event_spec.rb +38 -56
- data/spec/lib/{event/assessment_event_spec.rb → events/assessment_started_event_spec.rb} +36 -51
- data/spec/lib/{event/assignable_event_spec.rb → events/assignable_activated_event_spec.rb} +37 -52
- data/spec/lib/{event/media_event_spec.rb → events/media_paused_video_event_spec.rb} +33 -43
- data/spec/lib/{event/navigated_event_spec.rb → events/navigation_navigated_to_event_spec.rb} +36 -45
- data/spec/lib/events/outcome_graded_event_spec.rb +163 -0
- data/spec/lib/{event/session_event_login_spec.rb → events/session_logged_in_event_spec.rb} +38 -46
- data/spec/lib/{event/session_event_logout_spec.rb → events/session_logged_out-event_spec.rb} +28 -37
- data/spec/lib/{event/session_event_timeout_spec.rb → events/session_timed_out_event_spec.rb} +24 -34
- data/spec/lib/{event/viewed_event_spec.rb → events/view_viewed_event_spec.rb} +33 -41
- data/spec/lib/request/{http_requestor_spec.rb → http_requestor_single_event_spec.rb} +46 -47
- data/spec/lib/request/http_requestor_single_minimal_event_spec.rb +84 -0
- data/spec/lib/sensor_spec.rb +1 -1
- metadata +77 -70
- data/lib/caliper/event/event.rb +0 -114
- data/lib/caliper/profiles/assessment_item_profile.rb +0 -48
- data/lib/caliper/profiles/reading_profile.rb +0 -56
- data/lib/caliper/profiles/session_profile.rb +0 -46
- data/lib/caliper/validators/error_message.rb +0 -63
- data/lib/caliper/validators/event_validator.rb +0 -57
- data/lib/caliper/validators/property_type_check.rb +0 -33
- data/lib/caliper/validators/session_login_event_validator.rb +0 -121
- data/lib/caliper/validators/session_logout_event_validator.rb +0 -120
- data/lib/caliper/validators/time_check.rb +0 -50
- data/spec/lib/entities/entity.json +0 -9
- data/spec/lib/entities/entity_spec.rb +0 -52
data/spec/lib/{event/session_event_timeout_spec.rb → events/session_timed_out_event_spec.rb}
RENAMED
@@ -16,7 +16,8 @@
|
|
16
16
|
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
17
|
|
18
18
|
require 'require_all'
|
19
|
-
require_all 'lib/caliper/
|
19
|
+
require_all 'lib/caliper/actions/session_actions.rb'
|
20
|
+
require_all 'lib/caliper/entities/entity_base.rb'
|
20
21
|
require_all 'lib/caliper/entities/agent/software_application.rb'
|
21
22
|
require_all 'lib/caliper/entities/agent/person.rb'
|
22
23
|
require_all 'lib/caliper/entities/lis/membership.rb'
|
@@ -26,12 +27,11 @@ require_all 'lib/caliper/entities/lis/course_section.rb'
|
|
26
27
|
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
27
28
|
require_all 'lib/caliper/entities/lis/group.rb'
|
28
29
|
require_all 'lib/caliper/entities/session/session.rb'
|
29
|
-
require_all 'lib/caliper/
|
30
|
-
require_all 'lib/caliper/profiles/session_profile.rb'
|
30
|
+
require_all 'lib/caliper/events/session_event.rb'
|
31
31
|
require 'json_spec'
|
32
32
|
|
33
33
|
module Caliper
|
34
|
-
module
|
34
|
+
module Events
|
35
35
|
|
36
36
|
describe SessionEvent do
|
37
37
|
|
@@ -39,78 +39,68 @@ module Caliper
|
|
39
39
|
|
40
40
|
# EdApp
|
41
41
|
ed_app = Caliper::Entities::Agent::SoftwareApplication.new
|
42
|
-
ed_app.id = 'https://
|
43
|
-
ed_app.name = '
|
44
|
-
ed_app.dateCreated =
|
45
|
-
ed_app.dateModified =
|
42
|
+
ed_app.id = 'https://example.com/viewer'
|
43
|
+
ed_app.name = 'ePub'
|
44
|
+
ed_app.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
45
|
+
ed_app.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
46
46
|
|
47
47
|
# Actor (edApp)
|
48
48
|
actor = ed_app
|
49
49
|
|
50
50
|
# Action
|
51
|
-
action = Caliper::
|
51
|
+
action = Caliper::Actions::SessionActions::TIMED_OUT
|
52
52
|
|
53
53
|
# Object session actor (session.actor)
|
54
54
|
student = Caliper::Entities::Agent::Person.new
|
55
|
-
student.id = 'https://
|
56
|
-
student.dateCreated =
|
57
|
-
student.dateModified =
|
55
|
+
student.id = 'https://example.edu/user/554433'
|
56
|
+
student.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
57
|
+
student.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
58
58
|
|
59
59
|
# Object
|
60
60
|
obj = Caliper::Entities::Session::Session.new
|
61
|
-
obj.id = 'https://
|
61
|
+
obj.id = 'https://example.com/viewer/session-123456789'
|
62
62
|
obj.name = 'session-123456789'
|
63
|
-
obj.description = nil
|
64
63
|
obj.actor = student
|
65
64
|
obj.startedAtTime = '2015-09-15T10:15:00.000Z'
|
66
65
|
obj.endedAtTime = '2015-09-15T11:05:00.000Z'
|
67
66
|
obj.duration = 'PT3000S'
|
68
|
-
obj.dateCreated =
|
69
|
-
obj.dateModified =
|
67
|
+
obj.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
68
|
+
obj.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
70
69
|
|
71
70
|
# LIS Course Offering
|
72
71
|
course = Caliper::Entities::LIS::CourseOffering.new
|
73
|
-
course.id = "https://
|
72
|
+
course.id = "https://example.edu/politicalScience/2015/american-revolution-101"
|
74
73
|
course.name = "Political Science 101: The American Revolution"
|
75
74
|
course.courseNumber = "POL101"
|
76
75
|
course.academicSession = "Fall-2015"
|
77
|
-
course.
|
78
|
-
course.
|
79
|
-
course.dateModified = '2015-09-02T11:30:00.000Z'
|
76
|
+
course.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
77
|
+
course.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
80
78
|
|
81
79
|
# LIS Course Section
|
82
80
|
section = Caliper::Entities::LIS::CourseSection.new
|
83
|
-
section.id = 'https://
|
81
|
+
section.id = 'https://example.edu/politicalScience/2015/american-revolution-101/section/001'
|
84
82
|
section.name = 'American Revolution 101'
|
85
83
|
section.courseNumber = "POL101"
|
86
84
|
section.academicSession = "Fall-2015"
|
87
|
-
section.category = nil
|
88
85
|
section.subOrganizationOf = course
|
89
|
-
section.dateCreated =
|
90
|
-
section.dateModified =
|
86
|
+
section.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
87
|
+
section.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
91
88
|
|
92
89
|
# LIS Group
|
93
90
|
group = Caliper::Entities::LIS::Group.new
|
94
|
-
group.id = "https://
|
91
|
+
group.id = "https://example.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
95
92
|
group.name = "Discussion Group 001"
|
96
93
|
group.subOrganizationOf = section
|
97
|
-
group.dateCreated =
|
98
|
-
group.dateModified = nil
|
94
|
+
group.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
99
95
|
|
100
96
|
# Create the Event
|
101
97
|
event = SessionEvent.new
|
102
98
|
event.actor = ed_app
|
103
99
|
event.action = action
|
104
100
|
event.object = obj
|
105
|
-
event.
|
106
|
-
event.generated = nil
|
107
|
-
event.startedAtTime = '2015-09-15T10:15:00.000Z'
|
108
|
-
event.endedAtTime = '2015-09-15T11:05:00.000Z'
|
109
|
-
event.duration = 'PT3000S'
|
101
|
+
event.eventTime = Time.utc(2015,9,15,10,15,0).iso8601(3)
|
110
102
|
event.edApp = ed_app
|
111
103
|
event.group = group
|
112
|
-
event.membership = nil
|
113
|
-
# puts "Event JSON = #{event.to_json}'"
|
114
104
|
|
115
105
|
# Load JSON from caliper-common-fixtures for comparison
|
116
106
|
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
@@ -16,7 +16,8 @@
|
|
16
16
|
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
17
|
|
18
18
|
require 'require_all'
|
19
|
-
require_all 'lib/caliper/
|
19
|
+
require_all 'lib/caliper/actions/reading_actions.rb'
|
20
|
+
require_all 'lib/caliper/entities/entity_base.rb'
|
20
21
|
require_all 'lib/caliper/entities/agent/software_application.rb'
|
21
22
|
require_all 'lib/caliper/entities/agent/person.rb'
|
22
23
|
require_all 'lib/caliper/entities/lis/membership.rb'
|
@@ -26,12 +27,11 @@ require_all 'lib/caliper/entities/lis/course_section.rb'
|
|
26
27
|
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
27
28
|
require_all 'lib/caliper/entities/lis/group.rb'
|
28
29
|
require_all 'lib/caliper/entities/reading/epub_volume.rb'
|
29
|
-
require_all 'lib/caliper/
|
30
|
-
require_all 'lib/caliper/profiles/reading_profile.rb'
|
30
|
+
require_all 'lib/caliper/events/view_event.rb'
|
31
31
|
require 'json_spec'
|
32
32
|
|
33
33
|
module Caliper
|
34
|
-
module
|
34
|
+
module Events
|
35
35
|
|
36
36
|
describe ViewEvent do
|
37
37
|
|
@@ -39,92 +39,84 @@ module Caliper
|
|
39
39
|
|
40
40
|
# Actor
|
41
41
|
actor = Caliper::Entities::Agent::Person.new
|
42
|
-
actor.id = 'https://
|
43
|
-
actor.dateCreated =
|
44
|
-
actor.dateModified =
|
42
|
+
actor.id = 'https://example.edu/user/554433'
|
43
|
+
actor.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
44
|
+
actor.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
45
45
|
|
46
46
|
# Action
|
47
|
-
action = Caliper::
|
47
|
+
action = Caliper::Actions::ReadingActions::VIEWED
|
48
48
|
|
49
49
|
# Object
|
50
50
|
obj = Caliper::Entities::Reading::EPubVolume.new
|
51
|
-
obj.id = 'https://
|
51
|
+
obj.id = 'https://example.com/viewer/book/34843#epubcfi(/4/3)'
|
52
52
|
obj.name = 'The Glorious Cause: The American Revolution, 1763-1789 (Oxford History of the United States)'
|
53
53
|
obj.version = '2nd ed.'
|
54
|
-
obj.dateCreated =
|
55
|
-
obj.dateModified =
|
54
|
+
obj.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
55
|
+
obj.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
56
56
|
|
57
57
|
# Target frame
|
58
58
|
frame = Caliper::Entities::Reading::Frame.new
|
59
|
-
frame.id = 'https://
|
59
|
+
frame.id = 'https://example.com/viewer/book/34843#epubcfi(/4/3/1)'
|
60
60
|
frame.name = 'Key Figures: George Washington'
|
61
61
|
frame.isPartOf = obj
|
62
62
|
frame.version = obj.version
|
63
63
|
frame.index = 1
|
64
|
-
frame.dateCreated =
|
65
|
-
frame.dateModified =
|
64
|
+
frame.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
65
|
+
frame.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
66
66
|
|
67
67
|
# EdApp
|
68
68
|
ed_app = Caliper::Entities::Agent::SoftwareApplication.new
|
69
|
-
ed_app.id = 'https://
|
70
|
-
ed_app.name = '
|
71
|
-
ed_app.dateCreated =
|
72
|
-
ed_app.dateModified =
|
69
|
+
ed_app.id = 'https://example.com/viewer'
|
70
|
+
ed_app.name = 'ePub'
|
71
|
+
ed_app.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
72
|
+
ed_app.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
73
73
|
|
74
74
|
# LIS Course Offering
|
75
75
|
course = Caliper::Entities::LIS::CourseOffering.new
|
76
|
-
course.id = "https://
|
76
|
+
course.id = "https://example.edu/politicalScience/2015/american-revolution-101"
|
77
77
|
course.name = "Political Science 101: The American Revolution"
|
78
78
|
course.courseNumber = "POL101"
|
79
79
|
course.academicSession = "Fall-2015"
|
80
|
-
course.
|
81
|
-
course.
|
82
|
-
course.dateModified = '2015-09-02T11:30:00.000Z'
|
80
|
+
course.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
81
|
+
course.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
83
82
|
|
84
83
|
# LIS Course Section
|
85
84
|
section = Caliper::Entities::LIS::CourseSection.new
|
86
|
-
section.id = 'https://
|
85
|
+
section.id = 'https://example.edu/politicalScience/2015/american-revolution-101/section/001'
|
87
86
|
section.name = 'American Revolution 101'
|
88
87
|
section.courseNumber = "POL101"
|
89
88
|
section.academicSession = "Fall-2015"
|
90
|
-
section.category = nil
|
91
89
|
section.subOrganizationOf = course
|
92
|
-
section.dateCreated =
|
93
|
-
section.dateModified =
|
90
|
+
section.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
91
|
+
section.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
94
92
|
|
95
93
|
# LIS Group
|
96
94
|
group = Caliper::Entities::LIS::Group.new
|
97
|
-
group.id = "https://
|
95
|
+
group.id = "https://example.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
98
96
|
group.name = "Discussion Group 001"
|
99
97
|
group.subOrganizationOf = section
|
100
|
-
group.dateCreated =
|
101
|
-
group.dateModified = nil
|
98
|
+
group.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
102
99
|
|
103
100
|
membership = Caliper::Entities::LIS::Membership.new
|
104
|
-
membership.id = "https://
|
101
|
+
membership.id = "https://example.edu/politicalScience/2015/american-revolution-101/roster/554433"
|
105
102
|
membership.name = "American Revolution 101"
|
106
103
|
membership.description = "Roster entry"
|
107
|
-
membership.member = "https://
|
108
|
-
membership.organization = "https://
|
104
|
+
membership.member = "https://example.edu/user/554433"
|
105
|
+
membership.organization = "https://example.edu/politicalScience/2015/american-revolution-101/section/001"
|
109
106
|
membership.roles = [Caliper::Entities::LIS::Role::LEARNER]
|
110
107
|
membership.status = Caliper::Entities::LIS::Status::ACTIVE
|
111
|
-
membership.dateCreated =
|
112
|
-
membership.dateModified = nil
|
108
|
+
membership.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
113
109
|
|
114
110
|
# Create Event
|
115
|
-
event = Caliper::
|
111
|
+
event = Caliper::Events::ViewEvent.new
|
116
112
|
event.actor = actor
|
117
113
|
event.action = action
|
118
114
|
event.object = obj
|
119
115
|
event.target = frame
|
120
|
-
event.
|
121
|
-
event.startedAtTime = '2015-09-15T10:15:00.000Z'
|
122
|
-
event.endedAtTime = nil
|
123
|
-
event.duration = nil
|
116
|
+
event.eventTime = Time.utc(2015,9,15,10,15,0).iso8601(3)
|
124
117
|
event.edApp = ed_app
|
125
118
|
event.group = group
|
126
119
|
event.membership = membership
|
127
|
-
# puts "Event JSON = #{event.to_json}'"
|
128
120
|
|
129
121
|
# Load JSON from caliper-common-fixtures for comparison
|
130
122
|
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
@@ -134,7 +126,7 @@ module Caliper
|
|
134
126
|
expect(event.to_json).to be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
|
135
127
|
|
136
128
|
# puts "JSON from file = #{data_hash}"
|
137
|
-
deser_event = Caliper::
|
129
|
+
deser_event = Caliper::Events::ViewEvent.new
|
138
130
|
deser_event.from_json data_hash
|
139
131
|
# puts "ReadingEvent from JSON = #{deser_event.to_json}"
|
140
132
|
|
@@ -16,7 +16,7 @@
|
|
16
16
|
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
17
|
|
18
18
|
require 'require_all'
|
19
|
-
require_all 'lib/caliper/entities/
|
19
|
+
require_all 'lib/caliper/entities/entity_base.rb'
|
20
20
|
require_all 'lib/caliper/entities/agent/software_application.rb'
|
21
21
|
require_all 'lib/caliper/entities/agent/person.rb'
|
22
22
|
require_all 'lib/caliper/entities/lis/membership.rb'
|
@@ -27,8 +27,8 @@ require_all 'lib/caliper/entities/lis/course_offering.rb'
|
|
27
27
|
require_all 'lib/caliper/entities/lis/group.rb'
|
28
28
|
require_all 'lib/caliper/entities/reading/epub_volume.rb'
|
29
29
|
require_all 'lib/caliper/entities/reading/web_page.rb'
|
30
|
-
require_all 'lib/caliper/
|
31
|
-
require_all 'lib/caliper/
|
30
|
+
require_all 'lib/caliper/entities/session/session.rb'
|
31
|
+
require_all 'lib/caliper/events/navigation_event.rb'
|
32
32
|
require_all 'lib/caliper/options.rb'
|
33
33
|
require_all 'lib/caliper/request/http_requestor.rb'
|
34
34
|
require_all 'lib/caliper/sensor.rb'
|
@@ -44,106 +44,105 @@ module Caliper
|
|
44
44
|
|
45
45
|
# EdApp
|
46
46
|
ed_app = Caliper::Entities::Agent::SoftwareApplication.new
|
47
|
-
ed_app.id = 'https://
|
48
|
-
ed_app.name = '
|
49
|
-
ed_app.dateCreated =
|
50
|
-
ed_app.dateModified =
|
51
|
-
|
47
|
+
ed_app.id = 'https://example.com/viewer'
|
48
|
+
ed_app.name = 'ePub'
|
49
|
+
ed_app.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
50
|
+
ed_app.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
51
|
+
|
52
52
|
# Actor
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
actor = Caliper::Entities::Agent::Person.new
|
54
|
+
actor.id = 'https://example.edu/user/554433'
|
55
|
+
actor.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
56
|
+
actor.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
57
|
+
|
58
|
+
# LTI federated session
|
59
|
+
session = Caliper::Entities::Session::Session.new
|
60
|
+
session.id = 'https://example.edu/lms/federatedSession/123456789'
|
61
|
+
session.actor = actor
|
62
|
+
session.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
63
|
+
session.startedAtTime = '2015-09-15T10:15:00.000Z'
|
57
64
|
|
58
65
|
# Action
|
59
|
-
action = Caliper::
|
66
|
+
action = Caliper::Actions::NavigationActions::NAVIGATED_TO
|
60
67
|
|
61
68
|
# Object
|
62
69
|
obj = Caliper::Entities::Reading::EPubVolume.new
|
63
|
-
obj.id = 'https://
|
70
|
+
obj.id = 'https://example.com/viewer/book/34843#epubcfi(/4/3)'
|
64
71
|
obj.name = 'The Glorious Cause: The American Revolution, 1763-1789 (Oxford History of the United States)'
|
65
72
|
obj.version = '2nd ed.'
|
66
|
-
obj.dateCreated =
|
67
|
-
obj.dateModified =
|
73
|
+
obj.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
74
|
+
obj.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
68
75
|
|
69
76
|
# Target frame
|
70
77
|
frame = Caliper::Entities::Reading::Frame.new
|
71
|
-
frame.id = 'https://
|
78
|
+
frame.id = 'https://example.com/viewer/book/34843#epubcfi(/4/3/1)'
|
72
79
|
frame.name = 'Key Figures: George Washington'
|
73
80
|
frame.isPartOf = obj
|
74
81
|
frame.version = obj.version
|
75
82
|
frame.index = 1
|
76
|
-
frame.dateCreated =
|
77
|
-
frame.dateModified =
|
83
|
+
frame.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
84
|
+
frame.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
78
85
|
|
79
86
|
# navigatedFrom property (specific to Navigation Event)
|
80
87
|
from = Caliper::Entities::Reading::WebPage.new
|
81
|
-
from.id = 'https://
|
88
|
+
from.id = 'https://example.edu/politicalScience/2015/american-revolution-101/index.html'
|
82
89
|
from.name = 'American Revolution 101 Landing Page'
|
83
|
-
from.dateCreated =
|
84
|
-
from.dateModified =
|
85
|
-
from.isPartOf = nil
|
90
|
+
from.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
91
|
+
from.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
86
92
|
from.version = '1.0'
|
87
93
|
|
88
94
|
# LIS Course Offering
|
89
95
|
course = Caliper::Entities::LIS::CourseOffering.new
|
90
|
-
course.id = "https://
|
96
|
+
course.id = "https://example.edu/politicalScience/2015/american-revolution-101"
|
91
97
|
course.name = "Political Science 101: The American Revolution"
|
92
98
|
course.courseNumber = "POL101"
|
93
99
|
course.academicSession = "Fall-2015"
|
94
|
-
course.
|
95
|
-
course.
|
96
|
-
course.dateModified = '2015-09-02T11:30:00.000Z'
|
100
|
+
course.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
101
|
+
course.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
97
102
|
|
98
103
|
# LIS Course Section
|
99
104
|
section = Caliper::Entities::LIS::CourseSection.new
|
100
|
-
section.id = 'https://
|
105
|
+
section.id = 'https://example.edu/politicalScience/2015/american-revolution-101/section/001'
|
101
106
|
section.name = 'American Revolution 101'
|
102
107
|
section.courseNumber = "POL101"
|
103
108
|
section.academicSession = "Fall-2015"
|
104
|
-
section.category = nil
|
105
109
|
section.subOrganizationOf = course
|
106
|
-
section.dateCreated =
|
107
|
-
section.dateModified =
|
110
|
+
section.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
111
|
+
section.dateModified = Time.utc(2015,9,2,11,30,0).iso8601(3)
|
108
112
|
|
109
113
|
# LIS Group
|
110
114
|
group = Caliper::Entities::LIS::Group.new
|
111
|
-
group.id = "https://
|
115
|
+
group.id = "https://example.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
112
116
|
group.name = "Discussion Group 001"
|
113
117
|
group.subOrganizationOf = section
|
114
|
-
group.dateCreated =
|
115
|
-
group.dateModified = nil
|
118
|
+
group.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
116
119
|
|
117
120
|
membership = Caliper::Entities::LIS::Membership.new
|
118
|
-
membership.id = "https://
|
121
|
+
membership.id = "https://example.edu/politicalScience/2015/american-revolution-101/roster/554433"
|
119
122
|
membership.name = "American Revolution 101"
|
120
123
|
membership.description = "Roster entry"
|
121
|
-
membership.member = "https://
|
122
|
-
membership.organization = "https://
|
124
|
+
membership.member = "https://example.edu/user/554433"
|
125
|
+
membership.organization = "https://example.edu/politicalScience/2015/american-revolution-101/section/001"
|
123
126
|
membership.roles = [Caliper::Entities::LIS::Role::LEARNER]
|
124
127
|
membership.status = Caliper::Entities::LIS::Status::ACTIVE
|
125
|
-
membership.dateCreated =
|
126
|
-
membership.dateModified = nil
|
128
|
+
membership.dateCreated = Time.utc(2015,8,1,6,0,0).iso8601(3)
|
127
129
|
|
128
130
|
# Create the Event
|
129
|
-
event = Caliper::
|
130
|
-
event.actor =
|
131
|
+
event = Caliper::Events::NavigationEvent.new
|
132
|
+
event.actor = actor
|
131
133
|
event.action = action
|
132
134
|
event.object = obj
|
133
135
|
event.target = frame
|
134
|
-
event.generated = nil
|
135
136
|
event.navigatedFrom = from
|
136
|
-
event.
|
137
|
-
event.endedAtTime = nil
|
138
|
-
event.duration = nil
|
137
|
+
event.eventTime = Time.utc(2015,9,15,10,15,0).iso8601(3)
|
139
138
|
event.edApp = ed_app
|
140
139
|
event.group = group
|
141
140
|
event.membership = membership
|
142
|
-
|
141
|
+
event.federatedSession = session.id
|
143
142
|
|
144
143
|
# The Sensor
|
145
144
|
options = Caliper::Options.new
|
146
|
-
sensor = Caliper::Sensor.new("
|
145
|
+
sensor = Caliper::Sensor.new("https://example.edu/sensor/001", options)
|
147
146
|
requestor = Caliper::Request::HttpRequestor.new(options)
|
148
147
|
json_payload = requestor.generate_payload(sensor, event)
|
149
148
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
##
|
2
|
+
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
+
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
+
# under one or more contributor license agreements. See the NOTICE
|
5
|
+
# file distributed with this work for additional information.
|
6
|
+
#
|
7
|
+
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
+
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
+
# Software Foundation, version 3 of the License.
|
10
|
+
#
|
11
|
+
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
+
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
+
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
+
|
18
|
+
require 'require_all'
|
19
|
+
require_all 'lib/caliper/actions/reading_actions.rb'
|
20
|
+
require_all 'lib/caliper/entities/entity.rb'
|
21
|
+
require_all 'lib/caliper/events/event.rb'
|
22
|
+
require_all 'lib/caliper/options.rb'
|
23
|
+
require_all 'lib/caliper/request/http_requestor.rb'
|
24
|
+
require_all 'lib/caliper/sensor.rb'
|
25
|
+
|
26
|
+
require 'json_spec'
|
27
|
+
|
28
|
+
module Caliper
|
29
|
+
module Request
|
30
|
+
|
31
|
+
describe Envelope do
|
32
|
+
|
33
|
+
it 'should ensure that a Caliper envelope comprising a minimalist event is correctly created and serialized' do
|
34
|
+
|
35
|
+
# Actor
|
36
|
+
actor = Caliper::Entities::Entity.new
|
37
|
+
actor.context = nil
|
38
|
+
actor.id = 'https://example.edu/user/554433'
|
39
|
+
actor.type = 'http://purl.imsglobal.org/caliper/v1/lis/Person'
|
40
|
+
# puts "new minimal actor entity = #{actor.to_json}"
|
41
|
+
|
42
|
+
# Action
|
43
|
+
action = Caliper::Actions::ReadingActions::VIEWED
|
44
|
+
|
45
|
+
obj = Caliper::Entities::Entity.new
|
46
|
+
obj.context = nil
|
47
|
+
obj.id = 'https://example.com/viewer/book/34843#epubcfi(/4/3)'
|
48
|
+
obj.type = 'http://www.idpf.org/epub/vocab/structure/#volume'
|
49
|
+
# puts "new minimal object entity = #{obj.to_json}"
|
50
|
+
|
51
|
+
# Create the Event
|
52
|
+
event = Caliper::Events::Event.new
|
53
|
+
event.actor = actor
|
54
|
+
event.action = action
|
55
|
+
event.object = obj
|
56
|
+
event.eventTime = Time.utc(2015,9,15,10,15,0).iso8601(3)
|
57
|
+
|
58
|
+
# The Sensor
|
59
|
+
options = Caliper::Options.new
|
60
|
+
sensor = Caliper::Sensor.new("https://example.edu/sensor/001", options)
|
61
|
+
requestor = Caliper::Request::HttpRequestor.new(options)
|
62
|
+
json_payload = requestor.generate_payload(sensor, event)
|
63
|
+
|
64
|
+
# Swap out sendTime=DateTime.now() in favor of fixture value (or test will most assuredly fail).
|
65
|
+
json_payload_sub = json_payload.sub(/\"sendTime\":\"[^\"]*\"/, "\"sendTime\":\"2015-09-15T11:05:01.000Z\"")
|
66
|
+
|
67
|
+
# Load JSON from caliper-common-fixtures for comparison
|
68
|
+
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
69
|
+
file = File.read('spec/fixtures/caliperEnvelopeEventViewViewedMinimal.json')
|
70
|
+
data_hash = JSON.parse(file)
|
71
|
+
expected_json = data_hash.to_json # convert hash back to JSON string after parse
|
72
|
+
expect(json_payload_sub).to be_json_eql(expected_json)
|
73
|
+
|
74
|
+
# puts "JSON from file = #{data_hash}"
|
75
|
+
# deser_envelope = Caliper::Request::Envelope.new
|
76
|
+
# deser_envelope.from_json data_hash
|
77
|
+
# puts "Envelope from JSON = #{deser_envelope.to_json}"
|
78
|
+
|
79
|
+
# Ensure that the deserialized shared event object conforms
|
80
|
+
# expect(json_payload_sub).to eql(deser_envelope)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|