qti 2.24.0 → 2.25.2

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
  SHA256:
3
- metadata.gz: fa2391bbfd265fba1241b29e4da36121ef06649841bcc2037f7dd34c27523bc4
4
- data.tar.gz: a6ba533017ca01b780802613bb7dd1d571511da04e41913a6eb2ac052ffde089
3
+ metadata.gz: 062a48a89ca4ced5ac4c33976eaa79be84d9f9f883de111d0cf8643550c1dd62
4
+ data.tar.gz: d6ec810ebbc758d650c2c081cbb777c1fd073bb1fc176b1e7b80958884cafc54
5
5
  SHA512:
6
- metadata.gz: 42ad1f00560acbecb59706297352f19cf72b68d11a68a23135d086b00f678b721c4529aaef5c04027457dc215b0264ea5f2158b10f1a095127b746c2013689e6
7
- data.tar.gz: 634a08fff1a70580908fdab9242c9ea333c8beff5529e136455f9b37f7e9652fd3ee4c3327c5ce2f6153825474149b6bc5fa935044f05b304f4a88a3515228f1
6
+ metadata.gz: 6abd2fda6c86e08b215c2ff3b7b1c79fdb8b5170af23de03c7f537528f2d6297981c941bf9ed19d9ee38345b9b13794abb24f68b7ab246693da55be0da1c8b18
7
+ data.tar.gz: 4140785078c7f4412d6c94e7124706e694bb5e884dc811d40db7e9c5c916ed81e0da86741378a4773c71abd5f8794e7ea8373383fe8b6f0fca808f0921ae0ac8
@@ -31,22 +31,32 @@ module Qti
31
31
  end
32
32
 
33
33
  def shape_type
34
- @shape_type ||= response_label&.attributes&.[]('rarea')&.value
34
+ @shape_type ||= extract_shape_type(response_label)
35
35
  end
36
36
 
37
37
  def coordinates
38
- @coordinates ||= begin
39
- raw_coordinates_array = raw_coordinates.split(',')
40
- return [] unless (raw_coordinates_array.length % 2).zero?
38
+ @coordinates ||= parse_coordinates(raw_coordinates)
39
+ end
41
40
 
42
- raw_coordinates_array.each_slice(2).map do |point|
43
- { x: point[0].to_f, y: point[1].to_f }
44
- end
45
- end
41
+ def scoring_data_structs
42
+ @scoring_data_structs ||= parse_scoring_data
46
43
  end
47
44
 
48
45
  private
49
46
 
47
+ def parse_scoring_data
48
+ raw_scoring_data = answer_nodes&.map do |answer|
49
+ {
50
+ id: extract_identifier(answer),
51
+ type: extract_shape_type(answer),
52
+ coordinates: parse_coordinates(answer&.text || '')
53
+ }
54
+ end
55
+ raw_scoring_data.map do |values|
56
+ Models::ScoringData.new(values, rcardinality)
57
+ end
58
+ end
59
+
50
60
  def response_label
51
61
  @response_label ||= begin
52
62
  node = @node.dup
@@ -55,10 +65,35 @@ module Qti
55
65
  end
56
66
  end
57
67
 
68
+ def answer_nodes
69
+ @answer_nodes ||= begin
70
+ node = @node.dup
71
+ presentation = node.at_xpath('.//xmlns:presentation')
72
+ presentation.xpath('.//xmlns:response_label')
73
+ end
74
+ end
75
+
58
76
  def raw_coordinates
59
77
  @raw_coordinates ||= response_label&.text || ''
60
78
  end
61
79
 
80
+ def extract_shape_type(answer)
81
+ answer&.attributes&.[]('rarea')&.value
82
+ end
83
+
84
+ def extract_identifier(answer)
85
+ answer&.attributes&.[]('ident')&.value
86
+ end
87
+
88
+ def parse_coordinates(raw_coordinates)
89
+ raw_coordinates_array = raw_coordinates.split(',')
90
+ return [] unless (raw_coordinates_array.length % 2).zero?
91
+
92
+ raw_coordinates_array.each_slice(2).map do |point|
93
+ { x: point[0].to_f, y: point[1].to_f }
94
+ end
95
+ end
96
+
62
97
  def coordinate_hash(coordinate_node)
63
98
  %w[x y].map do |axis|
64
99
  [axis.to_sym, coordinate_node&.attributes&.[](axis)&.value&.to_f]
data/lib/qti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qti
2
- VERSION = '2.24.0'.freeze
2
+ VERSION = '2.25.2'.freeze
3
3
  end
data/lib/qti.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'logger'
1
2
  require 'action_view'
2
3
  require 'active_support/core_ext/array/access'
3
4
  require 'active_support/core_ext/string'
@@ -39,7 +39,7 @@
39
39
  <material>
40
40
  <matimage uri="$IMS-CC-FILEBASE$/Uploaded Media/someuuid"/>
41
41
  </material>
42
- <response_label ident="response1" rarea="square">0.372,0.1376,0.616,0.4256</response_label>
42
+ <response_label ident="response1" rarea="rectangle">0.372,0.1376,0.616,0.4256</response_label>
43
43
  </render_hotspot>
44
44
  </response_xy>
45
45
  </flow>
@@ -76,7 +76,7 @@
76
76
  <material>
77
77
  <matimage uri="$IMS-CC-FILEBASE$/Uploaded Media/someuuid"/>
78
78
  </material>
79
- <response_label ident="response1" rarea="square">0.372</response_label>
79
+ <response_label ident="response1" rarea="rectangle">0.372</response_label>
80
80
  </render_hotspot>
81
81
  </response_xy>
82
82
  </flow>
@@ -113,7 +113,46 @@
113
113
  <material>
114
114
  <matimage uri="$IMS-CC-FILEBASE$/Uploaded Media/someuuid"/>
115
115
  </material>
116
- <response_label ident="response1" rarea="square"></response_label>
116
+ <response_label ident="response1" rarea="rectangle"></response_label>
117
+ </render_hotspot>
118
+ </response_xy>
119
+ </flow>
120
+ </presentation>
121
+ </item>
122
+ <item ident="g515255148f5a3cae1832584071aa8529" title="hot-spot with multiple selections">
123
+ <itemmetadata>
124
+ <qtimetadata>
125
+ <qtimetadatafield>
126
+ <fieldlabel>question_type</fieldlabel>
127
+ <fieldentry>hot_spot_question</fieldentry>
128
+ </qtimetadatafield>
129
+ <qtimetadatafield>
130
+ <fieldlabel>points_possible</fieldlabel>
131
+ <fieldentry>1.0</fieldentry>
132
+ </qtimetadatafield>
133
+ <qtimetadatafield>
134
+ <fieldlabel>original_answer_ids</fieldlabel>
135
+ <fieldentry/>
136
+ </qtimetadatafield>
137
+ <qtimetadatafield>
138
+ <fieldlabel>assessment_question_identifierref</fieldlabel>
139
+ <fieldentry>gd6ff15355f3dd3f532816fa268230130</fieldentry>
140
+ </qtimetadatafield>
141
+ </qtimetadata>
142
+ </itemmetadata>
143
+ <presentation>
144
+ <flow>
145
+ <response_xy ident="response1" rcardinality="Multiple" rtiming="No">
146
+ <material>
147
+ <mattext texttype="text/html">&lt;p&gt;point something on the image&lt;/p&gt;</mattext>
148
+ </material>
149
+ <render_hotspot>
150
+ <material>
151
+ <matimage uri="$IMS-CC-FILEBASE$/Uploaded Media/someuuid"/>
152
+ </material>
153
+ <response_label ident="response1" rarea="rectangle">0.1,0.2,0.3,0.4</response_label>
154
+ <response_label ident="response2" rarea="ellipse">0.5,0.6,0.7,0.8</response_label>
155
+ <response_label ident="response3" rarea="bounded">0.9,0.1,0.2,0.3</response_label>
117
156
  </render_hotspot>
118
157
  </response_xy>
119
158
  </flow>
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../../'
4
+
5
+ gem 'rails', '~> 7.1.0'
@@ -28,7 +28,7 @@ describe Qti::V1::Models::Interactions::HotSpotInteraction do
28
28
  describe '#shape_type' do
29
29
  let(:loaded_class) { described_class.new(assessment_item_refs.first, test_object) }
30
30
  it 'returns correct shape type' do
31
- expect(loaded_class.shape_type).to eq 'square'
31
+ expect(loaded_class.shape_type).to eq 'rectangle'
32
32
  end
33
33
  end
34
34
 
@@ -54,4 +54,35 @@ describe Qti::V1::Models::Interactions::HotSpotInteraction do
54
54
  end
55
55
  end
56
56
  end
57
+
58
+ describe '#scoring_data_structs' do
59
+ context 'with a single hotspot' do
60
+ let(:loaded_class) { described_class.new(assessment_item_refs.first, test_object) }
61
+
62
+ it 'returns scoring data with a single hotspot' do
63
+ scoring_data = loaded_class.scoring_data_structs
64
+ expect(scoring_data.size).to eq(1)
65
+ expect(scoring_data.first.values[:type]).to eq('rectangle')
66
+ expect(scoring_data.first.values[:coordinates]).to eq([{ x: 0.372, y: 0.1376 }, { x: 0.616, y: 0.4256 }])
67
+ end
68
+ end
69
+
70
+ context 'with multiple hotspots' do
71
+ let(:loaded_class) { described_class.new(assessment_item_refs[3], test_object) }
72
+
73
+ it 'returns scoring data with multiple hotspots' do
74
+ scoring_data = loaded_class.scoring_data_structs
75
+ expect(scoring_data.size).to eq(3)
76
+
77
+ expect(scoring_data[0].values[:type]).to eq('rectangle')
78
+ expect(scoring_data[0].values[:coordinates]).to eq([{ x: 0.1, y: 0.2 }, { x: 0.3, y: 0.4 }])
79
+
80
+ expect(scoring_data[1].values[:type]).to eq('ellipse')
81
+ expect(scoring_data[1].values[:coordinates]).to eq([{ x: 0.5, y: 0.6 }, { x: 0.7, y: 0.8 }])
82
+
83
+ expect(scoring_data[2].values[:type]).to eq('bounded')
84
+ expect(scoring_data[2].values[:coordinates]).to eq([{ x: 0.9, y: 0.1 }, { x: 0.2, y: 0.3 }])
85
+ end
86
+ end
87
+ end
57
88
  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.24.0
4
+ version: 2.25.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: 2024-10-23 00:00:00.000000000 Z
15
+ date: 2025-01-28 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: actionview
@@ -21,9 +21,6 @@ dependencies:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: '6.0'
24
- - - "<"
25
- - !ruby/object:Gem::Version
26
- version: '7.2'
27
24
  type: :runtime
28
25
  prerelease: false
29
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,9 +28,6 @@ dependencies:
31
28
  - - ">="
32
29
  - !ruby/object:Gem::Version
33
30
  version: '6.0'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '7.2'
37
31
  - !ruby/object:Gem::Dependency
38
32
  name: activesupport
39
33
  requirement: !ruby/object:Gem::Requirement
@@ -41,9 +35,6 @@ dependencies:
41
35
  - - ">="
42
36
  - !ruby/object:Gem::Version
43
37
  version: '6.0'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '7.2'
47
38
  type: :runtime
48
39
  prerelease: false
49
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,9 +42,6 @@ dependencies:
51
42
  - - ">="
52
43
  - !ruby/object:Gem::Version
53
44
  version: '6.0'
54
- - - "<"
55
- - !ruby/object:Gem::Version
56
- version: '7.2'
57
45
  - !ruby/object:Gem::Dependency
58
46
  name: dry-logic
59
47
  requirement: !ruby/object:Gem::Requirement
@@ -679,6 +667,7 @@ files:
679
667
  - spec/gemfiles/rails-6.0.gemfile
680
668
  - spec/gemfiles/rails-6.1.gemfile
681
669
  - spec/gemfiles/rails-7.0.gemfile
670
+ - spec/gemfiles/rails-7.1.gemfile
682
671
  - spec/lib/qti/assessment_item_exporter_spec.rb
683
672
  - spec/lib/qti/exporter_spec.rb
684
673
  - spec/lib/qti/models/assessment_meta_spec.rb
@@ -1061,6 +1050,7 @@ test_files:
1061
1050
  - spec/gemfiles/rails-6.0.gemfile
1062
1051
  - spec/gemfiles/rails-6.1.gemfile
1063
1052
  - spec/gemfiles/rails-7.0.gemfile
1053
+ - spec/gemfiles/rails-7.1.gemfile
1064
1054
  - spec/lib/qti/assessment_item_exporter_spec.rb
1065
1055
  - spec/lib/qti/exporter_spec.rb
1066
1056
  - spec/lib/qti/models/assessment_meta_spec.rb