ims_caliper 0.1.1 → 0.1.2
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 +8 -8
- data/.gitignore +37 -0
- data/.idea/caliper-ruby.iml +98 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/Gemfile +12 -1
- data/Gemfile.lock +42 -1
- data/LICENSE +67 -0
- data/NOTICE +15 -0
- data/README.md +13 -5
- data/caliper.gemspec +2 -8
- data/lib/caliper/defaults.rb +4 -4
- data/lib/caliper/entities/annotation/annotation.rb +14 -4
- data/lib/caliper/entities/annotation/bookmark_annotation.rb +14 -4
- data/lib/caliper/entities/annotation/highlight_annotation.rb +14 -3
- data/lib/caliper/entities/annotation/shared_annotation.rb +12 -3
- data/lib/caliper/entities/annotation/tag_annotation.rb +13 -3
- data/lib/caliper/entities/assessment/assessment.rb +27 -0
- data/lib/caliper/entities/assessment/assessment_item.rb +26 -0
- data/lib/caliper/entities/assignable/assignable_digital_resource.rb +47 -0
- data/lib/caliper/entities/assignable/attempt.rb +32 -0
- data/lib/caliper/entities/digital_resource.rb +36 -35
- data/lib/caliper/entities/entity.rb +50 -36
- data/lib/caliper/entities/foaf/agent.rb +1 -1
- data/lib/caliper/entities/jsonable.rb +56 -0
- data/lib/caliper/entities/learning_objective.rb +26 -0
- data/lib/caliper/entities/lis/course_offering.rb +30 -0
- data/lib/caliper/entities/lis/course_section.rb +27 -15
- data/lib/caliper/entities/lis/group.rb +27 -0
- data/lib/caliper/entities/lis/membership.rb +32 -0
- data/lib/caliper/entities/lis/organization.rb +20 -17
- data/lib/caliper/entities/lis/person.rb +23 -10
- data/lib/caliper/entities/lis/roles.rb +77 -0
- data/lib/caliper/entities/lis/status.rb +19 -0
- data/lib/caliper/entities/media/audio_object.rb +21 -0
- data/lib/caliper/entities/media/image_object.rb +21 -0
- data/lib/caliper/entities/media/media_location.rb +23 -0
- data/lib/caliper/entities/media/media_object.rb +38 -0
- data/lib/caliper/entities/media/video_object.rb +21 -0
- data/lib/caliper/entities/reading/epub_volume.rb +15 -7
- data/lib/caliper/entities/reading/frame.rb +7 -15
- data/lib/caliper/entities/response/fillin_blank_response.rb +20 -0
- data/lib/caliper/entities/response/multiple_choice_response.rb +20 -0
- data/lib/caliper/entities/response/multiple_response_response.rb +20 -0
- data/lib/caliper/entities/response/response.rb +23 -0
- data/lib/caliper/entities/response/response_type.rb +13 -0
- data/lib/caliper/entities/response/select_type_response.rb +20 -0
- data/lib/caliper/entities/response/true_false_response.rb +21 -0
- data/lib/caliper/entities/schemadotorg/software_application.rb +8 -8
- data/lib/caliper/entities/session.rb +25 -17
- data/lib/caliper/entities/software_application.rb +16 -7
- data/lib/caliper/entities/web_page.rb +2 -0
- data/lib/caliper/entity_envelope.rb +21 -0
- data/lib/caliper/event/annotation_event.rb +10 -6
- data/lib/caliper/event/assessment_event.rb +19 -0
- data/lib/caliper/event/assessment_item_event.rb +19 -0
- data/lib/caliper/event/assignable_event.rb +19 -0
- data/lib/caliper/event/event.rb +70 -50
- data/lib/caliper/event/jsonable.rb +55 -0
- data/lib/caliper/event/navigation_event.rb +2 -7
- data/lib/caliper/event/outcome_event.rb +1 -1
- data/lib/caliper/event/session_event.rb +13 -14
- data/lib/caliper/event/view_event.rb +6 -7
- data/lib/caliper/event_envelope.rb +22 -0
- data/lib/caliper/jsonable.rb +53 -0
- data/lib/caliper/profiles/annotation_profile.rb +56 -53
- data/lib/caliper/profiles/assessment_profile.rb +48 -0
- data/lib/caliper/profiles/assignable_profile.rb +44 -0
- data/lib/caliper/profiles/media_profile.rb +54 -0
- data/lib/caliper/profiles/profile.rb +38 -38
- data/lib/caliper/profiles/reading_profile.rb +31 -28
- data/lib/caliper/profiles/session_profile.rb +17 -18
- data/lib/caliper/request/event_store_requestor.rb +26 -26
- data/lib/caliper/sensor.rb +46 -35
- data/lib/caliper/version.rb +1 -1
- data/spec/lib/entities/entity.json +9 -0
- data/spec/lib/entities/entity_spec.rb +37 -0
- data/spec/lib/entities/lis/person_spec.rb +37 -0
- data/spec/lib/entities/lis/student.json +11 -0
- data/spec/lib/event/annotation_event_bookmark_spec.rb +159 -0
- data/spec/lib/event/annotation_event_highlight_spec.rb +160 -0
- data/spec/lib/event/annotation_event_shared_spec.rb +172 -0
- data/spec/lib/event/annotation_event_tag_spec.rb +159 -0
- data/spec/lib/event/assessment_event_spec.rb +207 -0
- data/spec/lib/event/assessment_item_completed_event_spec.rb +223 -0
- data/spec/lib/event/assessment_item_started_event_spec.rb +207 -0
- data/spec/lib/event/media_event_spec.rb +157 -0
- data/spec/lib/event/navigated_event_spec.rb +160 -0
- data/spec/lib/event/session_event_login_spec.rb +160 -0
- data/spec/lib/event/session_event_logout_spec.rb +145 -0
- data/spec/lib/event/session_event_timeout_spec.rb +145 -0
- data/spec/lib/event/viewed_event_spec.rb +149 -0
- data/spec/lib/event_helper.rb +145 -0
- data/spec/lib/sensor_spec.rb +30 -0
- data/spec/spec_helper.rb +3 -2
- metadata +84 -61
- data/lib/caliper/client.rb +0 -33
- data/lib/caliper/consumer/base.rb +0 -46
- data/lib/caliper/consumer/queue.rb +0 -40
- data/lib/caliper/consumer/socket.rb +0 -132
- data/lib/caliper/entities/annotation/text_position_selector.rb +0 -14
- data/lib/caliper/entities/schemadotorg/audio_object.rb +0 -15
- data/lib/caliper/entities/schemadotorg/image_object.rb +0 -15
- data/lib/caliper/entities/schemadotorg/media_object.rb +0 -19
- data/lib/caliper/entities/schemadotorg/video_object.rb +0 -15
- data/lib/caliper/event/.shared.rb.swp +0 -0
- data/spec/lib/client_spec.rb +0 -35
- data/spec/lib/consumer/base_spec.rb +0 -28
- data/spec/lib/consumer/queue_spec.rb +0 -16
- data/spec/lib/event/annotation_spec.rb +0 -12
- data/spec/lib/event/bookmarked_spec.rb +0 -17
- data/spec/lib/event/commented_spec.rb +0 -19
- data/spec/lib/event/highlighted_spec.rb +0 -18
- data/spec/lib/event/navigation_spec.rb +0 -15
- data/spec/lib/event/shared_spec.rb +0 -18
- data/spec/lib/event/tagged_spec.rb +0 -17
- data/spec/lib/event/used_spec.rb +0 -15
- data/spec/lib/event/viewed_spec.rb +0 -15
- data/test/caliper/events/session_login_event_test.rb +0 -58
- data/test/caliper/events/session_logout_event_test.rb +0 -55
- data/test/caliper/events/session_timeout_event_test.rb +0 -55
- data/test/caliper/request/http_requestor_test.rb +0 -59
- data/test/caliper/test_event.rb +0 -53
- data/test/caliper/test_utils.rb +0 -198
- data/test/fixtures/caliper_session_login_event.json +0 -71
- data/test/fixtures/caliper_session_logout_event.json +0 -52
- data/test/fixtures/caliper_session_timeout_event.json +0 -52
- data/test/fixtures/event_store_payload.json +0 -85
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'require_all'
|
2
|
+
require_all 'lib/caliper/entities/entity.rb'
|
3
|
+
require_all 'lib/caliper/entities/web_page.rb'
|
4
|
+
require_all 'lib/caliper/entities/software_application.rb'
|
5
|
+
require_all 'lib/caliper/entities/lis/person.rb'
|
6
|
+
require_all 'lib/caliper/entities/lis/membership.rb'
|
7
|
+
require_all 'lib/caliper/entities/lis/roles.rb'
|
8
|
+
require_all 'lib/caliper/entities/lis/status.rb'
|
9
|
+
require_all 'lib/caliper/entities/lis/course_section.rb'
|
10
|
+
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
11
|
+
require_all 'lib/caliper/entities/lis/group.rb'
|
12
|
+
require_all 'lib/caliper/entities/reading/epub_volume.rb'
|
13
|
+
require_all 'lib/caliper/event/navigation_event.rb'
|
14
|
+
require_all 'lib/caliper/profiles/reading_profile.rb'
|
15
|
+
require 'json_spec'
|
16
|
+
|
17
|
+
module Caliper
|
18
|
+
module Event
|
19
|
+
|
20
|
+
describe NavigationEvent do
|
21
|
+
|
22
|
+
it 'should ensure that a Navigation Event is correctly created and serialized' do
|
23
|
+
|
24
|
+
# The Actor (Person/Student))
|
25
|
+
student = Caliper::Entities::LIS::Person.new
|
26
|
+
student.id = 'https://some-university.edu/user/554433'
|
27
|
+
membership1 = Caliper::Entities::LIS::Membership.new
|
28
|
+
membership1.id = "https://some-university.edu/membership/001"
|
29
|
+
membership1.member = "https://some-university.edu/user/554433"
|
30
|
+
membership1.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
31
|
+
membership1.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
32
|
+
membership1.status = Caliper::Entities::LIS::Status::ACTIVE
|
33
|
+
membership1.dateCreated = "2015-08-01T06:00:00.000Z"
|
34
|
+
membership1.dateModified = nil;
|
35
|
+
membership2 = Caliper::Entities::LIS::Membership.new
|
36
|
+
membership2.id = "https://some-university.edu/membership/002"
|
37
|
+
membership2.member = "https://some-university.edu/user/554433"
|
38
|
+
membership2.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
39
|
+
membership2.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
40
|
+
membership2.status = Caliper::Entities::LIS::Status::ACTIVE
|
41
|
+
membership2.dateCreated = "2015-08-01T06:00:00.000Z"
|
42
|
+
membership2.dateModified = nil
|
43
|
+
membership3 = Caliper::Entities::LIS::Membership.new
|
44
|
+
membership3.id = "https://some-university.edu/membership/003"
|
45
|
+
membership3.member = "https://some-university.edu/user/554433"
|
46
|
+
membership3.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
47
|
+
membership3.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
48
|
+
membership3.status = Caliper::Entities::LIS::Status::ACTIVE
|
49
|
+
membership3.dateCreated = "2015-08-01T06:00:00.000Z"
|
50
|
+
membership3.dateModified = nil
|
51
|
+
student.hasMembership = [membership1, membership2, membership3]
|
52
|
+
student.dateCreated = '2015-08-01T06:00:00.000Z'
|
53
|
+
student.dateModified = '2015-09-02T11:30:00.000Z'
|
54
|
+
# puts "new student = #{student.to_json}"
|
55
|
+
|
56
|
+
# The Action
|
57
|
+
action = Caliper::Profiles::ReadingActions::NAVIGATED_TO
|
58
|
+
|
59
|
+
# The Object navigated (ePub Volume)
|
60
|
+
ePubVolume = Caliper::Entities::Reading::EPubVolume.new
|
61
|
+
ePubVolume.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3)'
|
62
|
+
ePubVolume.name = 'The Glorious Cause: The American Revolution, 1763-1789 (Oxford History of the United States)'
|
63
|
+
ePubVolume.version = '2nd ed.'
|
64
|
+
ePubVolume.dateCreated = '2015-08-01T06:00:00.000Z'
|
65
|
+
ePubVolume.dateModified = '2015-09-02T11:30:00.000Z'
|
66
|
+
|
67
|
+
# The Target within the Object (frame)
|
68
|
+
frame = Caliper::Entities::Reading::Frame.new
|
69
|
+
frame.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/1)'
|
70
|
+
frame.name = 'Key Figures: George Washington'
|
71
|
+
frame.version = '2nd ed.'
|
72
|
+
frame.dateCreated = '2015-08-01T06:00:00.000Z'
|
73
|
+
frame.dateModified = '2015-09-02T11:30:00.000Z'
|
74
|
+
frame.index = 1
|
75
|
+
frame.isPartOf = ePubVolume.id
|
76
|
+
|
77
|
+
# The course that is part of the Learning Context (edApp)
|
78
|
+
edApp = Caliper::Entities::SoftwareApplication.new
|
79
|
+
edApp.id = 'https://github.com/readium/readium-js-viewer'
|
80
|
+
edApp.name = 'Readium'
|
81
|
+
edApp.hasMembership = []
|
82
|
+
edApp.dateCreated = '2015-08-01T06:00:00.000Z'
|
83
|
+
edApp.dateModified = '2015-09-02T11:30:00.000Z'
|
84
|
+
|
85
|
+
#LIS Course Offering
|
86
|
+
courseOffering = Caliper::Entities::LIS::CourseOffering.new
|
87
|
+
courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
88
|
+
courseOffering.name = "Political Science 101: The American Revolution"
|
89
|
+
courseOffering.courseNumber = "POL101"
|
90
|
+
courseOffering.academicSession = "Fall-2015"
|
91
|
+
courseOffering.membership = []
|
92
|
+
courseOffering.subOrganizationOf = nil
|
93
|
+
courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
|
94
|
+
courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
|
95
|
+
|
96
|
+
# The LIS Course Section for the Caliper Event
|
97
|
+
course = Caliper::Entities::LIS::CourseSection.new
|
98
|
+
course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
99
|
+
course.name = 'American Revolution 101'
|
100
|
+
course.courseNumber = "POL101"
|
101
|
+
course.academicSession = "Fall-2015"
|
102
|
+
course.category = nil
|
103
|
+
course.membership = [membership2]
|
104
|
+
course.subOrganizationOf = courseOffering
|
105
|
+
course.dateCreated = '2015-08-01T06:00:00.000Z'
|
106
|
+
course.dateModified = '2015-09-02T11:30:00.000Z'
|
107
|
+
|
108
|
+
# LIS Group
|
109
|
+
group = Caliper::Entities::LIS::Group.new
|
110
|
+
group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
111
|
+
group.name = "Discussion Group 001"
|
112
|
+
group.membership = [membership3]
|
113
|
+
group.subOrganizationOf = course
|
114
|
+
group.dateCreated = '2015-08-01T06:00:00.000Z'
|
115
|
+
group.dateModified = nil
|
116
|
+
|
117
|
+
# The navigatedFrom property (specific to Navigation Event)
|
118
|
+
fromPage = Caliper::Entities::WebPage.new
|
119
|
+
fromPage.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/index.html'
|
120
|
+
fromPage.name = 'American Revolution 101 Landing Page'
|
121
|
+
fromPage.dateCreated = '2015-08-01T06:00:00.000Z'
|
122
|
+
fromPage.dateModified = '2015-09-02T11:30:00.000Z'
|
123
|
+
fromPage.isPartOf = nil
|
124
|
+
fromPage.version = '1.0'
|
125
|
+
|
126
|
+
# The (Reading::BookmarkReading) Event
|
127
|
+
navigated_event = Caliper::Event::NavigationEvent.new
|
128
|
+
navigated_event.actor = student
|
129
|
+
navigated_event.action = action
|
130
|
+
navigated_event.object = ePubVolume
|
131
|
+
navigated_event.target = frame
|
132
|
+
navigated_event.generated = nil
|
133
|
+
navigated_event.edApp = edApp
|
134
|
+
navigated_event.group = group
|
135
|
+
navigated_event.navigatedFrom = fromPage
|
136
|
+
navigated_event.startedAtTime = '2015-09-15T10:15:00.000Z'
|
137
|
+
navigated_event.endedAtTime = nil
|
138
|
+
navigated_event.duration = nil
|
139
|
+
# puts "Event JSON = #{navigated_event.to_json}'"
|
140
|
+
|
141
|
+
# Load JSON from caliper-common-fixtures for comparison
|
142
|
+
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
143
|
+
file = File.read('spec/fixtures/caliperNavigationEvent.json')
|
144
|
+
data_hash = JSON.parse(file)
|
145
|
+
expected_json = data_hash.to_json # convert hash back to JSON string after parse
|
146
|
+
navigated_event.to_json.should be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
|
147
|
+
|
148
|
+
# puts "JSON from file = #{data_hash}"
|
149
|
+
deser_navigated_event = Caliper::Event::NavigationEvent.new
|
150
|
+
deser_navigated_event.from_json data_hash
|
151
|
+
# puts "ReadingEvent from JSON = #{deser_navigated_event.to_json}"
|
152
|
+
|
153
|
+
# Ensure that the deserialized shared event object conforms
|
154
|
+
expect(navigated_event).to eql(deser_navigated_event)
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'require_all'
|
2
|
+
require_all 'lib/caliper/entities/entity.rb'
|
3
|
+
require_all 'lib/caliper/entities/session.rb'
|
4
|
+
require_all 'lib/caliper/entities/software_application.rb'
|
5
|
+
require_all 'lib/caliper/entities/lis/person.rb'
|
6
|
+
require_all 'lib/caliper/entities/lis/membership.rb'
|
7
|
+
require_all 'lib/caliper/entities/lis/roles.rb'
|
8
|
+
require_all 'lib/caliper/entities/lis/status.rb'
|
9
|
+
require_all 'lib/caliper/entities/lis/course_section.rb'
|
10
|
+
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
11
|
+
require_all 'lib/caliper/entities/lis/group.rb'
|
12
|
+
require_all 'lib/caliper/entities/reading/epub_volume.rb'
|
13
|
+
require_all 'lib/caliper/entities/reading/frame.rb'
|
14
|
+
require_all 'lib/caliper/event/session_event.rb'
|
15
|
+
require_all 'lib/caliper/profiles/session_profile.rb'
|
16
|
+
require 'json_spec'
|
17
|
+
|
18
|
+
module Caliper
|
19
|
+
module Event
|
20
|
+
|
21
|
+
describe SessionEvent do
|
22
|
+
|
23
|
+
it 'should ensure that a SessionEvent (login) is correctly created and serialized' do
|
24
|
+
|
25
|
+
# The Actor (Person/Student))
|
26
|
+
student = Caliper::Entities::LIS::Person.new
|
27
|
+
student.id = 'https://some-university.edu/user/554433'
|
28
|
+
membership1 = Caliper::Entities::LIS::Membership.new
|
29
|
+
membership1.id = "https://some-university.edu/membership/001"
|
30
|
+
membership1.member = "https://some-university.edu/user/554433"
|
31
|
+
membership1.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
32
|
+
membership1.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
33
|
+
membership1.status = Caliper::Entities::LIS::Status::ACTIVE
|
34
|
+
membership1.dateCreated = "2015-08-01T06:00:00.000Z"
|
35
|
+
membership1.dateModified = nil;
|
36
|
+
membership2 = Caliper::Entities::LIS::Membership.new
|
37
|
+
membership2.id = "https://some-university.edu/membership/002"
|
38
|
+
membership2.member = "https://some-university.edu/user/554433"
|
39
|
+
membership2.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
40
|
+
membership2.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
41
|
+
membership2.status = Caliper::Entities::LIS::Status::ACTIVE
|
42
|
+
membership2.dateCreated = "2015-08-01T06:00:00.000Z"
|
43
|
+
membership2.dateModified = nil
|
44
|
+
membership3 = Caliper::Entities::LIS::Membership.new
|
45
|
+
membership3.id = "https://some-university.edu/membership/003"
|
46
|
+
membership3.member = "https://some-university.edu/user/554433"
|
47
|
+
membership3.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
48
|
+
membership3.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
49
|
+
membership3.status = Caliper::Entities::LIS::Status::ACTIVE
|
50
|
+
membership3.dateCreated = "2015-08-01T06:00:00.000Z"
|
51
|
+
membership3.dateModified = nil
|
52
|
+
student.hasMembership = [membership1, membership2, membership3]
|
53
|
+
student.dateCreated = '2015-08-01T06:00:00.000Z'
|
54
|
+
student.dateModified = '2015-09-02T11:30:00.000Z'
|
55
|
+
# puts "new student = #{student.to_json}"
|
56
|
+
|
57
|
+
# The Action
|
58
|
+
action = Caliper::Profiles::SessionActions::LOGGED_IN
|
59
|
+
|
60
|
+
# The Object (edApp)
|
61
|
+
edApp = Caliper::Entities::SoftwareApplication.new
|
62
|
+
edApp.id = 'https://github.com/readium/readium-js-viewer'
|
63
|
+
edApp.name = 'Readium'
|
64
|
+
edApp.hasMembership = []
|
65
|
+
edApp.dateCreated = '2015-08-01T06:00:00.000Z'
|
66
|
+
edApp.dateModified = '2015-09-02T11:30:00.000Z'
|
67
|
+
|
68
|
+
# The Target (Frame)
|
69
|
+
ePubVolume = Caliper::Entities::Reading::EPubVolume.new
|
70
|
+
ePubVolume.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3)'
|
71
|
+
ePubVolume.name = 'The Glorious Cause: The American Revolution, 1763-1789 (Oxford History of the United States)'
|
72
|
+
ePubVolume.version = '2nd ed.'
|
73
|
+
ePubVolume.dateCreated = '2015-08-01T06:00:00.000Z'
|
74
|
+
ePubVolume.dateModified = '2015-09-02T11:30:00.000Z'
|
75
|
+
|
76
|
+
frame = Caliper::Entities::Reading::Frame.new
|
77
|
+
frame.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/1)'
|
78
|
+
frame.name = 'Key Figures: George Washington'
|
79
|
+
frame.version = '2nd ed.'
|
80
|
+
frame.dateCreated = '2015-08-01T06:00:00.000Z'
|
81
|
+
frame.dateModified = '2015-09-02T11:30:00.000Z'
|
82
|
+
frame.index = 1
|
83
|
+
frame.isPartOf = ePubVolume.id
|
84
|
+
|
85
|
+
# The Generated (Session)
|
86
|
+
session = Caliper::Entities::Session.new
|
87
|
+
session.id = 'https://github.com/readium/session-123456789'
|
88
|
+
session.name = 'session-123456789'
|
89
|
+
session.description = nil
|
90
|
+
session.actor = student
|
91
|
+
session.startedAtTime = '2015-09-15T10:15:00.000Z'
|
92
|
+
session.endedAtTime = nil
|
93
|
+
session.duration = nil
|
94
|
+
session.dateCreated = '2015-08-01T06:00:00.000Z'
|
95
|
+
session.dateModified = '2015-09-02T11:30:00.000Z'
|
96
|
+
|
97
|
+
#LIS Course Offering
|
98
|
+
courseOffering = Caliper::Entities::LIS::CourseOffering.new
|
99
|
+
courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
100
|
+
courseOffering.name = "Political Science 101: The American Revolution"
|
101
|
+
courseOffering.courseNumber = "POL101"
|
102
|
+
courseOffering.academicSession = "Fall-2015"
|
103
|
+
courseOffering.membership = []
|
104
|
+
courseOffering.subOrganizationOf = nil
|
105
|
+
courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
|
106
|
+
courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
|
107
|
+
|
108
|
+
# The LIS Course Section for the Caliper Event
|
109
|
+
course = Caliper::Entities::LIS::CourseSection.new
|
110
|
+
course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
111
|
+
course.name = 'American Revolution 101'
|
112
|
+
course.courseNumber = "POL101"
|
113
|
+
course.academicSession = "Fall-2015"
|
114
|
+
course.category = nil
|
115
|
+
course.membership = [membership2]
|
116
|
+
course.subOrganizationOf = courseOffering
|
117
|
+
course.dateCreated = '2015-08-01T06:00:00.000Z'
|
118
|
+
course.dateModified = '2015-09-02T11:30:00.000Z'
|
119
|
+
|
120
|
+
# LIS Group
|
121
|
+
group = Caliper::Entities::LIS::Group.new
|
122
|
+
group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
123
|
+
group.name = "Discussion Group 001"
|
124
|
+
group.membership = [membership3]
|
125
|
+
group.subOrganizationOf = course
|
126
|
+
group.dateCreated = '2015-08-01T06:00:00.000Z'
|
127
|
+
group.dateModified = nil
|
128
|
+
|
129
|
+
# The (Session) Event
|
130
|
+
session_event = SessionEvent.new
|
131
|
+
session_event.actor = student
|
132
|
+
session_event.action = action
|
133
|
+
session_event.object = edApp
|
134
|
+
session_event.target = frame
|
135
|
+
session_event.generated = session
|
136
|
+
session_event.edApp = edApp
|
137
|
+
session_event.group = group
|
138
|
+
session_event.startedAtTime = '2015-09-15T10:15:00.000Z'
|
139
|
+
# puts "Event JSON = #{session_event.to_json}'"
|
140
|
+
|
141
|
+
# Load JSON from caliper-common-fixtures for comparison
|
142
|
+
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
143
|
+
file = File.read('spec/fixtures/caliperSessionLoginEvent.json')
|
144
|
+
data_hash = JSON.parse(file)
|
145
|
+
expected_json = data_hash.to_json # convert hash back to JSON string after parse
|
146
|
+
session_event.to_json.should be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
|
147
|
+
|
148
|
+
# puts "JSON from file = #{data_hash}"
|
149
|
+
deser_session_event = SessionEvent.new
|
150
|
+
deser_session_event.from_json data_hash
|
151
|
+
# puts "SessionEvent from JSON = #{deser_session_event.to_json}"
|
152
|
+
|
153
|
+
# Ensure that the deserialized session event object conforms
|
154
|
+
expect(session_event).to eql(deser_session_event)
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'require_all'
|
2
|
+
require_all 'lib/caliper/entities/entity.rb'
|
3
|
+
require_all 'lib/caliper/entities/session.rb'
|
4
|
+
require_all 'lib/caliper/entities/software_application.rb'
|
5
|
+
require_all 'lib/caliper/entities/lis/person.rb'
|
6
|
+
require_all 'lib/caliper/entities/lis/membership.rb'
|
7
|
+
require_all 'lib/caliper/entities/lis/roles.rb'
|
8
|
+
require_all 'lib/caliper/entities/lis/status.rb'
|
9
|
+
require_all 'lib/caliper/entities/lis/course_section.rb'
|
10
|
+
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
11
|
+
require_all 'lib/caliper/entities/lis/group.rb'
|
12
|
+
require_all 'lib/caliper/entities/reading/epub_volume.rb'
|
13
|
+
require_all 'lib/caliper/entities/reading/frame.rb'
|
14
|
+
require_all 'lib/caliper/event/session_event.rb'
|
15
|
+
require_all 'lib/caliper/profiles/session_profile.rb'
|
16
|
+
require 'json_spec'
|
17
|
+
|
18
|
+
module Caliper
|
19
|
+
module Event
|
20
|
+
|
21
|
+
describe SessionEvent do
|
22
|
+
|
23
|
+
it 'should ensure that a SessionEvent (logout) is correctly created and serialized' do
|
24
|
+
|
25
|
+
# The Actor (Person/Student))
|
26
|
+
student = Caliper::Entities::LIS::Person.new
|
27
|
+
student.id = 'https://some-university.edu/user/554433'
|
28
|
+
membership1 = Caliper::Entities::LIS::Membership.new
|
29
|
+
membership1.id = "https://some-university.edu/membership/001"
|
30
|
+
membership1.member = "https://some-university.edu/user/554433"
|
31
|
+
membership1.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
32
|
+
membership1.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
33
|
+
membership1.status = Caliper::Entities::LIS::Status::ACTIVE
|
34
|
+
membership1.dateCreated = "2015-08-01T06:00:00.000Z"
|
35
|
+
membership1.dateModified = nil;
|
36
|
+
membership2 = Caliper::Entities::LIS::Membership.new
|
37
|
+
membership2.id = "https://some-university.edu/membership/002"
|
38
|
+
membership2.member = "https://some-university.edu/user/554433"
|
39
|
+
membership2.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
40
|
+
membership2.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
41
|
+
membership2.status = Caliper::Entities::LIS::Status::ACTIVE
|
42
|
+
membership2.dateCreated = "2015-08-01T06:00:00.000Z"
|
43
|
+
membership2.dateModified = nil
|
44
|
+
membership3 = Caliper::Entities::LIS::Membership.new
|
45
|
+
membership3.id = "https://some-university.edu/membership/003"
|
46
|
+
membership3.member = "https://some-university.edu/user/554433"
|
47
|
+
membership3.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
48
|
+
membership3.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
49
|
+
membership3.status = Caliper::Entities::LIS::Status::ACTIVE
|
50
|
+
membership3.dateCreated = "2015-08-01T06:00:00.000Z"
|
51
|
+
membership3.dateModified = nil
|
52
|
+
student.hasMembership = [membership1, membership2, membership3]
|
53
|
+
student.dateCreated = '2015-08-01T06:00:00.000Z'
|
54
|
+
student.dateModified = '2015-09-02T11:30:00.000Z'
|
55
|
+
# puts "new student = #{student.to_json}"
|
56
|
+
|
57
|
+
# The Action
|
58
|
+
action = Caliper::Profiles::SessionActions::LOGGED_OUT
|
59
|
+
|
60
|
+
# The Object (edApp)
|
61
|
+
edApp = Caliper::Entities::SoftwareApplication.new
|
62
|
+
edApp.id = 'https://github.com/readium/readium-js-viewer'
|
63
|
+
edApp.name = 'Readium'
|
64
|
+
edApp.hasMembership = []
|
65
|
+
edApp.dateCreated = '2015-08-01T06:00:00.000Z'
|
66
|
+
edApp.dateModified = '2015-09-02T11:30:00.000Z'
|
67
|
+
|
68
|
+
# The Target (Session)
|
69
|
+
session = Caliper::Entities::Session.new
|
70
|
+
session.id = 'https://github.com/readium/session-123456789'
|
71
|
+
session.name = 'session-123456789'
|
72
|
+
session.description = nil
|
73
|
+
session.actor = student
|
74
|
+
session.startedAtTime = '2015-09-15T10:15:00.000Z'
|
75
|
+
session.endedAtTime = '2015-09-15T11:05:00.000Z'
|
76
|
+
session.duration = 'PT3000S'
|
77
|
+
session.dateCreated = '2015-08-01T06:00:00.000Z'
|
78
|
+
session.dateModified = '2015-09-02T11:30:00.000Z'
|
79
|
+
|
80
|
+
#LIS Course Offering
|
81
|
+
courseOffering = Caliper::Entities::LIS::CourseOffering.new
|
82
|
+
courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
83
|
+
courseOffering.name = "Political Science 101: The American Revolution"
|
84
|
+
courseOffering.courseNumber = "POL101"
|
85
|
+
courseOffering.academicSession = "Fall-2015"
|
86
|
+
courseOffering.membership = []
|
87
|
+
courseOffering.subOrganizationOf = nil
|
88
|
+
courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
|
89
|
+
courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
|
90
|
+
|
91
|
+
# The LIS Course Section for the Caliper Event
|
92
|
+
course = Caliper::Entities::LIS::CourseSection.new
|
93
|
+
course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
94
|
+
course.name = 'American Revolution 101'
|
95
|
+
course.courseNumber = "POL101"
|
96
|
+
course.academicSession = "Fall-2015"
|
97
|
+
course.category = nil
|
98
|
+
course.membership = [membership2]
|
99
|
+
course.subOrganizationOf = courseOffering
|
100
|
+
course.dateCreated = '2015-08-01T06:00:00.000Z'
|
101
|
+
course.dateModified = '2015-09-02T11:30:00.000Z'
|
102
|
+
|
103
|
+
# LIS Group
|
104
|
+
group = Caliper::Entities::LIS::Group.new
|
105
|
+
group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
106
|
+
group.name = "Discussion Group 001"
|
107
|
+
group.membership = [membership3]
|
108
|
+
group.subOrganizationOf = course
|
109
|
+
group.dateCreated = '2015-08-01T06:00:00.000Z'
|
110
|
+
group.dateModified = nil
|
111
|
+
|
112
|
+
# The (Session) Event
|
113
|
+
session_event = SessionEvent.new
|
114
|
+
session_event.actor = student
|
115
|
+
session_event.action = action
|
116
|
+
session_event.object = edApp
|
117
|
+
session_event.target = session
|
118
|
+
session_event.generated = nil
|
119
|
+
session_event.edApp = edApp
|
120
|
+
session_event.group = group
|
121
|
+
session_event.startedAtTime = '2015-09-15T10:15:00.000Z'
|
122
|
+
session_event.endedAtTime = '2015-09-15T11:05:00.000Z'
|
123
|
+
session_event.duration = 'PT3000S'
|
124
|
+
# puts "Event JSON = #{session_event.to_json}'"
|
125
|
+
|
126
|
+
# Load JSON from caliper-common-fixtures for comparison
|
127
|
+
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
128
|
+
file = File.read('spec/fixtures/caliperSessionLogoutEvent.json')
|
129
|
+
data_hash = JSON.parse(file)
|
130
|
+
expected_json = data_hash.to_json # convert hash back to JSON string after parse
|
131
|
+
session_event.to_json.should be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
|
132
|
+
|
133
|
+
# puts "JSON from file = #{data_hash}"
|
134
|
+
deser_session_event = SessionEvent.new
|
135
|
+
deser_session_event.from_json data_hash
|
136
|
+
# puts "SessionEvent from JSON = #{deser_session_event.to_json}"
|
137
|
+
|
138
|
+
# Ensure that the deserialized session event object conforms
|
139
|
+
expect(session_event).to eql(deser_session_event)
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|