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.
Files changed (131) hide show
  1. checksums.yaml +8 -8
  2. data/.gitignore +37 -0
  3. data/.idea/caliper-ruby.iml +98 -0
  4. data/.idea/encodings.xml +5 -0
  5. data/.idea/misc.xml +5 -0
  6. data/.idea/modules.xml +9 -0
  7. data/.idea/scopes/scope_settings.xml +5 -0
  8. data/.idea/vcs.xml +7 -0
  9. data/Gemfile +12 -1
  10. data/Gemfile.lock +42 -1
  11. data/LICENSE +67 -0
  12. data/NOTICE +15 -0
  13. data/README.md +13 -5
  14. data/caliper.gemspec +2 -8
  15. data/lib/caliper/defaults.rb +4 -4
  16. data/lib/caliper/entities/annotation/annotation.rb +14 -4
  17. data/lib/caliper/entities/annotation/bookmark_annotation.rb +14 -4
  18. data/lib/caliper/entities/annotation/highlight_annotation.rb +14 -3
  19. data/lib/caliper/entities/annotation/shared_annotation.rb +12 -3
  20. data/lib/caliper/entities/annotation/tag_annotation.rb +13 -3
  21. data/lib/caliper/entities/assessment/assessment.rb +27 -0
  22. data/lib/caliper/entities/assessment/assessment_item.rb +26 -0
  23. data/lib/caliper/entities/assignable/assignable_digital_resource.rb +47 -0
  24. data/lib/caliper/entities/assignable/attempt.rb +32 -0
  25. data/lib/caliper/entities/digital_resource.rb +36 -35
  26. data/lib/caliper/entities/entity.rb +50 -36
  27. data/lib/caliper/entities/foaf/agent.rb +1 -1
  28. data/lib/caliper/entities/jsonable.rb +56 -0
  29. data/lib/caliper/entities/learning_objective.rb +26 -0
  30. data/lib/caliper/entities/lis/course_offering.rb +30 -0
  31. data/lib/caliper/entities/lis/course_section.rb +27 -15
  32. data/lib/caliper/entities/lis/group.rb +27 -0
  33. data/lib/caliper/entities/lis/membership.rb +32 -0
  34. data/lib/caliper/entities/lis/organization.rb +20 -17
  35. data/lib/caliper/entities/lis/person.rb +23 -10
  36. data/lib/caliper/entities/lis/roles.rb +77 -0
  37. data/lib/caliper/entities/lis/status.rb +19 -0
  38. data/lib/caliper/entities/media/audio_object.rb +21 -0
  39. data/lib/caliper/entities/media/image_object.rb +21 -0
  40. data/lib/caliper/entities/media/media_location.rb +23 -0
  41. data/lib/caliper/entities/media/media_object.rb +38 -0
  42. data/lib/caliper/entities/media/video_object.rb +21 -0
  43. data/lib/caliper/entities/reading/epub_volume.rb +15 -7
  44. data/lib/caliper/entities/reading/frame.rb +7 -15
  45. data/lib/caliper/entities/response/fillin_blank_response.rb +20 -0
  46. data/lib/caliper/entities/response/multiple_choice_response.rb +20 -0
  47. data/lib/caliper/entities/response/multiple_response_response.rb +20 -0
  48. data/lib/caliper/entities/response/response.rb +23 -0
  49. data/lib/caliper/entities/response/response_type.rb +13 -0
  50. data/lib/caliper/entities/response/select_type_response.rb +20 -0
  51. data/lib/caliper/entities/response/true_false_response.rb +21 -0
  52. data/lib/caliper/entities/schemadotorg/software_application.rb +8 -8
  53. data/lib/caliper/entities/session.rb +25 -17
  54. data/lib/caliper/entities/software_application.rb +16 -7
  55. data/lib/caliper/entities/web_page.rb +2 -0
  56. data/lib/caliper/entity_envelope.rb +21 -0
  57. data/lib/caliper/event/annotation_event.rb +10 -6
  58. data/lib/caliper/event/assessment_event.rb +19 -0
  59. data/lib/caliper/event/assessment_item_event.rb +19 -0
  60. data/lib/caliper/event/assignable_event.rb +19 -0
  61. data/lib/caliper/event/event.rb +70 -50
  62. data/lib/caliper/event/jsonable.rb +55 -0
  63. data/lib/caliper/event/navigation_event.rb +2 -7
  64. data/lib/caliper/event/outcome_event.rb +1 -1
  65. data/lib/caliper/event/session_event.rb +13 -14
  66. data/lib/caliper/event/view_event.rb +6 -7
  67. data/lib/caliper/event_envelope.rb +22 -0
  68. data/lib/caliper/jsonable.rb +53 -0
  69. data/lib/caliper/profiles/annotation_profile.rb +56 -53
  70. data/lib/caliper/profiles/assessment_profile.rb +48 -0
  71. data/lib/caliper/profiles/assignable_profile.rb +44 -0
  72. data/lib/caliper/profiles/media_profile.rb +54 -0
  73. data/lib/caliper/profiles/profile.rb +38 -38
  74. data/lib/caliper/profiles/reading_profile.rb +31 -28
  75. data/lib/caliper/profiles/session_profile.rb +17 -18
  76. data/lib/caliper/request/event_store_requestor.rb +26 -26
  77. data/lib/caliper/sensor.rb +46 -35
  78. data/lib/caliper/version.rb +1 -1
  79. data/spec/lib/entities/entity.json +9 -0
  80. data/spec/lib/entities/entity_spec.rb +37 -0
  81. data/spec/lib/entities/lis/person_spec.rb +37 -0
  82. data/spec/lib/entities/lis/student.json +11 -0
  83. data/spec/lib/event/annotation_event_bookmark_spec.rb +159 -0
  84. data/spec/lib/event/annotation_event_highlight_spec.rb +160 -0
  85. data/spec/lib/event/annotation_event_shared_spec.rb +172 -0
  86. data/spec/lib/event/annotation_event_tag_spec.rb +159 -0
  87. data/spec/lib/event/assessment_event_spec.rb +207 -0
  88. data/spec/lib/event/assessment_item_completed_event_spec.rb +223 -0
  89. data/spec/lib/event/assessment_item_started_event_spec.rb +207 -0
  90. data/spec/lib/event/media_event_spec.rb +157 -0
  91. data/spec/lib/event/navigated_event_spec.rb +160 -0
  92. data/spec/lib/event/session_event_login_spec.rb +160 -0
  93. data/spec/lib/event/session_event_logout_spec.rb +145 -0
  94. data/spec/lib/event/session_event_timeout_spec.rb +145 -0
  95. data/spec/lib/event/viewed_event_spec.rb +149 -0
  96. data/spec/lib/event_helper.rb +145 -0
  97. data/spec/lib/sensor_spec.rb +30 -0
  98. data/spec/spec_helper.rb +3 -2
  99. metadata +84 -61
  100. data/lib/caliper/client.rb +0 -33
  101. data/lib/caliper/consumer/base.rb +0 -46
  102. data/lib/caliper/consumer/queue.rb +0 -40
  103. data/lib/caliper/consumer/socket.rb +0 -132
  104. data/lib/caliper/entities/annotation/text_position_selector.rb +0 -14
  105. data/lib/caliper/entities/schemadotorg/audio_object.rb +0 -15
  106. data/lib/caliper/entities/schemadotorg/image_object.rb +0 -15
  107. data/lib/caliper/entities/schemadotorg/media_object.rb +0 -19
  108. data/lib/caliper/entities/schemadotorg/video_object.rb +0 -15
  109. data/lib/caliper/event/.shared.rb.swp +0 -0
  110. data/spec/lib/client_spec.rb +0 -35
  111. data/spec/lib/consumer/base_spec.rb +0 -28
  112. data/spec/lib/consumer/queue_spec.rb +0 -16
  113. data/spec/lib/event/annotation_spec.rb +0 -12
  114. data/spec/lib/event/bookmarked_spec.rb +0 -17
  115. data/spec/lib/event/commented_spec.rb +0 -19
  116. data/spec/lib/event/highlighted_spec.rb +0 -18
  117. data/spec/lib/event/navigation_spec.rb +0 -15
  118. data/spec/lib/event/shared_spec.rb +0 -18
  119. data/spec/lib/event/tagged_spec.rb +0 -17
  120. data/spec/lib/event/used_spec.rb +0 -15
  121. data/spec/lib/event/viewed_spec.rb +0 -15
  122. data/test/caliper/events/session_login_event_test.rb +0 -58
  123. data/test/caliper/events/session_logout_event_test.rb +0 -55
  124. data/test/caliper/events/session_timeout_event_test.rb +0 -55
  125. data/test/caliper/request/http_requestor_test.rb +0 -59
  126. data/test/caliper/test_event.rb +0 -53
  127. data/test/caliper/test_utils.rb +0 -198
  128. data/test/fixtures/caliper_session_login_event.json +0 -71
  129. data/test/fixtures/caliper_session_logout_event.json +0 -52
  130. data/test/fixtures/caliper_session_timeout_event.json +0 -52
  131. data/test/fixtures/event_store_payload.json +0 -85
@@ -0,0 +1,172 @@
1
+ require 'require_all'
2
+ require_all 'lib/caliper/entities/entity.rb'
3
+ require_all 'lib/caliper/entities/software_application.rb'
4
+ require_all 'lib/caliper/entities/lis/person.rb'
5
+ require_all 'lib/caliper/entities/lis/membership.rb'
6
+ require_all 'lib/caliper/entities/lis/roles.rb'
7
+ require_all 'lib/caliper/entities/lis/status.rb'
8
+ require_all 'lib/caliper/entities/lis/course_section.rb'
9
+ require_all 'lib/caliper/entities/lis/course_offering.rb'
10
+ require_all 'lib/caliper/entities/lis/group.rb'
11
+ require_all 'lib/caliper/entities/reading/epub_volume.rb'
12
+ require_all 'lib/caliper/entities/annotation/shared_annotation.rb'
13
+ require_all 'lib/caliper/event/annotation_event.rb'
14
+ require_all 'lib/caliper/profiles/annotation_profile.rb'
15
+ require 'json_spec'
16
+
17
+ module Caliper
18
+ module Event
19
+
20
+ describe AnnotationEvent do
21
+
22
+ it 'should ensure that a AnnotationEvent (Shared) 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::AnnotationActions::SHARED
58
+
59
+ # The Object shared (Frame)
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
+ frame = Caliper::Entities::Reading::Frame.new
68
+ frame.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/3)'
69
+ frame.name = 'Key Figures: John Adams'
70
+ frame.version = '2nd ed.'
71
+ frame.dateCreated = '2015-08-01T06:00:00.000Z'
72
+ frame.dateModified = '2015-09-02T11:30:00.000Z'
73
+ frame.index = 3
74
+ frame.isPartOf = ePubVolume.id
75
+
76
+ # The Generated (Annotation::SharedAnnotation)
77
+ shared = Caliper::Entities::Annotation::SharedAnnotation.new
78
+ shared.id = 'https://someEduApp.edu/shared/9999'
79
+ shared.name = nil
80
+ shared.description = nil
81
+ shared.dateCreated = '2015-08-01T06:00:00.000Z'
82
+ shared.dateModified = '2015-09-02T11:30:00.000Z'
83
+ shared.annotated = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/3)'
84
+
85
+ classmate1 = Caliper::Entities::LIS::Person.new
86
+ classmate1.id = 'https://some-university.edu/students/657585'
87
+ classmate1.hasMembership = []
88
+ classmate1.dateCreated = '2015-08-01T06:00:00.000Z'
89
+ classmate1.dateModified = '2015-09-02T11:30:00.000Z'
90
+
91
+ classmate2 = Caliper::Entities::LIS::Person.new
92
+ classmate2.id = 'https://some-university.edu/students/667788'
93
+ classmate2.hasMembership = []
94
+ classmate2.dateCreated = '2015-08-01T06:00:00.000Z'
95
+ classmate2.dateModified = '2015-09-02T11:30:00.000Z'
96
+
97
+ shared.withAgents = [classmate1, classmate2]
98
+
99
+ # The course that is part of the Learning Context (edApp)
100
+ edApp = Caliper::Entities::SoftwareApplication.new
101
+ edApp.id = 'https://github.com/readium/readium-js-viewer'
102
+ edApp.name = 'Readium'
103
+ edApp.hasMembership = []
104
+ edApp.dateCreated = '2015-08-01T06:00:00.000Z'
105
+ edApp.dateModified = '2015-09-02T11:30:00.000Z'
106
+
107
+ #LIS Course Offering
108
+ courseOffering = Caliper::Entities::LIS::CourseOffering.new
109
+ courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
110
+ courseOffering.name = "Political Science 101: The American Revolution"
111
+ courseOffering.courseNumber = "POL101"
112
+ courseOffering.academicSession = "Fall-2015"
113
+ courseOffering.membership = []
114
+ courseOffering.subOrganizationOf = nil
115
+ courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
116
+ courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
117
+
118
+ # The LIS Course Section for the Caliper Event
119
+ course = Caliper::Entities::LIS::CourseSection.new
120
+ course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
121
+ course.name = 'American Revolution 101'
122
+ course.courseNumber = "POL101"
123
+ course.academicSession = "Fall-2015"
124
+ course.category = nil
125
+ course.membership = [membership2]
126
+ course.subOrganizationOf = courseOffering
127
+ course.dateCreated = '2015-08-01T06:00:00.000Z'
128
+ course.dateModified = '2015-09-02T11:30:00.000Z'
129
+
130
+ # LIS Group
131
+ group = Caliper::Entities::LIS::Group.new
132
+ group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
133
+ group.name = "Discussion Group 001"
134
+ group.membership = [membership3]
135
+ group.subOrganizationOf = course
136
+ group.dateCreated = '2015-08-01T06:00:00.000Z'
137
+ group.dateModified = nil
138
+
139
+ # The (Annotation::BookmarkAnnotation) Event
140
+ annotation_event = AnnotationEvent.new
141
+ annotation_event.actor = student
142
+ annotation_event.action = action
143
+ annotation_event.object = frame
144
+ annotation_event.target = nil
145
+ annotation_event.generated = shared
146
+ annotation_event.edApp = edApp
147
+ annotation_event.group = group
148
+ annotation_event.startedAtTime = '2015-09-15T10:15:00.000Z'
149
+ annotation_event.endedAtTime = nil
150
+ annotation_event.duration = nil
151
+ # puts "Event JSON = #{annotation_event.to_json}'"
152
+
153
+ # Load JSON from caliper-common-fixtures for comparison
154
+ # NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
155
+ file = File.read('spec/fixtures/caliperSharedAnnotationEvent.json')
156
+ data_hash = JSON.parse(file)
157
+ expected_json = data_hash.to_json # convert hash back to JSON string after parse
158
+ annotation_event.to_json.should be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
159
+
160
+ # puts "JSON from file = #{data_hash}"
161
+ deser_annotation_event = AnnotationEvent.new
162
+ deser_annotation_event.from_json data_hash
163
+ # puts "AnnotationEvent from JSON = #{deser_annotation_event.to_json}"
164
+
165
+ # Ensure that the deserialized shared event object conforms
166
+ expect(annotation_event).to eql(deser_annotation_event)
167
+
168
+ end
169
+
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,159 @@
1
+ require 'require_all'
2
+ require_all 'lib/caliper/entities/entity.rb'
3
+ require_all 'lib/caliper/entities/software_application.rb'
4
+ require_all 'lib/caliper/entities/lis/person.rb'
5
+ require_all 'lib/caliper/entities/lis/membership.rb'
6
+ require_all 'lib/caliper/entities/lis/roles.rb'
7
+ require_all 'lib/caliper/entities/lis/status.rb'
8
+ require_all 'lib/caliper/entities/lis/course_section.rb'
9
+ require_all 'lib/caliper/entities/lis/course_offering.rb'
10
+ require_all 'lib/caliper/entities/lis/group.rb'
11
+ require_all 'lib/caliper/entities/reading/epub_volume.rb'
12
+ require_all 'lib/caliper/entities/annotation/tag_annotation.rb'
13
+ require_all 'lib/caliper/event/annotation_event.rb'
14
+ require_all 'lib/caliper/profiles/annotation_profile.rb'
15
+ require 'json_spec'
16
+
17
+ module Caliper
18
+ module Event
19
+
20
+ describe AnnotationEvent do
21
+
22
+ it 'should ensure that a AnnotationEvent (Tagged) 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::AnnotationActions::TAGGED
58
+
59
+ # The Object of the tag (Frame)
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
+ frame = Caliper::Entities::Reading::Frame.new
68
+ frame.id = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/4)'
69
+ frame.name = 'The Stamp Act Crisis'
70
+ frame.version = '2nd ed.'
71
+ frame.dateCreated = '2015-08-01T06:00:00.000Z'
72
+ frame.dateModified = '2015-09-02T11:30:00.000Z'
73
+ frame.index = 4
74
+ frame.isPartOf = ePubVolume.id
75
+
76
+ # The Generated (Annotation::BookmarkAnnotation)
77
+ tag = Caliper::Entities::Annotation::TagAnnotation.new
78
+ tag.id = 'https://someEduApp.edu/tags/7654'
79
+ tag.name = nil
80
+ tag.description = nil
81
+ tag.dateCreated = '2015-08-01T06:00:00.000Z'
82
+ tag.dateModified = '2015-09-02T11:30:00.000Z'
83
+ tag.annotated = 'https://github.com/readium/readium-js-viewer/book/34843#epubcfi(/4/3/4)'
84
+ tag.tags = ["to-read", "1765", "shared-with-project-team"]
85
+
86
+ # The course that is part of the Learning Context (edApp)
87
+ edApp = Caliper::Entities::SoftwareApplication.new
88
+ edApp.id = 'https://github.com/readium/readium-js-viewer'
89
+ edApp.name = 'Readium'
90
+ edApp.hasMembership = []
91
+ edApp.dateCreated = '2015-08-01T06:00:00.000Z'
92
+ edApp.dateModified = '2015-09-02T11:30:00.000Z'
93
+
94
+ #LIS Course Offering
95
+ courseOffering = Caliper::Entities::LIS::CourseOffering.new
96
+ courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
97
+ courseOffering.name = "Political Science 101: The American Revolution"
98
+ courseOffering.courseNumber = "POL101"
99
+ courseOffering.academicSession = "Fall-2015"
100
+ courseOffering.membership = []
101
+ courseOffering.subOrganizationOf = nil
102
+ courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
103
+ courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
104
+
105
+ # The LIS Course Section for the Caliper Event
106
+ course = Caliper::Entities::LIS::CourseSection.new
107
+ course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
108
+ course.name = 'American Revolution 101'
109
+ course.courseNumber = "POL101"
110
+ course.academicSession = "Fall-2015"
111
+ course.category = nil
112
+ course.membership = [membership2]
113
+ course.subOrganizationOf = courseOffering
114
+ course.dateCreated = '2015-08-01T06:00:00.000Z'
115
+ course.dateModified = '2015-09-02T11:30:00.000Z'
116
+
117
+ # LIS Group
118
+ group = Caliper::Entities::LIS::Group.new
119
+ group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
120
+ group.name = "Discussion Group 001"
121
+ group.membership = [membership3]
122
+ group.subOrganizationOf = course
123
+ group.dateCreated = '2015-08-01T06:00:00.000Z'
124
+ group.dateModified = nil
125
+
126
+ # The (Annotation::BookmarkAnnotation) Event
127
+ annotation_event = AnnotationEvent.new
128
+ annotation_event.actor = student
129
+ annotation_event.action = action
130
+ annotation_event.object = frame
131
+ annotation_event.target = nil
132
+ annotation_event.generated = tag
133
+ annotation_event.edApp = edApp
134
+ annotation_event.group = group
135
+ annotation_event.startedAtTime = '2015-09-15T10:15:00.000Z'
136
+ annotation_event.endedAtTime = nil
137
+ annotation_event.duration = nil
138
+ # puts "Event JSON = #{annotation_event.to_json}'"
139
+
140
+ # Load JSON from caliper-common-fixtures for comparison
141
+ # NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
142
+ file = File.read('spec/fixtures/caliperTagAnnotationEvent.json')
143
+ data_hash = JSON.parse(file)
144
+ expected_json = data_hash.to_json # convert hash back to JSON string after parse
145
+ annotation_event.to_json.should be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
146
+
147
+ # puts "JSON from file = #{data_hash}"
148
+ deser_annotation_event = AnnotationEvent.new
149
+ deser_annotation_event.from_json data_hash
150
+ # puts "AnnotationEvent from JSON = #{deser_annotation_event.to_json}"
151
+
152
+ # Ensure that the deserialized tag event object conforms
153
+ expect(annotation_event).to eql(deser_annotation_event)
154
+
155
+ end
156
+
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,207 @@
1
+ require 'require_all'
2
+ require_all 'lib/caliper/entities/entity.rb'
3
+ require_all 'lib/caliper/entities/software_application.rb'
4
+ require_all 'lib/caliper/entities/lis/person.rb'
5
+ require_all 'lib/caliper/entities/lis/membership.rb'
6
+ require_all 'lib/caliper/entities/lis/roles.rb'
7
+ require_all 'lib/caliper/entities/lis/status.rb'
8
+ require_all 'lib/caliper/entities/lis/course_section.rb'
9
+ require_all 'lib/caliper/entities/lis/course_offering.rb'
10
+ require_all 'lib/caliper/entities/lis/group.rb'
11
+ require_all 'lib/caliper/entities/reading/epub_volume.rb'
12
+ require_all 'lib/caliper/entities/assessment/assessment.rb'
13
+ require_all 'lib/caliper/entities/assessment/assessment_item.rb'
14
+ require_all 'lib/caliper/entities/assignable/attempt.rb'
15
+ require_all 'lib/caliper/entities/assignable/assignable_digital_resource.rb'
16
+ require_all 'lib/caliper/event/assessment_event.rb'
17
+ require_all 'lib/caliper/profiles/assessment_profile.rb'
18
+ require 'json_spec'
19
+
20
+ module Caliper
21
+ module Event
22
+
23
+ describe AssessmentEvent do
24
+
25
+ it 'should ensure that a AssessmentEvent is correctly created and serialized' do
26
+
27
+ # The Actor = Person/Student))
28
+ student = Caliper::Entities::LIS::Person.new
29
+ student.id = 'https://some-university.edu/user/554433'
30
+ membership1 = Caliper::Entities::LIS::Membership.new
31
+ membership1.id = "https://some-university.edu/membership/001"
32
+ membership1.member = "https://some-university.edu/user/554433"
33
+ membership1.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101"
34
+ membership1.roles = [Caliper::Entities::LIS::Roles::LEARNER]
35
+ membership1.status = Caliper::Entities::LIS::Status::ACTIVE
36
+ membership1.dateCreated = "2015-08-01T06:00:00.000Z"
37
+ membership1.dateModified = nil;
38
+ membership2 = Caliper::Entities::LIS::Membership.new
39
+ membership2.id = "https://some-university.edu/membership/002"
40
+ membership2.member = "https://some-university.edu/user/554433"
41
+ membership2.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001"
42
+ membership2.roles = [Caliper::Entities::LIS::Roles::LEARNER]
43
+ membership2.status = Caliper::Entities::LIS::Status::ACTIVE
44
+ membership2.dateCreated = "2015-08-01T06:00:00.000Z"
45
+ membership2.dateModified = nil
46
+ membership3 = Caliper::Entities::LIS::Membership.new
47
+ membership3.id = "https://some-university.edu/membership/003"
48
+ membership3.member = "https://some-university.edu/user/554433"
49
+ membership3.organization = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
50
+ membership3.roles = [Caliper::Entities::LIS::Roles::LEARNER]
51
+ membership3.status = Caliper::Entities::LIS::Status::ACTIVE
52
+ membership3.dateCreated = "2015-08-01T06:00:00.000Z"
53
+ membership3.dateModified = nil
54
+ student.hasMembership = [membership1, membership2, membership3]
55
+ student.dateCreated = '2015-08-01T06:00:00.000Z'
56
+ student.dateModified = '2015-09-02T11:30:00.000Z'
57
+ # puts "new student = #{student.to_json}"
58
+
59
+ # The Action
60
+ action = Caliper::Profiles::AssessmentActions::STARTED
61
+
62
+ # The Object being interacted with by the Actor = Assessment)
63
+ assessment = Caliper::Entities::Assessment::Assessment.new
64
+ assessment.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/assessment1"
65
+ assessment.name = "American Revolution - Key Figures Assessment"
66
+ assessment.dateModified = '2015-09-02T11:30:00.000Z'
67
+ assessment.dateCreated = '2015-08-01T06:00:00.000Z'
68
+ assessment.datePublished = '2015-08-15T09:30:00.000Z'
69
+ assessment.version = "1.0"
70
+ assessment.dateToActivate = '2015-08-16T05:00:00.000Z'
71
+ assessment.dateToShow = '2015-08-16T05:00:00.000Z'
72
+ assessment.dateToStartOn = "2015-08-16T05:00:00.000Z"
73
+ assessment.dateToSubmit = "2015-09-28T11:59:59.000Z"
74
+ assessment.maxAttempts = 2
75
+ assessment.maxSubmits = 2
76
+ assessment.maxScore = 3.0
77
+
78
+ # The Assessment has three items
79
+ assessmentItem1 = Caliper::Entities::Assessment::AssessmentItem.new
80
+ assessmentItem1.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/assessment1/item1"
81
+ assessmentItem1.name = "Assessment Item 1"
82
+ assessmentItem1.isPartOf = assessment.id
83
+ assessmentItem1.maxAttempts = 2
84
+ assessmentItem1.maxSubmits = 2
85
+ assessmentItem1.maxScore = 1.0
86
+ assessmentItem1.dateCreated = nil
87
+ assessmentItem1.dateModified = nil
88
+ assessmentItem1.version = "1.0"
89
+ assessmentItem1.isTimeDependent = false
90
+
91
+ assessmentItem2 = Caliper::Entities::Assessment::AssessmentItem.new
92
+ assessmentItem2.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/assessment1/item2"
93
+ assessmentItem2.name = "Assessment Item 2"
94
+ assessmentItem2.isPartOf = assessment.id
95
+ assessmentItem2.maxAttempts = 2
96
+ assessmentItem2.maxSubmits = 2
97
+ assessmentItem2.maxScore = 1.0
98
+ assessmentItem2.dateCreated = nil
99
+ assessmentItem2.dateModified = nil
100
+ assessmentItem2.version = "1.0"
101
+ assessmentItem2.isTimeDependent = false
102
+
103
+ assessmentItem3 = Caliper::Entities::Assessment::AssessmentItem.new
104
+ assessmentItem3.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/assessment1/item3"
105
+ assessmentItem3.name = "Assessment Item 3"
106
+ assessmentItem3.isPartOf = assessment.id
107
+ assessmentItem3.maxAttempts = 2
108
+ assessmentItem3.maxSubmits = 2
109
+ assessmentItem3.maxScore = 1.0
110
+ assessmentItem3.dateCreated = nil
111
+ assessmentItem3.dateModified = nil
112
+ assessmentItem3.version = "1.0"
113
+ assessmentItem3.isTimeDependent = false
114
+
115
+ assessment.assessmentItems = [assessmentItem1, assessmentItem2, assessmentItem3]
116
+
117
+ # The target object within the Event Object
118
+ target = nil;
119
+
120
+ # The attempt object = Attempt) within the Event Object
121
+ attempt = Caliper::Entities::Assignable::Attempt.new
122
+ attempt.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/assessment1/attempt1"
123
+ attempt.actor = "https://some-university.edu/user/554433"
124
+ attempt.assignable = "https://some-university.edu/politicalScience/2015/american-revolution-101/assessment1"
125
+ attempt.dateCreated = "2015-08-01T06:00:00.000Z"
126
+ attempt.dateModified = nil
127
+ attempt.count = 1
128
+ attempt.startedAtTime = "2015-09-15T10:15:00.000Z"
129
+ attempt.duration = nil
130
+ attempt.endedAtTime = nil
131
+ attempt.extensions = {}
132
+ attempt.name = nil
133
+
134
+ # The Object (edApp)
135
+ edApp = Caliper::Entities::SoftwareApplication.new
136
+ edApp.id = 'https://com.sat/super-assessment-tool'
137
+ edApp.name = 'Super Assessment Tool'
138
+ edApp.hasMembership = []
139
+ edApp.dateCreated = '2015-08-01T06:00:00.000Z'
140
+ edApp.dateModified = nil
141
+
142
+ #LIS Course Offering
143
+ courseOffering = Caliper::Entities::LIS::CourseOffering.new
144
+ courseOffering.id = "https://some-university.edu/politicalScience/2015/american-revolution-101"
145
+ courseOffering.name = "Political Science 101: The American Revolution"
146
+ courseOffering.courseNumber = "POL101"
147
+ courseOffering.academicSession = "Fall-2015"
148
+ courseOffering.membership = []
149
+ courseOffering.subOrganizationOf = nil
150
+ courseOffering.dateCreated = '2015-08-01T06:00:00.000Z'
151
+ courseOffering.dateModified = '2015-09-02T11:30:00.000Z'
152
+
153
+ # The LIS Course Section for the Caliper Event
154
+ course = Caliper::Entities::LIS::CourseSection.new
155
+ course.id = 'https://some-university.edu/politicalScience/2015/american-revolution-101/section/001'
156
+ course.name = 'American Revolution 101'
157
+ course.courseNumber = "POL101"
158
+ course.academicSession = "Fall-2015"
159
+ course.category = nil
160
+ course.membership = [membership2]
161
+ course.subOrganizationOf = courseOffering
162
+ course.dateCreated = '2015-08-01T06:00:00.000Z'
163
+ course.dateModified = '2015-09-02T11:30:00.000Z'
164
+
165
+ # LIS Group
166
+ group = Caliper::Entities::LIS::Group.new
167
+ group.id = "https://some-university.edu/politicalScience/2015/american-revolution-101/section/001/group/001"
168
+ group.name = "Discussion Group 001"
169
+ group.membership = [membership3]
170
+ group.subOrganizationOf = course
171
+ group.dateCreated = '2015-08-01T06:00:00.000Z'
172
+ group.dateModified = nil
173
+
174
+ # The Assessment Event
175
+ assessment_event = AssessmentEvent.new
176
+ assessment_event.actor = student
177
+ assessment_event.action = action
178
+ assessment_event.object = assessment
179
+ assessment_event.target = nil
180
+ assessment_event.generated = attempt
181
+ assessment_event.edApp = edApp
182
+ assessment_event.group = group
183
+ assessment_event.startedAtTime = '2015-09-15T10:15:00.000Z'
184
+ assessment_event.endedAtTime = nil
185
+ assessment_event.duration = nil
186
+ # puts "Event JSON = #{assessment_event.to_json}'"
187
+
188
+ # Load JSON from caliper-common-fixtures for comparison
189
+ # NOTE - sym link to caliper-common-fixtures needs to exist under spec/fixtures
190
+ file = File.read('spec/fixtures/caliperAssessmentEvent.json')
191
+ data_hash = JSON.parse(file)
192
+ expected_json = data_hash.to_json # convert hash back to JSON string after parse
193
+ assessment_event.to_json.should be_json_eql(expected_json)#.excluding("actor", "action", "object", "target", "generated", "edApp", "group")
194
+
195
+ # puts "JSON from file = #{data_hash}"
196
+ deser_assessment_event = AssessmentEvent.new
197
+ deser_assessment_event.from_json data_hash
198
+ # puts "AssessmentEvent from JSON = #{deser_assessment_event.to_json}"
199
+
200
+ # Ensure that the deserialized bookmark event object conforms
201
+ expect(assessment_event).to eql(deser_assessment_event)
202
+
203
+ end
204
+
205
+ end
206
+ end
207
+ end