qti 0.2.15 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c46f07dd942e7712d82929de86e9395708c3087f
4
- data.tar.gz: 15c49825fa8070669857bfbfa9fd9d2823cbf082
3
+ metadata.gz: f132d1d60f4543bdd51c0e802af142364ecec6dc
4
+ data.tar.gz: 014a77115d5de11e5b30eafc1ffabfa75fbf433a
5
5
  SHA512:
6
- metadata.gz: c88b7a12660eb03b7baa4b9e9c43c9029e92bba89c6fc062300b03fab96e2952d78b395280ec8c059256ae22aea3cf928ac02bcc68ce94f515639cc51f03cb27
7
- data.tar.gz: 4c96921d1016701f69077824a3bb5ac928a7abd48179f4a8860976b8cdcbc5a6342a496f5c43e05aa4a7c0a3c33ef4d59e4ec243be3e9635b95d5692adb09c9b
6
+ metadata.gz: 3c31189e0aec801f05c3f102e6a3702211ee389cf39f1c212140f4048ebf50f91943b2efcdd3f242aff519fd84e1385874a7ceee540b569d5562f5990bd96981
7
+ data.tar.gz: e336ed0335bd67b47133a9fa0a48204d4f2ed7b181f0cc9af0958384ccdb9efb62f24947dedbd42ae61c8712e43cedbe735db121b62ab0bee10f5043f8aed316
@@ -5,9 +5,7 @@ module Qti
5
5
  class MatchInteraction < BaseInteraction
6
6
  def self.matches(node)
7
7
  matches = node.xpath('//xmlns:matchInteraction')
8
- return false if matches.empty?
9
-
10
- raise Qti::UnsupportedSchema if matches.size > 1
8
+ return false if matches.count != 1
11
9
  new(node)
12
10
  end
13
11
 
@@ -17,6 +15,10 @@ module Qti
17
15
  .map { |id| { id: id, question_body: choices_by_identifier[id].content } }
18
16
  end
19
17
 
18
+ def shuffled?
19
+ node.at_xpath('.//xmlns:matchInteraction').attributes['shuffle']&.value.try(:downcase) == 'true'
20
+ end
21
+
20
22
  def answers
21
23
  answer_nodes.map { |node| Choices::SimpleAssociableChoice.new(node) }
22
24
  end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Qti::V2::Models::Interactions::MatchInteraction do
4
+ let(:file) { File.read(File.join('spec', 'fixtures', 'items_2.1', 'match.xml')) }
5
+ let(:node) { Nokogiri::XML(file) }
6
+ subject { described_class.new(node) }
7
+
8
+ it 'returns shuffle setting' do
9
+ expect(subject.shuffled?).to eq true
10
+ end
11
+
12
+ it 'returns the answers' do
13
+ expect(subject.answers.map(&:item_body)).to eq ["A Midsummer-Night's Dream", 'Romeo and Juliet', 'The Tempest']
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qti
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hannah Bottalla
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-19 00:00:00.000000000 Z
12
+ date: 2017-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -416,6 +416,7 @@ files:
416
416
  - spec/lib/qti/v2/models/choices/simple_choice_spec.rb
417
417
  - spec/lib/qti/v2/models/interactions/choice_interaction_spec.rb
418
418
  - spec/lib/qti/v2/models/interactions/extended_text_interaction_spec.rb
419
+ - spec/lib/qti/v2/models/interactions/match_interaction_spec.rb
419
420
  - spec/lib/qti_spec.rb
420
421
  - spec/spec_helper.rb
421
422
  - spec/support/custom_matchers.rb
@@ -635,6 +636,7 @@ test_files:
635
636
  - spec/lib/qti/v2/models/choices/simple_choice_spec.rb
636
637
  - spec/lib/qti/v2/models/interactions/choice_interaction_spec.rb
637
638
  - spec/lib/qti/v2/models/interactions/extended_text_interaction_spec.rb
639
+ - spec/lib/qti/v2/models/interactions/match_interaction_spec.rb
638
640
  - spec/lib/qti_spec.rb
639
641
  - spec/spec_helper.rb
640
642
  - spec/support/custom_matchers.rb