qti 2.11.0 → 2.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 783579cd76121396d891a45730e833ebed9967a7366f75b61c8dca97dd429091
4
- data.tar.gz: 15193545fbe7b76ae5e66906a1794f19d3b5d175c7719adb8b01b48223ffe1d2
3
+ metadata.gz: 36f18933b8d36d5a0c9ff5a5b4788852a9061c434385c3dd542b9cfb6c736c8d
4
+ data.tar.gz: 97641eb71ae7efa662ed2e6052e7cb4f35297e8927a3c01c808dc85dcacbf6e3
5
5
  SHA512:
6
- metadata.gz: e2a783e103895c2f88d98e7e79c8a8024b1ef8726b7d54a03021213ac5745d6c85f0d5cb822e2034e64812e63ac2b8501067ef584a1167521be89401d08bc4b6
7
- data.tar.gz: 82a518e1b780ebc9ca5177212bde1108e7980efe4f4bee9473bc753a238268b1f9bfd1ba57bf8341d668faa8ed02166e5566dcfdb61215ddd817c6b8e6d34e05
6
+ metadata.gz: db6f0e6c2987afa8da40dd633ae1ecbb3fd5e099ddf6de86d6bf3b65d075caf8cfd4e1a4070810fdca2452ee669f347c33dfbb3d508f8ab44b26ccbc651f2009
7
+ data.tar.gz: bb12cf21f40ea16f3238d7a04f73b8a203b4a54881fd1f1576841abbf26045501e745b358ad77b94d8b4ee1f0ff16fe88876f7d7df073a85efa92ada6e14c75d
@@ -10,7 +10,7 @@ module Qti
10
10
  # ensure a prompt is carried into the html
11
11
  prompt = node.at_xpath('//xmlns:prompt')
12
12
  filter_item_body(node)
13
- node.add_child(prompt) if prompt&.parent && prompt.parent != node
13
+ node.add_child(prompt&.dup) if prompt&.parent && prompt.parent != node
14
14
  sanitize_content!(node.to_html)
15
15
  end
16
16
  end
@@ -59,9 +59,11 @@ module Qti
59
59
  def stem_text
60
60
  clean_stem_items.search('p').children.map do |stem_item|
61
61
  if stem_item.name == 'gap'
62
+ blank_id = stem_item.attributes['identifier'].value
62
63
  {
63
64
  type: 'blank',
64
- blank_id: stem_item.attributes['identifier'].value
65
+ blank_id: blank_id,
66
+ blank_name: correct_choice_value(blank_id)
65
67
  }
66
68
  else
67
69
  {
@@ -84,12 +86,15 @@ module Qti
84
86
  end
85
87
  end
86
88
 
89
+ def correct_choice_value(node_id)
90
+ answer_choice(choices, question_response_id_mapping[node_id]).content
91
+ end
92
+
87
93
  def scoring_data_structs
88
- mapping = question_response_id_mapping
89
94
  answer_nodes.map do |value_node|
90
95
  node_id = value_node.attributes['identifier']&.value
91
96
  ScoringData.new(
92
- answer_choice(choices, mapping[node_id]).content,
97
+ correct_choice_value(node_id),
93
98
  'directedPair',
94
99
  id: node_id,
95
100
  case: false
@@ -114,11 +119,13 @@ module Qti
114
119
  end
115
120
 
116
121
  def question_response_id_mapping
117
- question_response_pairs = node.xpath('.//xmlns:correctResponse//xmlns:value').map do |value|
118
- value.content.split
122
+ @question_response_id_mapping ||= begin
123
+ question_response_pairs = node.xpath('.//xmlns:correctResponse//xmlns:value').map do |value|
124
+ value.content.split
125
+ end
126
+ question_response_pairs.map!(&:reverse)
127
+ Hash[question_response_pairs]
119
128
  end
120
- question_response_pairs.map!(&:reverse)
121
- Hash[question_response_pairs]
122
129
  end
123
130
  end
124
131
  end
data/lib/qti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qti
2
- VERSION = '2.11.0'.freeze
2
+ VERSION = '2.12.0'.freeze
3
3
  end
@@ -20,6 +20,10 @@ describe Qti::V2::Models::AssessmentItem do
20
20
  expect(loaded_class.item_body).to include 'Look at the text in the picture.'
21
21
  end
22
22
 
23
+ it 'includes the prompt in the item_body' do
24
+ expect(loaded_class.item_body).to include 'What does it say?'
25
+ end
26
+
23
27
  it 'falls back onto nil points possible value' do
24
28
  expect(loaded_class.points_possible).to eq nil
25
29
  end
@@ -43,6 +47,19 @@ describe Qti::V2::Models::AssessmentItem do
43
47
  end
44
48
  end
45
49
 
50
+ context 'gap_match.xml' do
51
+ let(:fixtures_path) { File.join('spec', 'fixtures') }
52
+ let(:file_path) { File.join(fixtures_path, 'items_2.1', 'gap_match.xml') }
53
+ let(:loaded_class) { described_class.from_path!(file_path) }
54
+
55
+ it 'returns the prompt as the first stem item even after calculating item_body' do
56
+ loaded_class.item_body
57
+ stem_items = loaded_class.interaction_model.stem_items
58
+ expect(stem_items.count).to equal(12)
59
+ expect(stem_items.first[:value]).to include('Identify the missing words')
60
+ end
61
+ end
62
+
46
63
  context 'all test files' do
47
64
  test_files = Dir.glob(File.join('spec', 'fixtures', 'items_2.1', '*.xml'))
48
65
  test_files.each do |file|
@@ -11,11 +11,11 @@ describe Qti::V2::Models::Interactions::GapMatchInteraction do
11
11
  value: "Identify the missing words in this famous quote from Shakespeare's Richard III.",
12
12
  id: 'stem_0', position: 1 },
13
13
  { type: 'text', value: 'Now is the ', id: 'stem_1', position: 2 },
14
- { type: 'blank', blank_id: 'G1', id: 'stem_2', position: 3 },
14
+ { type: 'blank', blank_id: 'G1', blank_name: 'winter', id: 'stem_2', position: 3 },
15
15
  { type: 'text', value: ' of our discontent', id: 'stem_3', position: 4 },
16
16
  { type: 'text', value: ' ', id: 'stem_4', position: 5 },
17
17
  { type: 'text', value: ' Made glorious ', id: 'stem_5', position: 6 },
18
- { type: 'blank', blank_id: 'G2', id: 'stem_6', position: 7 },
18
+ { type: 'blank', blank_id: 'G2', blank_name: 'summer', id: 'stem_6', position: 7 },
19
19
  { type: 'text', value: ' by this sun of York;', id: 'stem_7', position: 8 },
20
20
  { type: 'text', value: ' ', id: 'stem_8', position: 9 },
21
21
  { type: 'text', value: " And all the clouds that lour'd\n upon our house",
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: 2.11.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Diaz
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-10-19 00:00:00.000000000 Z
15
+ date: 2022-12-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: actionview