qti 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97fae2a423b897f6bd3195a31da3770b967d9ca2
4
- data.tar.gz: d04fb9572ee17b2313dfe3e11d446ddafaed9780
3
+ metadata.gz: d28b9b4b803434ea56ecd453295db6a28b783b69
4
+ data.tar.gz: 6ba9bef6b2282a140bc6093d9cf2f3f6f3f78f35
5
5
  SHA512:
6
- metadata.gz: 39e248def2e8e645cdca5661c0e92e0b665fe57a9ef8c4b19cfd818c2c95150528899e8a40a5d83aad90c80fb3531c27017eaa3ae1c29bbb3f861f0c5e3c3371
7
- data.tar.gz: 2f2a67077b6e32b8d8888109fe695b91b6bf103aef5559a81ed15dbcc4e9ca5c71937032170607448b3890dacc37c65263c52afb94c5ce562bb347ff82f8fee9
6
+ metadata.gz: 7c4491ca81bc84b3e224b1965f5e5fd0e22e27335c85260ed1756a10fbedacf15db94c5a53af2bc35f5a75fee637a71485ff2460700357891d0324f9084c94fb
7
+ data.tar.gz: a5ee171c6fe09d519be06d6dfdf3136e5ff364705c489bded21ac64180598ce2d5f4f4cd91538a4098f78e92a50ea12119f095baec44bcafeda987efad252b57
data/lib/qti.rb CHANGED
@@ -53,7 +53,6 @@ require 'qti/v1/models/base'
53
53
  require 'qti/v1/models/assessment'
54
54
  require 'qti/v1/models/assessment_item'
55
55
  require 'qti/v1/models/choices/logical_identifier_choice'
56
- require 'qti/v1/models/interactions/logical_identifier_interaction'
57
56
 
58
57
  require 'qti/v2/models/base'
59
58
  require 'qti/v2/models/choices/simple_choice'
@@ -1,4 +1,5 @@
1
- require 'qti/v1/models/interactions/logical_identifier_interaction'
1
+ require 'qti/v1/models/base'
2
+ require 'qti/v1/models/interactions'
2
3
 
3
4
  module Qti
4
5
  module V1
@@ -37,7 +38,9 @@ module Qti
37
38
  end
38
39
 
39
40
  def interaction_model
40
- @interaction_model ||= V1::Models::Interactions::LogicalIdentifierInteraction.new(@doc)
41
+ @interaction_model ||= begin
42
+ V1::Models::Interactions.interaction_model(@doc)
43
+ end
41
44
  end
42
45
 
43
46
  def scoring_data_structs
@@ -0,0 +1,25 @@
1
+ # Populate the subclasses
2
+ Dir["#{__dir__}/interactions/*.rb"].each { |f| load f }
3
+
4
+ module Qti
5
+ module V1
6
+ module Models
7
+ module Interactions
8
+ # This one finds the correct parsing model based on the provided xml node
9
+ def self.interaction_model(node)
10
+ subclasses = constants.map { |c| const_get(c) }
11
+
12
+ # Check for matches
13
+ matches = subclasses.each_with_object([]) do |interaction_class, result|
14
+ match = interaction_class.matches(node)
15
+ result << match if match
16
+ end
17
+
18
+ raise V1::UnsupportedSchema if matches.size > 1
19
+
20
+ matches.first
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -6,6 +6,16 @@ module Qti
6
6
  module Models
7
7
  module Interactions
8
8
  class LogicalIdentifierInteraction < Qti::V1::Models::Base
9
+ NODE_NAME = 'response_lid'.freeze
10
+ # This will know if a class matches
11
+ def self.matches(node)
12
+ matches = node.children.children.select { |n| n.name == NODE_NAME }
13
+ return false if matches.empty?
14
+
15
+ raise Qti::UnsupportedSchema if matches.size > 1
16
+ new(matches.first)
17
+ end
18
+
9
19
  def initialize(node)
10
20
  @node = node
11
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hannah Bottalla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-24 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,6 +125,7 @@ files:
125
125
  - lib/qti/v1/models/assessment_item.rb
126
126
  - lib/qti/v1/models/base.rb
127
127
  - lib/qti/v1/models/choices/logical_identifier_choice.rb
128
+ - lib/qti/v1/models/interactions.rb
128
129
  - lib/qti/v1/models/interactions/logical_identifier_interaction.rb
129
130
  - lib/qti/v1/models/interactions/string_interaction.rb
130
131
  - lib/qti/v2/models/assessment_item.rb