qti 2.20.1 → 2.20.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
  SHA256:
3
- metadata.gz: 86c46f8f8cc44f5462d95d93455aefd56aae83e8f6291a492459ba9da425c510
4
- data.tar.gz: 63429e02991279043a3a0380e720fee6bb27b36132cfcb97837a68ddec0dd0cc
3
+ metadata.gz: da80b152cde2c888a430bbada6c10bcf17014051966422051fe8b03f72289d37
4
+ data.tar.gz: 7dae249fdedc88b62ed6446530ff8c7b4571aa92b7b2e7971d0b17387f1a64e6
5
5
  SHA512:
6
- metadata.gz: 2f628da6521093b39fa707d8305431e5282f4a5c9bae5f386f8e91b59d56be873f3705844b146a220a97e6ca1d8eb7f7b822e22d37c162499b4e418b2aebe5e3
7
- data.tar.gz: 232035507f0adfe737d0271c9e2d4200330e0921205c4ae2f5800564d755ed82630ad58955615102e6e3c40392f4270fb0a9167e70f769c29e701b96eb6acf40
6
+ metadata.gz: 1e675715605ea756267eb2366ad0a1c77d118323cd6a01e9a997d1a2a46081e2cce5f18869aaaf60887cc82f496994730e74001520aee83f4708fad97d3570ed
7
+ data.tar.gz: 106e313ebc91bcfcea283c7d1977044ff349e2ec6c0b67eb9e113a95805a9fff5f7c4c8b95651526ff8dd49a9fa23057b00e10dc0c2c018fa9dbcdba49a32c56
@@ -22,9 +22,11 @@ module Qti
22
22
 
23
23
  def solutions
24
24
  node.xpath('.//xmlns:var_set').map do |anode|
25
+ output = anode.at_xpath('.//xmlns:answer')&.text
26
+
25
27
  {
26
28
  inputs: vars_at_node(anode),
27
- output: anode.at_xpath('.//xmlns:answer')&.text&.to_f
29
+ output: formula_scientific_notation ? output : output&.to_f
28
30
  }
29
31
  end
30
32
  end
@@ -49,6 +51,10 @@ module Qti
49
51
  @node.at_xpath('.//xmlns:formulas/@decimal_places')&.value
50
52
  end
51
53
 
54
+ def formula_scientific_notation
55
+ @node.at_xpath('.//xmlns:formulas/@scientific_notation')&.value == 'true'
56
+ end
57
+
52
58
  def formulas
53
59
  node.xpath('.//xmlns:formula').map(&:text)
54
60
  end
data/lib/qti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qti
2
- VERSION = '2.20.1'.freeze
2
+ VERSION = '2.20.2'.freeze
3
3
  end
@@ -0,0 +1,74 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <questestinterop xmlns="http://www.imsglobal.org/xsd/ims_qtiasiv1p2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/ims_qtiasiv1p2 http://www.imsglobal.org/xsd/ims_qtiasiv1p2p1.xsd">
3
+ <item ident="id39adb107fd2d03971a2d4206c6550dc" title="Formula">
4
+ <itemmetadata>
5
+ <qtimetadata>
6
+ <qtimetadatafield>
7
+ <fieldlabel>question_type</fieldlabel>
8
+ <fieldentry>calculated_question</fieldentry>
9
+ </qtimetadatafield>
10
+ <qtimetadatafield>
11
+ <fieldlabel>points_possible</fieldlabel>
12
+ <fieldentry>1.0</fieldentry>
13
+ </qtimetadatafield>
14
+ <qtimetadatafield>
15
+ <fieldlabel>assessment_question_identifierref</fieldlabel>
16
+ <fieldentry>i2c64259a331bc821bdcb2f326cf36631</fieldentry>
17
+ </qtimetadatafield>
18
+ </qtimetadata>
19
+ </itemmetadata>
20
+ <presentation>
21
+ <material>
22
+ <mattext texttype="text/html">&lt;div&gt;&lt;p&gt;What number is [x]&lt;/p&gt;&lt;/div&gt;</mattext>
23
+ </material>
24
+ <response_str ident="response1" rcardinality="Single">
25
+ <render_fib fibtype="Decimal">
26
+ <response_label ident="answer1"/>
27
+ </render_fib>
28
+ </response_str>
29
+ </presentation>
30
+ <resprocessing>
31
+ <outcomes>
32
+ <decvar maxvalue="100" minvalue="0" varname="SCORE" vartype="Decimal"/>
33
+ </outcomes>
34
+ <respcondition title="correct">
35
+ <conditionvar>
36
+ <other/>
37
+ </conditionvar>
38
+ <setvar varname="SCORE" action="Set">100</setvar>
39
+ </respcondition>
40
+ <respcondition title="incorrect">
41
+ <conditionvar>
42
+ <not>
43
+ <other/>
44
+ </not>
45
+ </conditionvar>
46
+ <setvar varname="SCORE" action="Set">0</setvar>
47
+ </respcondition>
48
+ </resprocessing>
49
+ <itemproc_extension>
50
+ <calculated>
51
+ <answer_tolerance margin_type="">0</answer_tolerance>
52
+ <formulas decimal_places="0" scientific_notation="true">
53
+ <formula>5+x</formula>
54
+ </formulas>
55
+ <vars>
56
+ <var name="x" scale="0">
57
+ <min>0</min>
58
+ <max>10</max>
59
+ </var>
60
+ </vars>
61
+ <var_sets>
62
+ <var_set ident="7d5006729d5dbc489c374a2cd5f41352">
63
+ <var name="x">9</var>
64
+ <answer>1*10^1</answer>
65
+ </var_set>
66
+ <var_set ident="15f629c4045e838e172b04824caa3893">
67
+ <var name="x">2</var>
68
+ <answer>7*10^0</answer>
69
+ </var_set>
70
+ </var_sets>
71
+ </calculated>
72
+ </itemproc_extension>
73
+ </item>
74
+ </questestinterop>
@@ -13,6 +13,7 @@ describe Qti::V1::Models::Interactions::FormulaInteraction do
13
13
  shared_examples_for 'reading_formulas' do
14
14
  it 'reads formulas correctly' do
15
15
  expect(loaded_class.formula_decimal_places).to eq(formula_decimal_places)
16
+ expect(loaded_class.formula_scientific_notation).to eq(formula_scientific_notation)
16
17
  expect(loaded_class.formulas).to eq(formula_formulas)
17
18
  end
18
19
  end
@@ -41,6 +42,7 @@ describe Qti::V1::Models::Interactions::FormulaInteraction do
41
42
  let(:answer_tolerance) { '0' }
42
43
  let(:margin_of_error) { { margin: '0', margin_type: 'absolute' } }
43
44
  let(:formula_decimal_places) { '0' }
45
+ let(:formula_scientific_notation) { false }
44
46
  let(:formula_formulas) { ['x'] }
45
47
 
46
48
  let(:item_title) { '<div><p>What number is [x]</p></div>' }
@@ -61,6 +63,7 @@ describe Qti::V1::Models::Interactions::FormulaInteraction do
61
63
  let(:answer_tolerance) { '0' }
62
64
  let(:margin_of_error) { { margin: '0', margin_type: 'absolute' } }
63
65
  let(:formula_decimal_places) { '0' }
66
+ let(:formula_scientific_notation) { false }
64
67
  let(:formula_formulas) { ['x+y'] }
65
68
 
66
69
  let(:item_title) { '<div><p>[x] + [y]</p></div>' }
@@ -84,6 +87,7 @@ describe Qti::V1::Models::Interactions::FormulaInteraction do
84
87
  let(:answer_tolerance) { '10%' }
85
88
  let(:margin_of_error) { { margin: '10', margin_type: 'percent' } }
86
89
  let(:formula_decimal_places) { '2' }
90
+ let(:formula_scientific_notation) { false }
87
91
  let(:formula_formulas) { ['x=n*x', 'y=m*y', 'x+y'] }
88
92
 
89
93
  let(:item_title) { '<div><p>[n][x] + [m][y]</p></div>' }
@@ -100,4 +104,26 @@ describe Qti::V1::Models::Interactions::FormulaInteraction do
100
104
  include_examples 'reading_formulas'
101
105
  include_examples 'variables'
102
106
  end
107
+
108
+ context 'Formula with scientific notation' do
109
+ let(:file_path) { File.join(fixtures_path, 'formula_scientific.xml') }
110
+
111
+ let(:scoring_data_values) { ['1*10^1', '7*10^0'] }
112
+
113
+ let(:answer_tolerance) { '0' }
114
+ let(:formula_decimal_places) { '0' }
115
+ let(:formula_scientific_notation) { true }
116
+ let(:formula_formulas) { ['x'] }
117
+ let(:margin_of_error) { { margin: '0', margin_type: 'absolute' } }
118
+ let(:formula_formulas) { ['5+x'] }
119
+
120
+ let(:item_title) { '<div><p>What number is [x]</p></div>' }
121
+
122
+ let(:variables) { [{ max: 10.0, min: 0.0, name: 'x', precision: 0 }] }
123
+
124
+ include_examples 'scoring_data_structs'
125
+ include_examples 'reading_formulas'
126
+ include_examples 'answer_tolerance'
127
+ include_examples 'variables'
128
+ end
103
129
  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: 2.20.1
4
+ version: 2.20.2
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: 2023-08-11 00:00:00.000000000 Z
15
+ date: 2023-08-15 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: actionview
@@ -409,6 +409,7 @@ files:
409
409
  - spec/fixtures/items_1.2/formula.xml
410
410
  - spec/fixtures/items_1.2/formula_mform.xml
411
411
  - spec/fixtures/items_1.2/formula_mvar.xml
412
+ - spec/fixtures/items_1.2/formula_scientific.xml
412
413
  - spec/fixtures/items_1.2/hot_spot.xml
413
414
  - spec/fixtures/items_1.2/item_no_title.xml
414
415
  - spec/fixtures/items_1.2/matching.xml
@@ -783,6 +784,7 @@ test_files:
783
784
  - spec/fixtures/items_1.2/formula.xml
784
785
  - spec/fixtures/items_1.2/formula_mform.xml
785
786
  - spec/fixtures/items_1.2/formula_mvar.xml
787
+ - spec/fixtures/items_1.2/formula_scientific.xml
786
788
  - spec/fixtures/items_1.2/hot_spot.xml
787
789
  - spec/fixtures/items_1.2/item_no_title.xml
788
790
  - spec/fixtures/items_1.2/matching.xml