ims_caliper 0.9.3.15 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/lib/caliper/{profiles/annotation_profile.rb → actions/annotation_actions.rb} +3 -41
- data/lib/caliper/{profiles/assessment_profile.rb → actions/assessment_actions.rb} +3 -19
- data/lib/caliper/actions/assessment_item_actions.rb +31 -0
- data/lib/caliper/{profiles/assignable_profile.rb → actions/assignable_actions.rb} +3 -28
- data/lib/caliper/{profiles/media_profile.rb → actions/media_actions.rb} +4 -29
- data/lib/caliper/{event/view_event.rb → actions/navigation_actions.rb} +5 -11
- data/lib/caliper/{validators/event_validator_context.rb → actions/outcome_actions.rb} +7 -15
- data/lib/caliper/{event/navigation_event.rb → actions/reading_actions.rb} +6 -14
- data/lib/caliper/actions/session_actions.rb +30 -0
- data/lib/caliper/context/context.rb +31 -0
- data/lib/caliper/entities/agent/organization.rb +4 -3
- data/lib/caliper/entities/agent/person.rb +4 -3
- data/lib/caliper/entities/agent/software_application.rb +4 -3
- data/lib/caliper/entities/annotation/annotation.rb +4 -12
- data/lib/caliper/entities/annotation/annotation_type.rb +32 -0
- data/lib/caliper/entities/annotation/bookmark_annotation.rb +3 -1
- data/lib/caliper/entities/annotation/highlight_annotation.rb +4 -4
- data/lib/caliper/entities/annotation/shared_annotation.rb +3 -1
- data/lib/caliper/entities/annotation/tag_annotation.rb +3 -1
- data/lib/caliper/entities/assessment/assessment.rb +1 -1
- data/lib/caliper/entities/assessment/assessment_item.rb +2 -0
- data/lib/caliper/entities/assignable/assignable_digital_resource.rb +3 -13
- data/lib/caliper/{event/session_event.rb → entities/assignable/assignable_digital_resource_type.rb} +7 -11
- data/lib/caliper/entities/assignable/attempt.rb +8 -9
- data/lib/caliper/entities/digital_resource.rb +5 -22
- data/lib/caliper/entities/digital_resource_type.rb +33 -0
- data/lib/caliper/entities/entity.rb +7 -37
- data/lib/caliper/entities/{learning_context.rb → entity_base.rb} +19 -15
- data/lib/caliper/entities/entity_type.rb +39 -0
- data/lib/caliper/entities/foaf/agent.rb +0 -2
- data/lib/caliper/entities/jsonable.rb +14 -3
- data/lib/caliper/entities/learning_objective.rb +4 -3
- data/lib/caliper/entities/lis/course_offering.rb +9 -6
- data/lib/caliper/entities/lis/course_section.rb +3 -1
- data/lib/caliper/entities/lis/group.rb +5 -3
- data/lib/caliper/entities/lis/membership.rb +5 -7
- data/lib/caliper/entities/media/audio_object.rb +2 -1
- data/lib/caliper/entities/media/image_object.rb +2 -1
- data/lib/caliper/entities/media/media_location.rb +2 -1
- data/lib/caliper/entities/media/media_object.rb +2 -9
- data/lib/caliper/entities/media/media_object_type.rb +31 -0
- data/lib/caliper/entities/media/video_object.rb +2 -1
- data/lib/caliper/entities/outcome/result.rb +23 -16
- data/lib/caliper/entities/reading/epub_chapter.rb +2 -1
- data/lib/caliper/entities/reading/epub_part.rb +2 -1
- data/lib/caliper/entities/reading/epub_sub_chapter.rb +2 -1
- data/lib/caliper/entities/reading/epub_volume.rb +2 -1
- data/lib/caliper/entities/reading/frame.rb +4 -3
- data/lib/caliper/entities/reading/web_page.rb +3 -2
- data/lib/caliper/entities/response/fillin_blank_response.rb +3 -3
- data/lib/caliper/entities/response/multiple_choice_response.rb +3 -3
- data/lib/caliper/entities/response/multiple_response_response.rb +3 -3
- data/lib/caliper/entities/response/response.rb +8 -10
- data/lib/caliper/entities/response/response_type.rb +5 -5
- data/lib/caliper/entities/response/select_type_response.rb +3 -3
- data/lib/caliper/entities/response/true_false_response.rb +2 -3
- data/lib/caliper/entities/session/session.rb +8 -7
- data/lib/caliper/{event → events}/annotation_event.rb +11 -3
- data/lib/caliper/{event → events}/assessment_event.rb +11 -8
- data/lib/caliper/{event → events}/assessment_item_event.rb +11 -8
- data/lib/caliper/{event → events}/assignable_event.rb +11 -8
- data/lib/caliper/{profiles/profile.rb → events/event.rb} +15 -15
- data/lib/caliper/events/event_context.rb +24 -0
- data/lib/caliper/events/event_type.rb +33 -0
- data/lib/caliper/{event → events}/jsonable.rb +2 -2
- data/lib/caliper/{event → events}/media_event.rb +11 -8
- data/lib/caliper/events/navigation_event.rb +47 -0
- data/lib/caliper/events/outcome_event.rb +44 -0
- data/lib/caliper/{event/outcome_event.rb → events/reading_event.rb} +13 -10
- data/lib/caliper/events/session_event.rb +42 -0
- data/lib/caliper/events/view_event.rb +44 -0
- data/lib/caliper/request/envelope.rb +4 -15
- data/lib/caliper/request/event_store_requestor.rb +1 -1
- data/lib/caliper/request/{envelope_jsonable.rb → jsonable.rb} +9 -11
- data/lib/caliper/sensor.rb +1 -1
- data/lib/caliper/version.rb +1 -1
- data/lib/caliper.rb +1 -1
- data/spec/lib/entities/agent/{student.json → person.json} +4 -3
- data/spec/lib/entities/agent/person_spec.rb +5 -6
- data/spec/lib/entities/assessment/assessment.json +23 -0
- data/spec/lib/entities/assessment/assessment_spec.rb +54 -0
- data/spec/lib/event_helper.rb +33 -41
- data/spec/lib/{event/annotation_event_bookmark_spec.rb → events/annotation_bookmarked_event_spec.rb} +36 -46
- data/spec/lib/{event/annotation_event_highlight_spec.rb → events/annotation_highlighted_event_spec.rb} +36 -46
- data/spec/lib/{event/annotation_event_shared_spec.rb → events/annotation_shared_event_spec.rb} +42 -52
- data/spec/lib/{event/annotation_event_tag_spec.rb → events/annotation_tagged_event_spec.rb} +36 -46
- data/spec/lib/{event → events}/assessment_item_completed_event_spec.rb +41 -65
- data/spec/lib/{event → events}/assessment_item_started_event_spec.rb +38 -56
- data/spec/lib/{event/assessment_event_spec.rb → events/assessment_started_event_spec.rb} +36 -51
- data/spec/lib/{event/assignable_event_spec.rb → events/assignable_activated_event_spec.rb} +37 -52
- data/spec/lib/{event/media_event_spec.rb → events/media_paused_video_event_spec.rb} +33 -43
- data/spec/lib/{event/navigated_event_spec.rb → events/navigation_navigated_to_event_spec.rb} +36 -45
- data/spec/lib/events/outcome_graded_event_spec.rb +163 -0
- data/spec/lib/{event/session_event_login_spec.rb → events/session_logged_in_event_spec.rb} +38 -46
- data/spec/lib/{event/session_event_logout_spec.rb → events/session_logged_out-event_spec.rb} +28 -37
- data/spec/lib/{event/session_event_timeout_spec.rb → events/session_timed_out_event_spec.rb} +24 -34
- data/spec/lib/{event/viewed_event_spec.rb → events/view_viewed_event_spec.rb} +33 -41
- data/spec/lib/request/{http_requestor_spec.rb → http_requestor_single_event_spec.rb} +46 -47
- data/spec/lib/request/http_requestor_single_minimal_event_spec.rb +84 -0
- data/spec/lib/sensor_spec.rb +1 -1
- metadata +77 -70
- data/lib/caliper/event/event.rb +0 -114
- data/lib/caliper/profiles/assessment_item_profile.rb +0 -48
- data/lib/caliper/profiles/reading_profile.rb +0 -56
- data/lib/caliper/profiles/session_profile.rb +0 -46
- data/lib/caliper/validators/error_message.rb +0 -63
- data/lib/caliper/validators/event_validator.rb +0 -57
- data/lib/caliper/validators/property_type_check.rb +0 -33
- data/lib/caliper/validators/session_login_event_validator.rb +0 -121
- data/lib/caliper/validators/session_logout_event_validator.rb +0 -120
- data/lib/caliper/validators/time_check.rb +0 -50
- data/spec/lib/entities/entity.json +0 -9
- data/spec/lib/entities/entity_spec.rb +0 -52
@@ -1,46 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
-
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
-
# under one or more contributor license agreements. See the NOTICE
|
5
|
-
# file distributed with this work for additional information.
|
6
|
-
#
|
7
|
-
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
-
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
-
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
-
|
18
|
-
require_relative './profile'
|
19
|
-
require_relative '../entities/digital_resource'
|
20
|
-
require_relative '../entities/annotation/annotation'
|
21
|
-
require_relative '../entities/reading/frame'
|
22
|
-
|
23
|
-
#
|
24
|
-
# Session Profile.
|
25
|
-
#
|
26
|
-
module Caliper
|
27
|
-
module Profiles
|
28
|
-
module SessionActions
|
29
|
-
LOGGED_IN = 'http://purl.imsglobal.org/vocab/caliper/v1/action#LoggedIn'
|
30
|
-
LOGGED_OUT = 'http://purl.imsglobal.org/vocab/caliper/v1/action#LoggedOut'
|
31
|
-
TIMED_OUT = 'http://purl.imsglobal.org/vocab/caliper/v1/action#TimedOut'
|
32
|
-
end
|
33
|
-
class SessionProfile < Profile
|
34
|
-
include SessionActions
|
35
|
-
|
36
|
-
def initialize
|
37
|
-
super
|
38
|
-
end
|
39
|
-
|
40
|
-
# whether object if of type DigitalResource
|
41
|
-
def validate_event (event)
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
-
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
-
# under one or more contributor license agreements. See the NOTICE
|
5
|
-
# file distributed with this work for additional information.
|
6
|
-
#
|
7
|
-
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
-
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
-
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
-
|
18
|
-
#
|
19
|
-
# Error Message.
|
20
|
-
#
|
21
|
-
module Caliper
|
22
|
-
module Validators
|
23
|
-
class ErrorMessage
|
24
|
-
|
25
|
-
attr_accessor :text
|
26
|
-
|
27
|
-
def initialize
|
28
|
-
@text = ""
|
29
|
-
end
|
30
|
-
|
31
|
-
# append comma if appropriate when building conformance violation message
|
32
|
-
def append_text(text)
|
33
|
-
if (@text.length == 0)
|
34
|
-
# assign text value
|
35
|
-
@text = text
|
36
|
-
else
|
37
|
-
# append text value
|
38
|
-
@text = @text + ",\n" + text + "\n"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# prepend text
|
43
|
-
# typically a Caliper conformance clause that prefixes a string of one or more violations.
|
44
|
-
def prepend_text(text)
|
45
|
-
@text = text + "\n" + @text
|
46
|
-
end
|
47
|
-
|
48
|
-
# append period and end sentence
|
49
|
-
def end_sentence
|
50
|
-
@text = @text + "."
|
51
|
-
end
|
52
|
-
|
53
|
-
def end_message(text)
|
54
|
-
prepend_text(text)
|
55
|
-
end_sentence
|
56
|
-
end
|
57
|
-
|
58
|
-
def length
|
59
|
-
return @text.length
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
-
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
-
# under one or more contributor license agreements. See the NOTICE
|
5
|
-
# file distributed with this work for additional information.
|
6
|
-
#
|
7
|
-
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
-
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
-
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
-
|
18
|
-
#
|
19
|
-
# Event Validator.
|
20
|
-
#
|
21
|
-
module Caliper
|
22
|
-
module Validators
|
23
|
-
module EventValidator
|
24
|
-
module Conformance
|
25
|
-
ACTION_IS_NULL = "an action must be specified."
|
26
|
-
ACTION_UNRECOGNIZED = "unrecognized action."
|
27
|
-
ACTOR_NOT_PERSON = "actor must be of type Person"
|
28
|
-
ACTOR_NOT_SOFTWAREAPP = "actor must be of type SoftwareApplication"
|
29
|
-
ASSIGNABLE_NOT_ASSESSMENT = "assignable must be of type Assessment"
|
30
|
-
CONTEXT_ERROR = "context URI must be specified"
|
31
|
-
COUNT_NOT_ZERO = "count must be specified"
|
32
|
-
DURATION_INVALID = "duration format is invalid"
|
33
|
-
ENDEDATTIME_IS_NULL = "endedAtTime must be specified"
|
34
|
-
ENDEDATTIME_SET = "endedAtTime must not be specified"
|
35
|
-
EVENT_ILLEGAL_STATE = "event constructed in an illegal state."
|
36
|
-
GENERATED_NOT_ATTEMPT = "generated object must be of type Attempt"
|
37
|
-
GENERATED_NOT_NULL = "a generated object is not required"
|
38
|
-
GENERATED_NOT_SESSION = "generated object must be of type Session"
|
39
|
-
OBJECT_NOT_ASSESSMENT = "object must be of type Assessment"
|
40
|
-
OBJECT_NOT_SOFTWAREAPP = "object must be of type SoftwareApplication"
|
41
|
-
STARTEDATTIME_IS_NULL = "startedAtTime must be specified"
|
42
|
-
TARGET_NOT_CREATIVEWORK = "target must be of type CreativeWork"
|
43
|
-
TARGET_NOT_DIGITALRESOURCE = "target must be of type DigitalResource"
|
44
|
-
TARGET_NOT_NULL = "target is not required."
|
45
|
-
TARGET_NOT_SESSION = "target must be of type Session"
|
46
|
-
TARGET_NOT_SET = "target must be specified"
|
47
|
-
TARGET_NOT_THING = "target must be of type Thing"
|
48
|
-
TIME_ERROR = "end time must be greater than start time."
|
49
|
-
TYPE_ERROR = "type URI must be specified"
|
50
|
-
end
|
51
|
-
|
52
|
-
def validate
|
53
|
-
# to be implemented
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
-
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
-
# under one or more contributor license agreements. See the NOTICE
|
5
|
-
# file distributed with this work for additional information.
|
6
|
-
#
|
7
|
-
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
-
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
-
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
-
|
18
|
-
require_relative '../agent/person'
|
19
|
-
require_relative '../schemadotorg/software_application'
|
20
|
-
|
21
|
-
#
|
22
|
-
# Type check.
|
23
|
-
#
|
24
|
-
module Caliper
|
25
|
-
module Validators
|
26
|
-
class PropertyTypeCheck
|
27
|
-
# whether the object is of wanted target class
|
28
|
-
def is_object_of_type(object, targetClass)
|
29
|
-
return !object.nil? && object.is_a?(targetClass)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,121 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
-
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
-
# under one or more contributor license agreements. See the NOTICE
|
5
|
-
# file distributed with this work for additional information.
|
6
|
-
#
|
7
|
-
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
-
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
-
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
-
|
18
|
-
require_relative './event_validator'
|
19
|
-
require_relative './error_message'
|
20
|
-
require_relative './property_type_check'
|
21
|
-
require_relative './time_check'
|
22
|
-
require_relative '../event/event'
|
23
|
-
require_relative '../agent/person'
|
24
|
-
require_relative '../digital_resource'
|
25
|
-
require_relative '../session/session'
|
26
|
-
require_relative '../schemadotorg/software_application'
|
27
|
-
|
28
|
-
#
|
29
|
-
# Session Login validator
|
30
|
-
#
|
31
|
-
module Caliper
|
32
|
-
module Validators
|
33
|
-
class SessionLoginEventValidator
|
34
|
-
include EventValidator
|
35
|
-
include TimeCheck
|
36
|
-
|
37
|
-
## Validate session login event properties.
|
38
|
-
# Properties
|
39
|
-
# context:: required
|
40
|
-
# type:: required
|
41
|
-
# edApp:: optional
|
42
|
-
# group:: optional
|
43
|
-
# actor:: required: Person
|
44
|
-
# action:: required: session.loggedIn
|
45
|
-
# object:: required: SoftwareApplication
|
46
|
-
# target:: required: DigitalResource
|
47
|
-
# generated:: required: Session
|
48
|
-
# startedAtTime:: required
|
49
|
-
# endedAtTime:: optional: but should not be set.
|
50
|
-
# duration:: optional: but should not be set.
|
51
|
-
# returns conformance violations message.
|
52
|
-
def validate(event)
|
53
|
-
context = "session"
|
54
|
-
error_message = ErrorMessage.new
|
55
|
-
property_check = PropertyTypeCheck.new
|
56
|
-
|
57
|
-
|
58
|
-
if (!event.is_a?(Event))
|
59
|
-
# check whether the argument is of right type
|
60
|
-
return
|
61
|
-
else
|
62
|
-
# is event context of Session
|
63
|
-
if (!event.context.equal?(EventType::SESSION))
|
64
|
-
error_message.append_text(event.context + " " + Conformance::CONTEXT_ERROR)
|
65
|
-
end
|
66
|
-
|
67
|
-
# is event type of Session
|
68
|
-
if (!event.type.equal?(EventType::SESSION))
|
69
|
-
error_message.append_text(event.type + " " + Conformance::TYPE_ERROR)
|
70
|
-
end
|
71
|
-
|
72
|
-
# is event actor a Person
|
73
|
-
if (!property_check.is_object_of_type(event.actor, Person.class))
|
74
|
-
error_message.append_text(event.actor.class + " " + Conformance::ACTOR_NOT_PERSON)
|
75
|
-
end
|
76
|
-
|
77
|
-
# is event object a SoftwareApplication
|
78
|
-
if (!property_check.is_object_of_type(event.object, SoftwareApplication.class))
|
79
|
-
error_message.append_text(event.object.class + " " + Conformance::OBJECT_NOT_SOFTWAREAPP)
|
80
|
-
end
|
81
|
-
|
82
|
-
# is event target a DigitalResource
|
83
|
-
if (!property_check.is_object_of_type(event.target, DigitalResource.class))
|
84
|
-
error_message.append_text(event.object.class + " " + Conformance::TARGET_NOT_DIGITALRESOURCE)
|
85
|
-
end
|
86
|
-
|
87
|
-
if (property_check.is_object_of_type(event.generated, Session.class))
|
88
|
-
if (event.generated.started_at_time == 0)
|
89
|
-
error_message.append_text(context + " " + Conformance::STARTEDATTIME_IS_NULL)
|
90
|
-
elsif (event.generated.end_at_time != 0)
|
91
|
-
error_message.append_text(context + " " + Conformance::ENDEDATTIME_SET)
|
92
|
-
end
|
93
|
-
else
|
94
|
-
error_message.append_text(Conformance::GENERATED_NOT_SESSION)
|
95
|
-
end
|
96
|
-
|
97
|
-
# start time set for event
|
98
|
-
if (!check_started_at_time(event.started_at_time))
|
99
|
-
error_message.append_text(Conformance::STARTEDATTIME_IS_NULL)
|
100
|
-
end
|
101
|
-
|
102
|
-
# also check the event end time
|
103
|
-
if (!check_ended_at_time(event.started_at_time, event.ended_at_time))
|
104
|
-
error_message.append_text(Conformance::TIME_ERROR)
|
105
|
-
end
|
106
|
-
|
107
|
-
# check duration value
|
108
|
-
if (check_duration(event.duration))
|
109
|
-
error_message.append_text(Conformance::DURATION_INVALID)
|
110
|
-
end
|
111
|
-
|
112
|
-
if (error_message.length() > 0)
|
113
|
-
error_message.end_message("Caliper Session profile login event conformance: ")
|
114
|
-
end
|
115
|
-
|
116
|
-
return error_message.text
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# This file is part of IMS Caliper Analytics™ and is licensed to
|
3
|
-
# IMS Global Learning Consortium, Inc. (http://www.imsglobal.org)
|
4
|
-
# under one or more contributor license agreements. See the NOTICE
|
5
|
-
# file distributed with this work for additional information.
|
6
|
-
#
|
7
|
-
# IMS Caliper is free software: you can redistribute it and/or modify it under
|
8
|
-
# the terms of the GNU Lesser General Public License as published by the Free
|
9
|
-
# Software Foundation, version 3 of the License.
|
10
|
-
#
|
11
|
-
# IMS Caliper is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
13
|
-
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
14
|
-
#
|
15
|
-
# You should have received a copy of the GNU Lesser General Public License along
|
16
|
-
# with this program. If not, see http://www.gnu.org/licenses/.
|
17
|
-
|
18
|
-
require_relative 'event_validator'
|
19
|
-
require_relative 'error_message'
|
20
|
-
require_relative 'property_type_check'
|
21
|
-
require_relative 'time_check'
|
22
|
-
require_relative '../event/event'
|
23
|
-
require_relative '../entities/agent/person'
|
24
|
-
require_relative '../entities/digital_resource'
|
25
|
-
require_relative '../entities/session/session'
|
26
|
-
require_relative '../entities/schemadotorg/software_application'
|
27
|
-
|
28
|
-
#
|
29
|
-
# Session logout validator.
|
30
|
-
#
|
31
|
-
module Caliper
|
32
|
-
module Validators
|
33
|
-
class SessionLogoutEventValidator
|
34
|
-
include EventValidator
|
35
|
-
include TimeCheck
|
36
|
-
|
37
|
-
Validate session logout event properties.
|
38
|
-
*
|
39
|
-
## Validate SessionEvent.
|
40
|
-
# An IllegalStateException will be thrown as a defensive measure if programing
|
41
|
-
# errors are encountered during object construction.
|
42
|
-
# Properties
|
43
|
-
# context:: required
|
44
|
-
# type:: required
|
45
|
-
# edApp:: optional
|
46
|
-
# group:: optional
|
47
|
-
# actor:: required: Person
|
48
|
-
# action:: required: session.loggedIn
|
49
|
-
# object:: required: SoftwareApplication
|
50
|
-
# target:: required: DigitalResource
|
51
|
-
# generated:: required: Session
|
52
|
-
# startedAtTime:: required
|
53
|
-
# endedAtTime:: optional: but should not be set.
|
54
|
-
# duration:: optional: but should not be set.
|
55
|
-
# returns conformance violations message.
|
56
|
-
def validate(event)
|
57
|
-
context = "session"
|
58
|
-
error_message = ErrorMessage.new
|
59
|
-
property_check = PropertyTypeCheck.new
|
60
|
-
|
61
|
-
|
62
|
-
if (!event.is_a?(Event))
|
63
|
-
# check whether the argument is of right type
|
64
|
-
return
|
65
|
-
else
|
66
|
-
# is event context of Session
|
67
|
-
if (!event.context.equal?(EventType::SESSION))
|
68
|
-
error_message.append_text(event.context + " " + Conformance::CONTEXT_ERROR)
|
69
|
-
end
|
70
|
-
|
71
|
-
# is event type of Session
|
72
|
-
if (!event.type.equal?(EventType::SESSION))
|
73
|
-
error_message.append_text(event.type + " " + Conformance::TYPE_ERROR)
|
74
|
-
end
|
75
|
-
|
76
|
-
# is event actor a Person
|
77
|
-
if (!property_check.is_object_of_type(event.actor, Person.class))
|
78
|
-
error_message.append_text(event.actor.class + " " + Conformance::ACTOR_NOT_PERSON)
|
79
|
-
end
|
80
|
-
|
81
|
-
# is event object a SoftwareApplication
|
82
|
-
if (!property_check.is_object_of_type(event.object, SoftwareApplication.class))
|
83
|
-
error_message.append_text(event.object.class + " " + Conformance::OBJECT_NOT_SOFTWAREAPP)
|
84
|
-
end
|
85
|
-
|
86
|
-
# is event target a DigitalResource
|
87
|
-
if (!property_check.is_object_of_type(event.target, Session.class))
|
88
|
-
error_message.append_text(event.object.class + " " + Conformance::TARGET_NOT_SESSION)
|
89
|
-
end
|
90
|
-
|
91
|
-
# should not be generated
|
92
|
-
if (event.generated)
|
93
|
-
message.appendText(Conformance::GENERATED_NOT_NULL);
|
94
|
-
end
|
95
|
-
|
96
|
-
# start time set for event
|
97
|
-
if (!check_started_at_time(event.started_at_time))
|
98
|
-
error_message.append_text(Conformance::STARTEDATTIME_IS_NULL)
|
99
|
-
end
|
100
|
-
|
101
|
-
# also check the event end time
|
102
|
-
if (!check_ended_at_time(event.started_at_time, event.ended_at_time))
|
103
|
-
error_message.append_text(Conformance::TIME_ERROR)
|
104
|
-
end
|
105
|
-
|
106
|
-
# check duration value
|
107
|
-
if (check_duration(event.duration))
|
108
|
-
error_message.append_text(Conformance::DURATION_INVALID)
|
109
|
-
end
|
110
|
-
|
111
|
-
if (error_message.length > 0)
|
112
|
-
error_message.end_message("Caliper Session profile login event conformance: ")
|
113
|
-
end
|
114
|
-
|
115
|
-
return error_message.text
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|