ims_caliper 0.9.3.14 → 0.9.3.15
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 +5 -13
- data/lib/caliper/defaults.rb +2 -2
- data/lib/caliper/entities/agent/organization.rb +3 -3
- data/lib/caliper/entities/assessment/assessment.rb +0 -2
- data/lib/caliper/entities/entity.rb +0 -1
- data/lib/caliper/entities/foaf/agent.rb +1 -1
- data/lib/caliper/entities/lis/course_offering.rb +0 -1
- data/lib/caliper/entities/lis/group.rb +1 -2
- data/lib/caliper/entities/lis/{roles.rb → role.rb} +1 -1
- data/lib/caliper/entities/outcome/result.rb +3 -3
- data/lib/caliper/entities/response/fillin_blank_response.rb +1 -0
- data/lib/caliper/entities/response/multiple_choice_response.rb +1 -0
- data/lib/caliper/entities/response/multiple_response_response.rb +1 -0
- data/lib/caliper/entities/response/response.rb +1 -0
- data/lib/caliper/entities/response/select_type_response.rb +1 -0
- data/lib/caliper/entities/response/true_false_response.rb +1 -0
- data/lib/caliper/event/annotation_event.rb +1 -0
- data/lib/caliper/event/event.rb +28 -26
- data/lib/caliper/event/view_event.rb +1 -0
- data/lib/caliper/jsonable.rb +2 -1
- data/lib/caliper/options.rb +11 -11
- data/lib/caliper/profiles/assessment_profile.rb +0 -1
- data/lib/caliper/{event/grade_predict_event.rb → request/envelope.rb} +21 -11
- data/lib/caliper/request/envelope_jsonable.rb +69 -0
- data/lib/caliper/request/event_store_requestor.rb +16 -27
- data/lib/caliper/request/http_requestor.rb +8 -27
- data/lib/caliper/sensor.rb +12 -23
- data/lib/caliper/version.rb +1 -1
- data/spec/lib/entities/agent/person_spec.rb +1 -1
- data/spec/lib/entities/entity_spec.rb +1 -1
- data/spec/lib/event/annotation_event_bookmark_spec.rb +81 -98
- data/spec/lib/event/annotation_event_highlight_spec.rb +81 -98
- data/spec/lib/event/annotation_event_shared_spec.rb +81 -100
- data/spec/lib/event/annotation_event_tag_spec.rb +81 -98
- data/spec/lib/event/assessment_event_spec.rb +64 -124
- data/spec/lib/event/assessment_item_completed_event_spec.rb +93 -138
- data/spec/lib/event/assessment_item_started_event_spec.rb +92 -139
- data/spec/lib/event/assignable_event_spec.rb +65 -129
- data/spec/lib/event/media_event_spec.rb +77 -94
- data/spec/lib/event/navigated_event_spec.rb +90 -108
- data/spec/lib/event/session_event_login_spec.rb +98 -108
- data/spec/lib/event/session_event_logout_spec.rb +66 -81
- data/spec/lib/event/session_event_timeout_spec.rb +62 -88
- data/spec/lib/event/viewed_event_spec.rb +74 -92
- data/spec/lib/event_helper.rb +89 -109
- data/spec/lib/request/http_requestor_spec.rb +170 -0
- data/spec/lib/sensor_spec.rb +9 -29
- metadata +10 -11
- data/lib/caliper/entities/outcome/predicted_grade.rb +0 -43
- data/lib/caliper/entity_envelope.rb +0 -33
- data/lib/caliper/event_envelope.rb +0 -33
- data/lib/caliper/request/event_store_envelope.rb +0 -27
@@ -20,7 +20,7 @@ require_all 'lib/caliper/entities/entity.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'
|
23
|
-
require_all 'lib/caliper/entities/lis/
|
23
|
+
require_all 'lib/caliper/entities/lis/role.rb'
|
24
24
|
require_all 'lib/caliper/entities/lis/status.rb'
|
25
25
|
require_all 'lib/caliper/entities/lis/course_section.rb'
|
26
26
|
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
@@ -37,121 +37,95 @@ module Caliper
|
|
37
37
|
|
38
38
|
it 'should ensure that a TimedOut SessionEvent is correctly created and serialized' do
|
39
39
|
|
40
|
-
#
|
40
|
+
# EdApp
|
41
|
+
ed_app = Caliper::Entities::Agent::SoftwareApplication.new
|
42
|
+
ed_app.id = 'https://github.com/readium/readium-js-viewer'
|
43
|
+
ed_app.name = 'Readium'
|
44
|
+
ed_app.dateCreated = '2015-08-01T06:00:00.000Z'
|
45
|
+
ed_app.dateModified = '2015-09-02T11:30:00.000Z'
|
46
|
+
|
47
|
+
# Actor (edApp)
|
48
|
+
actor = ed_app
|
49
|
+
|
50
|
+
# Action
|
51
|
+
action = Caliper::Profiles::SessionActions::TIMED_OUT
|
52
|
+
|
53
|
+
# Object session actor (session.actor)
|
41
54
|
student = Caliper::Entities::Agent::Person.new
|
42
55
|
student.id = 'https://some-university.edu/user/554433'
|
43
|
-
membership1 = Caliper::Entities::LIS::Membership.new
|
44
|
-
membership1.id = "https://some-university.edu/membership/001"
|
45
|
-
membership1.member = "https://some-university.edu/user/554433"
|
46
|
-
membership1.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
47
|
-
membership1.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
48
|
-
membership1.status = Caliper::Entities::LIS::Status::ACTIVE
|
49
|
-
membership1.dateCreated = "2015-08-01T06:00:00.000Z"
|
50
|
-
membership1.dateModified = nil;
|
51
|
-
membership2 = Caliper::Entities::LIS::Membership.new
|
52
|
-
membership2.id = "https://some-university.edu/membership/002"
|
53
|
-
membership2.member = "https://some-university.edu/user/554433"
|
54
|
-
membership2.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
55
|
-
membership2.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
56
|
-
membership2.status = Caliper::Entities::LIS::Status::ACTIVE
|
57
|
-
membership2.dateCreated = "2015-08-01T06:00:00.000Z"
|
58
|
-
membership2.dateModified = nil
|
59
|
-
membership3 = Caliper::Entities::LIS::Membership.new
|
60
|
-
membership3.id = "https://some-university.edu/membership/003"
|
61
|
-
membership3.member = "https://some-university.edu/user/554433"
|
62
|
-
membership3.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
63
|
-
membership3.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
64
|
-
membership3.status = Caliper::Entities::LIS::Status::ACTIVE
|
65
|
-
membership3.dateCreated = "2015-08-01T06:00:00.000Z"
|
66
|
-
membership3.dateModified = nil
|
67
|
-
student.hasMembership = [membership1, membership2, membership3]
|
68
56
|
student.dateCreated = '2015-08-01T06:00:00.000Z'
|
69
57
|
student.dateModified = '2015-09-02T11:30:00.000Z'
|
70
|
-
# puts "new student = #{student.to_json}"
|
71
58
|
|
72
|
-
#
|
73
|
-
|
59
|
+
# Object
|
60
|
+
obj = Caliper::Entities::Session::Session.new
|
61
|
+
obj.id = 'https://github.com/readium/session-123456789'
|
62
|
+
obj.name = 'session-123456789'
|
63
|
+
obj.description = nil
|
64
|
+
obj.actor = student
|
65
|
+
obj.startedAtTime = '2015-09-15T10:15:00.000Z'
|
66
|
+
obj.endedAtTime = '2015-09-15T11:05:00.000Z'
|
67
|
+
obj.duration = 'PT3000S'
|
68
|
+
obj.dateCreated = '2015-08-01T06:00:00.000Z'
|
69
|
+
obj.dateModified = '2015-09-02T11:30:00.000Z'
|
74
70
|
|
75
|
-
#
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
edApp.hasMembership = []
|
80
|
-
edApp.dateCreated = '2015-08-01T06:00:00.000Z'
|
81
|
-
edApp.dateModified = '2015-09-02T11:30:00.000Z'
|
82
|
-
|
83
|
-
# The Target (Session)
|
84
|
-
session = Caliper::Entities::Session::Session.new
|
85
|
-
session.id = 'https://github.com/readium/session-123456789'
|
86
|
-
session.name = 'session-123456789'
|
87
|
-
session.description = nil
|
88
|
-
session.actor = student
|
89
|
-
session.startedAtTime = '2015-09-15T10:15:00.000Z'
|
90
|
-
session.endedAtTime = '2015-09-15T11:05:00.000Z'
|
91
|
-
session.duration = 'PT3000S'
|
92
|
-
session.dateCreated = '2015-08-01T06:00:00.000Z'
|
93
|
-
session.dateModified = '2015-09-02T11:30:00.000Z'
|
94
|
-
|
95
|
-
#LIS Course Offering
|
96
|
-
courseOffering = Caliper::Entities::LIS::CourseOffering.new
|
97
|
-
courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
98
|
-
courseOffering.name = "Political Science 101: The American Revolution"
|
99
|
-
courseOffering.courseNumber = "POL101"
|
100
|
-
courseOffering.academicSession = "Fall-2015"
|
101
|
-
courseOffering.membership = []
|
102
|
-
courseOffering.subOrganizationOf = nil
|
103
|
-
courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
|
104
|
-
courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
|
105
|
-
|
106
|
-
# The LIS Course Section for the Caliper Event
|
107
|
-
course = Caliper::Entities::LIS::CourseSection.new
|
108
|
-
course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
109
|
-
course.name = 'American Revolution 101'
|
71
|
+
# LIS Course Offering
|
72
|
+
course = Caliper::Entities::LIS::CourseOffering.new
|
73
|
+
course.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
74
|
+
course.name = "Political Science 101: The American Revolution"
|
110
75
|
course.courseNumber = "POL101"
|
111
76
|
course.academicSession = "Fall-2015"
|
112
|
-
course.
|
113
|
-
course.membership = [membership2]
|
114
|
-
course.subOrganizationOf = courseOffering
|
77
|
+
course.subOrganizationOf = nil
|
115
78
|
course.dateCreated = '2015-08-01T06:00:00.000Z'
|
116
79
|
course.dateModified = '2015-09-02T11:30:00.000Z'
|
117
80
|
|
81
|
+
# LIS Course Section
|
82
|
+
section = Caliper::Entities::LIS::CourseSection.new
|
83
|
+
section.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
84
|
+
section.name = 'American Revolution 101'
|
85
|
+
section.courseNumber = "POL101"
|
86
|
+
section.academicSession = "Fall-2015"
|
87
|
+
section.category = nil
|
88
|
+
section.subOrganizationOf = course
|
89
|
+
section.dateCreated = '2015-08-01T06:00:00.000Z'
|
90
|
+
section.dateModified = '2015-09-02T11:30:00.000Z'
|
91
|
+
|
118
92
|
# LIS Group
|
119
93
|
group = Caliper::Entities::LIS::Group.new
|
120
94
|
group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
121
95
|
group.name = "Discussion Group 001"
|
122
|
-
group.
|
123
|
-
group.subOrganizationOf = course
|
96
|
+
group.subOrganizationOf = section
|
124
97
|
group.dateCreated = '2015-08-01T06:00:00.000Z'
|
125
98
|
group.dateModified = nil
|
126
99
|
|
127
|
-
#
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
100
|
+
# Create the Event
|
101
|
+
event = SessionEvent.new
|
102
|
+
event.actor = ed_app
|
103
|
+
event.action = action
|
104
|
+
event.object = obj
|
105
|
+
event.target = nil
|
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'
|
110
|
+
event.edApp = ed_app
|
111
|
+
event.group = group
|
112
|
+
event.membership = nil
|
113
|
+
# puts "Event JSON = #{event.to_json}'"
|
140
114
|
|
141
115
|
# Load JSON from caliper-common-fixtures for comparison
|
142
116
|
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
143
117
|
file = File.read('spec/fixtures/caliperSessionTimeoutEvent.json')
|
144
118
|
data_hash = JSON.parse(file)
|
145
119
|
expected_json = data_hash.to_json # convert hash back to JSON string after parse
|
146
|
-
|
120
|
+
expect(event.to_json).to be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
|
147
121
|
|
148
122
|
# puts "JSON from file = #{data_hash}"
|
149
|
-
|
150
|
-
|
151
|
-
# puts "SessionEvent from JSON = #{
|
123
|
+
deser_event = SessionEvent.new
|
124
|
+
deser_event.from_json data_hash
|
125
|
+
# puts "SessionEvent from JSON = #{deser_event.to_json}"
|
152
126
|
|
153
127
|
# Ensure that the deserialized session event object conforms
|
154
|
-
expect(
|
128
|
+
expect(event).to eql(deser_event)
|
155
129
|
end
|
156
130
|
end
|
157
131
|
end
|
@@ -20,7 +20,7 @@ require_all 'lib/caliper/entities/entity.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'
|
23
|
-
require_all 'lib/caliper/entities/lis/
|
23
|
+
require_all 'lib/caliper/entities/lis/role.rb'
|
24
24
|
require_all 'lib/caliper/entities/lis/status.rb'
|
25
25
|
require_all 'lib/caliper/entities/lis/course_section.rb'
|
26
26
|
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
@@ -37,127 +37,109 @@ module Caliper
|
|
37
37
|
|
38
38
|
it 'should ensure that a ViewedEvent is correctly created and serialized' do
|
39
39
|
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
membership1.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
48
|
-
membership1.status = Caliper::Entities::LIS::Status::ACTIVE
|
49
|
-
membership1.dateCreated = "2015-08-01T06:00:00.000Z"
|
50
|
-
membership1.dateModified = nil;
|
51
|
-
membership2 = Caliper::Entities::LIS::Membership.new
|
52
|
-
membership2.id = "https://some-university.edu/membership/002"
|
53
|
-
membership2.member = "https://some-university.edu/user/554433"
|
54
|
-
membership2.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
55
|
-
membership2.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
56
|
-
membership2.status = Caliper::Entities::LIS::Status::ACTIVE
|
57
|
-
membership2.dateCreated = "2015-08-01T06:00:00.000Z"
|
58
|
-
membership2.dateModified = nil
|
59
|
-
membership3 = Caliper::Entities::LIS::Membership.new
|
60
|
-
membership3.id = "https://some-university.edu/membership/003"
|
61
|
-
membership3.member = "https://some-university.edu/user/554433"
|
62
|
-
membership3.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
63
|
-
membership3.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
64
|
-
membership3.status = Caliper::Entities::LIS::Status::ACTIVE
|
65
|
-
membership3.dateCreated = "2015-08-01T06:00:00.000Z"
|
66
|
-
membership3.dateModified = nil
|
67
|
-
student.hasMembership = [membership1, membership2, membership3]
|
68
|
-
student.dateCreated = '2015-08-01T06:00:00.000Z'
|
69
|
-
student.dateModified = '2015-09-02T11:30:00.000Z'
|
70
|
-
# puts "new student = #{student.to_json}"
|
71
|
-
|
72
|
-
# The Action
|
40
|
+
# Actor
|
41
|
+
actor = Caliper::Entities::Agent::Person.new
|
42
|
+
actor.id = 'https://some-university.edu/user/554433'
|
43
|
+
actor.dateCreated = '2015-08-01T06:00:00.000Z'
|
44
|
+
actor.dateModified = '2015-09-02T11:30:00.000Z'
|
45
|
+
|
46
|
+
# Action
|
73
47
|
action = Caliper::Profiles::ReadingActions::VIEWED
|
74
48
|
|
75
|
-
#
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
49
|
+
# Object
|
50
|
+
obj = Caliper::Entities::Reading::EPubVolume.new
|
51
|
+
obj.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3)'
|
52
|
+
obj.name = 'The Glorious Cause: The American Revolution, 1763-1789 (Oxford History of the United States)'
|
53
|
+
obj.version = '2nd ed.'
|
54
|
+
obj.dateCreated = '2015-08-01T06:00:00.000Z'
|
55
|
+
obj.dateModified = '2015-09-02T11:30:00.000Z'
|
82
56
|
|
83
|
-
#
|
57
|
+
# Target frame
|
84
58
|
frame = Caliper::Entities::Reading::Frame.new
|
85
59
|
frame.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/1)'
|
86
60
|
frame.name = 'Key Figures: George Washington'
|
87
|
-
frame.
|
61
|
+
frame.isPartOf = obj
|
62
|
+
frame.version = obj.version
|
63
|
+
frame.index = 1
|
88
64
|
frame.dateCreated = '2015-08-01T06:00:00.000Z'
|
89
65
|
frame.dateModified = '2015-09-02T11:30:00.000Z'
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
courseOffering = Caliper::Entities::LIS::CourseOffering.new
|
103
|
-
courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
104
|
-
courseOffering.name = "Political Science 101: The American Revolution"
|
105
|
-
courseOffering.courseNumber = "POL101"
|
106
|
-
courseOffering.academicSession = "Fall-2015"
|
107
|
-
courseOffering.membership = []
|
108
|
-
courseOffering.subOrganizationOf = nil
|
109
|
-
courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
|
110
|
-
courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
|
111
|
-
|
112
|
-
# The LIS Course Section for the Caliper Event
|
113
|
-
course = Caliper::Entities::LIS::CourseSection.new
|
114
|
-
course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
115
|
-
course.name = 'American Revolution 101'
|
66
|
+
|
67
|
+
# EdApp
|
68
|
+
ed_app = Caliper::Entities::Agent::SoftwareApplication.new
|
69
|
+
ed_app.id = 'https://github.com/readium/readium-js-viewer'
|
70
|
+
ed_app.name = 'Readium'
|
71
|
+
ed_app.dateCreated = '2015-08-01T06:00:00.000Z'
|
72
|
+
ed_app.dateModified = '2015-09-02T11:30:00.000Z'
|
73
|
+
|
74
|
+
# LIS Course Offering
|
75
|
+
course = Caliper::Entities::LIS::CourseOffering.new
|
76
|
+
course.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
77
|
+
course.name = "Political Science 101: The American Revolution"
|
116
78
|
course.courseNumber = "POL101"
|
117
79
|
course.academicSession = "Fall-2015"
|
118
|
-
course.
|
119
|
-
course.membership = [membership2]
|
120
|
-
course.subOrganizationOf = courseOffering
|
80
|
+
course.subOrganizationOf = nil
|
121
81
|
course.dateCreated = '2015-08-01T06:00:00.000Z'
|
122
82
|
course.dateModified = '2015-09-02T11:30:00.000Z'
|
123
83
|
|
84
|
+
# LIS Course Section
|
85
|
+
section = Caliper::Entities::LIS::CourseSection.new
|
86
|
+
section.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
87
|
+
section.name = 'American Revolution 101'
|
88
|
+
section.courseNumber = "POL101"
|
89
|
+
section.academicSession = "Fall-2015"
|
90
|
+
section.category = nil
|
91
|
+
section.subOrganizationOf = course
|
92
|
+
section.dateCreated = '2015-08-01T06:00:00.000Z'
|
93
|
+
section.dateModified = '2015-09-02T11:30:00.000Z'
|
94
|
+
|
124
95
|
# LIS Group
|
125
96
|
group = Caliper::Entities::LIS::Group.new
|
126
97
|
group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
127
98
|
group.name = "Discussion Group 001"
|
128
|
-
group.
|
129
|
-
group.subOrganizationOf = course
|
99
|
+
group.subOrganizationOf = section
|
130
100
|
group.dateCreated = '2015-08-01T06:00:00.000Z'
|
131
101
|
group.dateModified = nil
|
132
102
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
103
|
+
membership = Caliper::Entities::LIS::Membership.new
|
104
|
+
membership.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/roster/554433"
|
105
|
+
membership.name = "American Revolution 101"
|
106
|
+
membership.description = "Roster entry"
|
107
|
+
membership.member = "https://some-university.edu/user/554433"
|
108
|
+
membership.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
109
|
+
membership.roles = [Caliper::Entities::LIS::Role::LEARNER]
|
110
|
+
membership.status = Caliper::Entities::LIS::Status::ACTIVE
|
111
|
+
membership.dateCreated = "2015-08-01T06:00:00.000Z"
|
112
|
+
membership.dateModified = nil
|
113
|
+
|
114
|
+
# Create Event
|
115
|
+
event = Caliper::Event::ViewEvent.new
|
116
|
+
event.actor = actor
|
117
|
+
event.action = action
|
118
|
+
event.object = obj
|
119
|
+
event.target = frame
|
120
|
+
event.generated = nil
|
121
|
+
event.startedAtTime = '2015-09-15T10:15:00.000Z'
|
122
|
+
event.endedAtTime = nil
|
123
|
+
event.duration = nil
|
124
|
+
event.edApp = ed_app
|
125
|
+
event.group = group
|
126
|
+
event.membership = membership
|
127
|
+
# puts "Event JSON = #{event.to_json}'"
|
146
128
|
|
147
129
|
# Load JSON from caliper-common-fixtures for comparison
|
148
130
|
# NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
|
149
131
|
file = File.read('spec/fixtures/caliperViewEvent.json')
|
150
132
|
data_hash = JSON.parse(file)
|
151
133
|
expected_json = data_hash.to_json # convert hash back to JSON string after parse
|
152
|
-
|
134
|
+
expect(event.to_json).to be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
|
153
135
|
|
154
136
|
# puts "JSON from file = #{data_hash}"
|
155
|
-
|
156
|
-
|
157
|
-
# puts "ReadingEvent from JSON = #{
|
137
|
+
deser_event = Caliper::Event::ViewEvent.new
|
138
|
+
deser_event.from_json data_hash
|
139
|
+
# puts "ReadingEvent from JSON = #{deser_event.to_json}"
|
158
140
|
|
159
141
|
# Ensure that the deserialized shared event object conforms
|
160
|
-
expect(
|
142
|
+
expect(event).to eql(deser_event)
|
161
143
|
end
|
162
144
|
end
|
163
145
|
end
|
data/spec/lib/event_helper.rb
CHANGED
@@ -20,7 +20,7 @@ require_all 'lib/caliper/entities/entity.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'
|
23
|
-
require_all 'lib/caliper/entities/lis/
|
23
|
+
require_all 'lib/caliper/entities/lis/role.rb'
|
24
24
|
require_all 'lib/caliper/entities/lis/status.rb'
|
25
25
|
require_all 'lib/caliper/entities/lis/course_section.rb'
|
26
26
|
require_all 'lib/caliper/entities/lis/course_offering.rb'
|
@@ -35,127 +35,107 @@ module Helper
|
|
35
35
|
|
36
36
|
def session_event
|
37
37
|
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
membership2.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
53
|
-
membership2.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
54
|
-
membership2.status = Caliper::Entities::LIS::Status::ACTIVE
|
55
|
-
membership2.dateCreated = "2015-08-01T06:00:00.000Z"
|
56
|
-
membership2.dateModified = nil
|
57
|
-
membership3 = Caliper::Entities::LIS::Membership.new
|
58
|
-
membership3.id = "https://some-university.edu/membership/003"
|
59
|
-
membership3.member = "https://some-university.edu/user/554433"
|
60
|
-
membership3.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
61
|
-
membership3.roles = [Caliper::Entities::LIS::Roles::LEARNER]
|
62
|
-
membership3.status = Caliper::Entities::LIS::Status::ACTIVE
|
63
|
-
membership3.dateCreated = "2015-08-01T06:00:00.000Z"
|
64
|
-
membership3.dateModified = nil
|
65
|
-
student.hasMembership = [membership1, membership2, membership3]
|
66
|
-
student.dateCreated = '2015-08-01T06:00:00.000Z'
|
67
|
-
student.dateModified = '2015-09-02T11:30:00.000Z'
|
68
|
-
# puts "new student = #{student.to_json}"
|
69
|
-
|
70
|
-
# The Action
|
38
|
+
# Edapp
|
39
|
+
ed_app = Caliper::Entities::Agent::SoftwareApplication.new
|
40
|
+
ed_app.id = 'https://github.com/readium/readium-js-viewer'
|
41
|
+
ed_app.name = 'Readium'
|
42
|
+
ed_app.dateCreated = '2015-08-01T06:00:00.000Z'
|
43
|
+
ed_app.dateModified = '2015-09-02T11:30:00.000Z'
|
44
|
+
|
45
|
+
# Actor
|
46
|
+
actor = Caliper::Entities::Agent::Person.new
|
47
|
+
actor.id = 'https://some-university.edu/user/554433'
|
48
|
+
actor.dateCreated = '2015-08-01T06:00:00.000Z'
|
49
|
+
actor.dateModified = '2015-09-02T11:30:00.000Z'
|
50
|
+
|
51
|
+
# Action
|
71
52
|
action = Caliper::Profiles::SessionActions::LOGGED_IN;
|
72
53
|
|
73
|
-
#
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
edApp = Caliper::Entities::Agent::SoftwareApplication.new
|
111
|
-
edApp.id = 'https://github.com/readium/readium-js-viewer'
|
112
|
-
edApp.name = 'Readium'
|
113
|
-
edApp.hasMembership = []
|
114
|
-
edApp.dateCreated = '2015-08-01T06:00:00.000Z'
|
115
|
-
edApp.dateModified = '2015-09-02T11:30:00.000Z'
|
116
|
-
|
117
|
-
#LIS Course Offering
|
118
|
-
courseOffering = Caliper::Entities::LIS::CourseOffering.new
|
119
|
-
courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
120
|
-
courseOffering.name = "Political Science 101: The American Revolution"
|
121
|
-
courseOffering.courseNumber = "POL101"
|
122
|
-
courseOffering.academicSession = "Fall-2015"
|
123
|
-
courseOffering.membership = []
|
124
|
-
courseOffering.subOrganizationOf = nil
|
125
|
-
courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
|
126
|
-
courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
|
127
|
-
|
128
|
-
# The LIS Course Section for the Caliper Event
|
129
|
-
course = Caliper::Entities::LIS::CourseSection.new
|
130
|
-
course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
131
|
-
course.name = 'American Revolution 101'
|
54
|
+
# Object
|
55
|
+
obj = ed_app
|
56
|
+
|
57
|
+
# ePub parent (frame.isPartOf)
|
58
|
+
ePub = Caliper::Entities::Reading::EPubVolume.new
|
59
|
+
ePub.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3)'
|
60
|
+
ePub.name = 'The Glorious Cause: The American Revolution, 1763-1789 (Oxford History of the United States)'
|
61
|
+
ePub.version = '2nd ed.'
|
62
|
+
ePub.dateCreated = '2015-08-01T06:00:00.000Z'
|
63
|
+
ePub.dateModified = '2015-09-02T11:30:00.000Z'
|
64
|
+
|
65
|
+
# Target frame
|
66
|
+
target = Caliper::Entities::Reading::Frame.new
|
67
|
+
target.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/1)'
|
68
|
+
target.name = 'Key Figures: George Washington'
|
69
|
+
target.isPartOf = ePub
|
70
|
+
target.version = ePub.version
|
71
|
+
target.index = 1
|
72
|
+
target.dateCreated = '2015-08-01T06:00:00.000Z'
|
73
|
+
target.dateModified = '2015-09-02T11:30:00.000Z'
|
74
|
+
|
75
|
+
# Generated session
|
76
|
+
generated = Caliper::Entities::Session::Session.new
|
77
|
+
generated.id = 'https://github.com/readium/session-123456789'
|
78
|
+
generated.name = 'session-123456789'
|
79
|
+
generated.description = nil
|
80
|
+
generated.actor = actor
|
81
|
+
generated.startedAtTime = '2015-09-15T10:15:00.000Z'
|
82
|
+
generated.endedAtTime = nil
|
83
|
+
generated.duration = nil
|
84
|
+
generated.dateCreated = '2015-08-01T06:00:00.000Z'
|
85
|
+
generated.dateModified = '2015-09-02T11:30:00.000Z'
|
86
|
+
|
87
|
+
# LIS Course Offering
|
88
|
+
course = Caliper::Entities::LIS::CourseOffering.new
|
89
|
+
course.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
|
90
|
+
course.name = "Political Science 101: The American Revolution"
|
132
91
|
course.courseNumber = "POL101"
|
133
92
|
course.academicSession = "Fall-2015"
|
134
|
-
course.
|
135
|
-
course.membership = [membership2]
|
136
|
-
course.subOrganizationOf = courseOffering
|
93
|
+
course.subOrganizationOf = nil
|
137
94
|
course.dateCreated = '2015-08-01T06:00:00.000Z'
|
138
95
|
course.dateModified = '2015-09-02T11:30:00.000Z'
|
139
96
|
|
97
|
+
# LIS Course Section
|
98
|
+
section = Caliper::Entities::LIS::CourseSection.new
|
99
|
+
section.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
|
100
|
+
section.name = 'American Revolution 101'
|
101
|
+
section.courseNumber = "POL101"
|
102
|
+
section.academicSession = "Fall-2015"
|
103
|
+
section.category = nil
|
104
|
+
section.subOrganizationOf = course
|
105
|
+
section.dateCreated = '2015-08-01T06:00:00.000Z'
|
106
|
+
section.dateModified = '2015-09-02T11:30:00.000Z'
|
107
|
+
|
140
108
|
# LIS Group
|
141
109
|
group = Caliper::Entities::LIS::Group.new
|
142
110
|
group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
|
143
111
|
group.name = "Discussion Group 001"
|
144
|
-
group.
|
145
|
-
group.subOrganizationOf = course
|
112
|
+
group.subOrganizationOf = section
|
146
113
|
group.dateCreated = '2015-08-01T06:00:00.000Z'
|
147
114
|
group.dateModified = nil
|
148
115
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
116
|
+
membership = Caliper::Entities::LIS::Membership.new
|
117
|
+
membership.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/roster/554433"
|
118
|
+
membership.name = "American Revolution 101"
|
119
|
+
membership.description = "Roster entry"
|
120
|
+
membership.member = "https://some-university.edu/user/554433"
|
121
|
+
membership.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
|
122
|
+
membership.roles = [Caliper::Entities::LIS::Role::LEARNER]
|
123
|
+
membership.status = Caliper::Entities::LIS::Status::ACTIVE
|
124
|
+
membership.dateCreated = "2015-08-01T06:00:00.000Z"
|
125
|
+
membership.dateModified = nil
|
126
|
+
|
127
|
+
# Create the Event
|
128
|
+
event = Caliper::Event::SessionEvent.new
|
129
|
+
event.actor = actor
|
130
|
+
event.action = action
|
131
|
+
event.object = obj
|
132
|
+
event.target = target
|
133
|
+
event.generated = generated
|
134
|
+
event.startedAtTime = '2015-09-15T10:15:00.000Z'
|
135
|
+
event.edApp = ed_app
|
136
|
+
event.group = course
|
137
|
+
event.membership = membership
|
138
|
+
|
139
|
+
return event
|
160
140
|
end
|
161
141
|
end
|