scorm2004-manifest 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.document +5 -0
  2. data/Gemfile +12 -0
  3. data/Gemfile.lock +36 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +94 -0
  6. data/Rakefile +39 -0
  7. data/VERSION +1 -0
  8. data/lib/scorm2004/manifest/adlseq_map_info.rb +17 -0
  9. data/lib/scorm2004/manifest/adlseq_objective.rb +14 -0
  10. data/lib/scorm2004/manifest/adlseq_objectives.rb +11 -0
  11. data/lib/scorm2004/manifest/attributes.rb +147 -0
  12. data/lib/scorm2004/manifest/children.rb +83 -0
  13. data/lib/scorm2004/manifest/completion_threshold.rb +13 -0
  14. data/lib/scorm2004/manifest/condition_rule.rb +12 -0
  15. data/lib/scorm2004/manifest/constrained_choice_considerations.rb +12 -0
  16. data/lib/scorm2004/manifest/control_mode.rb +16 -0
  17. data/lib/scorm2004/manifest/custom_error.rb +15 -0
  18. data/lib/scorm2004/manifest/data.rb +11 -0
  19. data/lib/scorm2004/manifest/data_from_lms.rb +21 -0
  20. data/lib/scorm2004/manifest/delivery_controls.rb +13 -0
  21. data/lib/scorm2004/manifest/dependency.rb +21 -0
  22. data/lib/scorm2004/manifest/error.rb +5 -0
  23. data/lib/scorm2004/manifest/file.rb +16 -0
  24. data/lib/scorm2004/manifest/hide_lmsui.rb +21 -0
  25. data/lib/scorm2004/manifest/href.rb +24 -0
  26. data/lib/scorm2004/manifest/item.rb +36 -0
  27. data/lib/scorm2004/manifest/limit_conditions.rb +12 -0
  28. data/lib/scorm2004/manifest/manifest.rb +26 -0
  29. data/lib/scorm2004/manifest/map.rb +13 -0
  30. data/lib/scorm2004/manifest/map_info.rb +15 -0
  31. data/lib/scorm2004/manifest/min_normalized_measure.rb +18 -0
  32. data/lib/scorm2004/manifest/navigation_interface.rb +10 -0
  33. data/lib/scorm2004/manifest/objective.rb +16 -0
  34. data/lib/scorm2004/manifest/objectives.rb +12 -0
  35. data/lib/scorm2004/manifest/organization.rb +20 -0
  36. data/lib/scorm2004/manifest/organizations.rb +24 -0
  37. data/lib/scorm2004/manifest/presentation.rb +10 -0
  38. data/lib/scorm2004/manifest/primary_objective.rb +24 -0
  39. data/lib/scorm2004/manifest/randomization_controls.rb +16 -0
  40. data/lib/scorm2004/manifest/resource.rb +18 -0
  41. data/lib/scorm2004/manifest/resources.rb +12 -0
  42. data/lib/scorm2004/manifest/rollup_action.rb +13 -0
  43. data/lib/scorm2004/manifest/rollup_condition.rb +24 -0
  44. data/lib/scorm2004/manifest/rollup_conditions.rb +14 -0
  45. data/lib/scorm2004/manifest/rollup_considerations.rb +17 -0
  46. data/lib/scorm2004/manifest/rollup_rule.rb +19 -0
  47. data/lib/scorm2004/manifest/rollup_rules.rb +16 -0
  48. data/lib/scorm2004/manifest/rule_action.rb +31 -0
  49. data/lib/scorm2004/manifest/rule_condition.rb +41 -0
  50. data/lib/scorm2004/manifest/rule_conditions.rb +14 -0
  51. data/lib/scorm2004/manifest/schema.rb +18 -0
  52. data/lib/scorm2004/manifest/schemaversion.rb +18 -0
  53. data/lib/scorm2004/manifest/sequencing.rb +24 -0
  54. data/lib/scorm2004/manifest/sequencing_collection.rb +11 -0
  55. data/lib/scorm2004/manifest/sequencing_rules.rb +13 -0
  56. data/lib/scorm2004/manifest/text_node.rb +11 -0
  57. data/lib/scorm2004/manifest/time_limit_action.rb +24 -0
  58. data/lib/scorm2004/manifest/title.rb +16 -0
  59. data/lib/scorm2004/manifest/visitor_pattern.rb +31 -0
  60. data/lib/scorm2004/manifest/xml_base.rb +38 -0
  61. data/lib/scorm2004/manifest.rb +76 -0
  62. data/lib/scorm2004-manifest.rb +1 -0
  63. data/test/functional_test.rb +45 -0
  64. data/test/helper.rb +18 -0
  65. data/test/mbce_test.rb +66 -0
  66. data/test/msce_test.rb +55 -0
  67. data/test/scorm2004/manifest/adlseq_map_info_test.rb +47 -0
  68. data/test/scorm2004/manifest/adlseq_objective_test.rb +44 -0
  69. data/test/scorm2004/manifest/adlseq_objectives_test.rb +29 -0
  70. data/test/scorm2004/manifest/any_uri_token_test.rb +40 -0
  71. data/test/scorm2004/manifest/attributes_test.rb +224 -0
  72. data/test/scorm2004/manifest/children_test.rb +330 -0
  73. data/test/scorm2004/manifest/completion_threshold_test.rb +80 -0
  74. data/test/scorm2004/manifest/condition_rule_test.rb +40 -0
  75. data/test/scorm2004/manifest/constrained_choice_considerations_test.rb +25 -0
  76. data/test/scorm2004/manifest/control_mode_test.rb +41 -0
  77. data/test/scorm2004/manifest/custom_error_test.rb +43 -0
  78. data/test/scorm2004/manifest/data_from_lms_test.rb +47 -0
  79. data/test/scorm2004/manifest/data_test.rb +31 -0
  80. data/test/scorm2004/manifest/delivery_controls_test.rb +27 -0
  81. data/test/scorm2004/manifest/dependency_test.rb +53 -0
  82. data/test/scorm2004/manifest/duration_attribute_test.rb +59 -0
  83. data/test/scorm2004/manifest/file_test.rb +40 -0
  84. data/test/scorm2004/manifest/hide_lmsui_test.rb +40 -0
  85. data/test/scorm2004/manifest/href_test.rb +43 -0
  86. data/test/scorm2004/manifest/item_test.rb +86 -0
  87. data/test/scorm2004/manifest/limit_conditions_test.rb +34 -0
  88. data/test/scorm2004/manifest/manifest_test.rb +152 -0
  89. data/test/scorm2004/manifest/map_info_test.rb +41 -0
  90. data/test/scorm2004/manifest/map_test.rb +32 -0
  91. data/test/scorm2004/manifest/min_normalized_measure_test.rb +28 -0
  92. data/test/scorm2004/manifest/navigation_interface_test.rb +29 -0
  93. data/test/scorm2004/manifest/non_negative_integer_attribute_test.rb +64 -0
  94. data/test/scorm2004/manifest/objective_test.rb +45 -0
  95. data/test/scorm2004/manifest/objectives_test.rb +37 -0
  96. data/test/scorm2004/manifest/organization_test.rb +115 -0
  97. data/test/scorm2004/manifest/organizations_test.rb +68 -0
  98. data/test/scorm2004/manifest/partial_manifest.rb +23 -0
  99. data/test/scorm2004/manifest/partial_manifest_test.rb +44 -0
  100. data/test/scorm2004/manifest/presentation_test.rb +26 -0
  101. data/test/scorm2004/manifest/primary_objective_test.rb +65 -0
  102. data/test/scorm2004/manifest/randomization_controls_test.rb +71 -0
  103. data/test/scorm2004/manifest/resource_test.rb +96 -0
  104. data/test/scorm2004/manifest/resources_test.rb +41 -0
  105. data/test/scorm2004/manifest/rollup_action_test.rb +33 -0
  106. data/test/scorm2004/manifest/rollup_condition_test.rb +42 -0
  107. data/test/scorm2004/manifest/rollup_conditions_test.rb +53 -0
  108. data/test/scorm2004/manifest/rollup_considerations_test.rb +42 -0
  109. data/test/scorm2004/manifest/rollup_rule_test.rb +87 -0
  110. data/test/scorm2004/manifest/rollup_rules_test.rb +60 -0
  111. data/test/scorm2004/manifest/rule_action_test.rb +79 -0
  112. data/test/scorm2004/manifest/rule_condition_test.rb +70 -0
  113. data/test/scorm2004/manifest/rule_conditions_test.rb +37 -0
  114. data/test/scorm2004/manifest/schema_test.rb +29 -0
  115. data/test/scorm2004/manifest/schemaversion_test.rb +29 -0
  116. data/test/scorm2004/manifest/sequencing_collection_test.rb +31 -0
  117. data/test/scorm2004/manifest/sequencing_rules_test.rb +36 -0
  118. data/test/scorm2004/manifest/sequencing_test.rb +42 -0
  119. data/test/scorm2004/manifest/string_attribute_test.rb +68 -0
  120. data/test/scorm2004/manifest/text_node_test.rb +37 -0
  121. data/test/scorm2004/manifest/time_limit_action_test.rb +51 -0
  122. data/test/scorm2004/manifest/title_test.rb +59 -0
  123. data/test/scorm2004/manifest/token_attribute_test.rb +53 -0
  124. data/test/scorm2004/manifest/visitor_pattern_test.rb +85 -0
  125. data/test/scorm2004/manifest/xml_base_test.rb +125 -0
  126. data/test/scorm2004/manifest_test.rb +33 -0
  127. data/test/scorm2004_test.rb +9 -0
  128. data/test/sece_test.rb +53 -0
  129. metadata +260 -0
@@ -0,0 +1,21 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class HideLmsui
4
+ include VisitorPattern
5
+ include CustomError
6
+ include TextNode
7
+
8
+ def self.vocabulary
9
+ %w( previous continue exit exitAll abandon abandonAll suspendAll )
10
+ end
11
+
12
+ private
13
+
14
+ def do_visit
15
+ unless self.class.vocabulary.include?(content)
16
+ error("Invalid <adlnav:hideLMSUI> token: #{content}")
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ module Href
4
+ def href
5
+ (base ? resolve_href : relative_href).try(:to_s)
6
+ end
7
+
8
+ private
9
+
10
+ def relative_href
11
+ value = el.at('./@href', NS)
12
+ return unless value
13
+ uri = URI(value)
14
+ uri.absolute? ? uri : Pathname(uri.path)
15
+ end
16
+
17
+ def resolve_href
18
+ return nil unless relative_href
19
+ return relative_href if relative_href.is_a?(URI)
20
+ base + relative_href.to_s
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,36 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Item
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ attribute :id, 'identifier'
10
+ attribute :string, 'identifierref', allow_nil: true
11
+ attribute :boolean, 'isvisible', default: true
12
+ attribute :string, 'parameters', allow_nil: true
13
+
14
+ has_one_and_only_one 'imscp:title'
15
+ has_zero_or_more 'imscp:item'
16
+ has_zero_or_one 'adlcp:timeLimitAction'
17
+ has_zero_or_one 'adlcp:dataFromLMS'
18
+ has_zero_or_one 'adlcp:completionThreshold'
19
+ has_zero_or_one 'imsss:sequencing'
20
+ has_zero_or_one 'adlnav:presentation'
21
+ has_zero_or_one 'adlcp:data'
22
+
23
+ private
24
+
25
+ def do_visit
26
+ if identifierref && resource.nil?
27
+ error("A <resource> element whose identifier is #{identifierref} not found:")
28
+ end
29
+ end
30
+
31
+ def resource
32
+ el.at("/imscp:manifest/imscp:resources/imscp:resource[@identifier='#{identifierref}']", NS)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,12 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class LimitConditions
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ attribute :non_negative_integer, 'attemptLimit', allow_nil: true
9
+ attribute :duration, 'attemptAbsoluteDurationLimit', allow_nil: true
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,26 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Manifest
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+ include XmlBase
9
+
10
+ has_one_and_only_one './imscp:metadata/imscp:schema'
11
+ has_one_and_only_one './imscp:metadata/imscp:schemaversion'
12
+ has_one_and_only_one 'imscp:resources'
13
+ has_one_and_only_one 'imscp:organizations'
14
+ has_zero_or_one 'imsss:sequencingCollection'
15
+
16
+ attribute :id, 'identifier'
17
+ attribute :string, 'version', spm: 20
18
+
19
+ private
20
+
21
+ def do_visit
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Map
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ attribute :any_uri, 'targetID'
9
+ attribute :boolean, 'readSharedData', default: true
10
+ attribute :boolean, 'writeSharedData', default: true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class MapInfo
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ attribute :any_uri, 'targetObjectiveID'
9
+ attribute :boolean, 'readSatisfiedStatus', default: true
10
+ attribute :boolean, 'readNormalizedMeasure', default: true
11
+ attribute :boolean, 'writeSatisfiedStatus', default: false
12
+ attribute :boolean, 'writeNormalizedMeasure', default: false
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class MinNormalizedMeasure
4
+ include VisitorPattern
5
+ include CustomError
6
+
7
+ def to_f
8
+ Float(el.content)
9
+ end
10
+
11
+ private
12
+
13
+ def do_visit
14
+ error("#{el} should be between -1 and 1.") unless (-1.0..1.0).include?(to_f)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class NavigationInterface
4
+ include VisitorPattern
5
+ include Children
6
+
7
+ has_zero_or_more 'adlnav:hideLMSUI'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Objective
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ attribute :boolean, 'satisfiedByMeasure', default: false
10
+ attribute :any_uri, 'objectiveID'
11
+
12
+ has_zero_or_one 'imsss:minNormalizedMeasure'
13
+ has_zero_or_more 'imsss:mapInfo'
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Objectives
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+
8
+ has_one_and_only_one 'imsss:primaryObjective'
9
+ has_zero_or_more 'imsss:objective'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Organization
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+ include XmlBase
9
+
10
+ has_one_or_more 'imscp:item'
11
+ has_one_and_only_one 'imscp:title'
12
+ has_zero_or_one 'adlcp:completionThreshold'
13
+ has_zero_or_one 'imsss:sequencing'
14
+
15
+ attribute :id, 'identifier'
16
+ attribute :boolean, 'adlseq:objectivesGlobalToSystem', default: false
17
+ attribute :boolean, 'adlcp:sharedDataGlobalToSystem', default: false
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Organizations
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+ include XmlBase
9
+
10
+ attribute :idref, 'default'
11
+ has_one_or_more 'imscp:organization'
12
+
13
+ private
14
+
15
+ def do_visit
16
+ error('Default <resource> not foulnd: ' + default) unless default_resource
17
+ end
18
+
19
+ def default_resource
20
+ el.at("/imscp:manifest/imscp:organizations/imscp:organization[@identifier='#{default}']", NS)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Presentation
4
+ include VisitorPattern
5
+ include Children
6
+
7
+ has_zero_or_one 'adlnav:navigationInterface'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class PrimaryObjective
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ attribute :boolean, 'satisfiedByMeasure', default: false
10
+ attribute :any_uri, 'objectiveID', allow_nil: true
11
+
12
+ has_zero_or_one 'imsss:minNormalizedMeasure'
13
+ has_zero_or_more 'imsss:mapInfo'
14
+
15
+ private
16
+
17
+ def do_visit
18
+ error(<<EOS) if el.at('./imsss:mapInfo', NS) && objective_id.nil?
19
+ If a <primaryObjective> contains an objective map (<mapInfo>), then the objectiveID attribute is required.
20
+ EOS
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RandomizationControls
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ TIMINGS = %w( never once onEachNewAttempt )
9
+
10
+ attribute :token, 'randomizationTiming', vocabulary: TIMINGS, default: 'never'
11
+ attribute :non_negative_integer, 'selectCount', allow_nil: true
12
+ attribute :boolean, 'reorderChildren', default: false
13
+ attribute :token, 'selectionTiming', vocabulary: TIMINGS, default: 'never'
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Resource
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+ include XmlBase
9
+ include Href
10
+
11
+ attribute :id, 'identifier'
12
+ attribute :token, 'adlcp:scormType', vocabulary: %w( sco asset )
13
+
14
+ has_zero_or_more 'imscp:file'
15
+ has_zero_or_more 'imscp:dependency'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Resources
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include XmlBase
8
+
9
+ has_zero_or_more 'imscp:resource'
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RollupAction
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ ACTIONS = %w( satisfied notSatisfied completed incomplete )
9
+
10
+ attribute :token, 'action', vocabulary: ACTIONS
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RollupCondition
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ CONDITIONS = [
9
+ 'satisfied',
10
+ 'objectiveStatusKnown',
11
+ 'objectiveMeasureKnown',
12
+ 'completed',
13
+ 'activityProgressKnown',
14
+ 'attempted',
15
+ 'attemptLimitExceeded',
16
+ 'timeLimitExceeded',
17
+ 'outsideAvailableTimeRange'
18
+ ]
19
+
20
+ attribute :token, 'operator', vocabulary: %w( not noOp ), default: 'noOp'
21
+ attribute :token, 'condition', vocabulary: CONDITIONS
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,14 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RollupConditions
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ attribute :token, 'conditionCombination', vocabulary: %w( any all ), default: 'any'
10
+
11
+ has_one_or_more 'imsss:rollupCondition'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RollupConsiderations
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ CONDITIONS = %w( always ifAttempted ifNotSkipped ifNotSuspended )
9
+
10
+ %w( requiredForSatisfied requireForNotSatisfied requiredForCompleted requireForIncomplete ).each do |attr|
11
+ attribute :token, attr, vocabulary: CONDITIONS, default: CONDITIONS.first
12
+ end
13
+
14
+ attribute :boolean, 'measureSatisfactionIfActive', default: true
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RollupRule
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ CONDITIONS = %w( all any none atLeastCount atLeastPercent )
10
+
11
+ attribute :token, 'childActivitySet', vocabulary: CONDITIONS, default: CONDITIONS.first
12
+ attribute :non_negative_integer, 'minimumCount', default: 0
13
+ attribute :decimal, 'minimumPercent', range: 0.0..1.0, default: 0.0
14
+
15
+ has_one_and_only_one 'imsss:rollupConditions'
16
+ has_one_and_only_one 'imsss:rollupAction'
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RollupRules
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ attribute :boolean, 'rollupObjectiveSatisfied', default: true
10
+ attribute :boolean, 'rollupProgressCompletion', default: true
11
+ attribute :decimal, 'objectiveMeasureWeight', range: 0.0..1.0, default: 1.0
12
+
13
+ has_zero_or_more 'imsss:rollupRule'
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RuleAction
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ PRE = %w( skip disabled hiddenFromChoice stopForwardTraversal )
9
+ POST = %w( exitParent exitAll retry retryAll continue previous )
10
+ EXIT = %w( exit )
11
+
12
+ attribute :token, 'action', vocabulary: PRE + POST + EXIT
13
+
14
+ private
15
+
16
+ def do_visit
17
+ parent_name = el.at('..').name
18
+ case parent_name
19
+ when 'preConditionRule'
20
+ error("Invalid rule action in <preConditionRule>: #{action}") unless PRE.include?(action)
21
+ when 'postConditionRule'
22
+ error("Invalid rule action in <postConditionRule>: #{action}") unless POST.include?(action)
23
+ when 'exitConditionRule'
24
+ error("Invalid rule action in <exitConditionRuel>: #{action}") unless EXIT.include?(action)
25
+ else
26
+ error("Invalid parent element for <ruleAction>: <#{parent_name}>")
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,41 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RuleCondition
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Attributes
7
+
8
+ CONDITIONS = [
9
+ 'satisfied',
10
+ 'objectiveStatusKnown',
11
+ 'objectiveMeasureKnown',
12
+ 'objectiveMeasureGreaterThan',
13
+ 'objectiveMeasureLessThan',
14
+ 'completed',
15
+ 'activityProgressKnown',
16
+ 'attempted',
17
+ 'attemptLimitExceeded',
18
+ 'timeLimitExceeded',
19
+ 'outsideAvailableTimeRange',
20
+ 'always'
21
+ ]
22
+
23
+ attribute :token, 'operator', vocabulary: %w( not noOp ), default: 'noOp'
24
+ attribute :string, 'referencedObjective', allow_nil: true
25
+ attribute :decimal, 'measureThreshold', range: -1.0..1.0, allow_nil: true
26
+ attribute :token, 'condition', vocabulary: CONDITIONS
27
+
28
+ private
29
+
30
+ def do_visit
31
+ return unless referenced_objective
32
+ if '' == referenced_objective
33
+ error('The referencedObjective attribute cannot be an empty string.')
34
+ end
35
+ if /\s/ =~ referenced_objective
36
+ error('The referencedObjective attribute cannot contain any whitespace characters.')
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,14 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class RuleConditions
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ attribute :token, 'conditionCombination', vocabulary: %w( all any ), default: 'all'
10
+
11
+ has_one_or_more 'imsss:ruleCondition'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Schema
4
+ include VisitorPattern
5
+ include CustomError
6
+
7
+ private
8
+
9
+ def do_visit
10
+ error("Invalid schema: #{el.content}") unless valid?
11
+ end
12
+
13
+ def valid?
14
+ 'ADL SCORM' == el.content
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Schemaversion
4
+ include VisitorPattern
5
+ include CustomError
6
+
7
+ private
8
+
9
+ def do_visit
10
+ error("Invalid schemaversion: #{el.content}") unless valid?
11
+ end
12
+
13
+ def valid?
14
+ '2004 4th Edition' == el.content
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,24 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class Sequencing
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+ include Attributes
8
+
9
+ attribute :id, 'ID', allow_nil: true
10
+ attribute :idref, 'IDRef', allow_nil: true
11
+
12
+ has_zero_or_one 'imsss:controlMode'
13
+ has_zero_or_one 'imsss:sequencingRules'
14
+ has_zero_or_one 'imsss:limitConditions'
15
+ has_zero_or_one 'imsss:rollupRules'
16
+ has_zero_or_one 'imsss:objectives'
17
+ has_zero_or_one 'imsss:randomizationControls'
18
+ has_zero_or_one 'imsss:deliveryControls'
19
+ has_zero_or_one 'adlseq:constrainedChoiceConsiderations'
20
+ has_zero_or_one 'adlseq:rollupConsiderations'
21
+ has_zero_or_one 'adlseq:objectives', name: 'adlseq_objectives', visitor: :adlseq_objectives
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class SequencingCollection
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+
8
+ has_one_or_more 'imsss:sequencing'
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ class SequencingRules
4
+ include VisitorPattern
5
+ include CustomError
6
+ include Children
7
+
8
+ has_zero_or_more 'imsss:preConditionRule', visitor: :condition_rule
9
+ has_zero_or_more 'imsss:postConditionRule', visitor: :condition_rule
10
+ has_zero_or_more 'imsss:exitConditionRule', visitor: :condition_rule
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Scorm2004
2
+ module Manifest
3
+ module TextNode
4
+ def content
5
+ el.content
6
+ end
7
+ alias :to_s :content
8
+ alias :to_str :content
9
+ end
10
+ end
11
+ end