qti 2.22.6 → 2.23.1

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: a72b532cd51607d749d519695eedd195baa829425689fb89651a240fe2ce6f74
4
- data.tar.gz: f4ca8d029a779c5f5b4b80c782238271647cee5d7cb15a4c221ffe5f5d53b1f7
3
+ metadata.gz: bd8303859118b11ead1859869efcadb1345b74da5c0d03099d961ed8ed33439d
4
+ data.tar.gz: 5f7e10b30898792b696d61cb14bc9a117c027462df0da9b5c35a347f98df62b6
5
5
  SHA512:
6
- metadata.gz: 97053ee0f769f90b7148271a7ecf0fe309adb72e48adb6feea2c823225c0a7c27a9bc4adae09b7f2fd812b063a7197a77fe316598e5539aff74c7d66471d207e
7
- data.tar.gz: 3ca0b4a412a6573fc530693e301bafca22e636742d069713b0be51e3ff923d302bfaee84792bbc72812553b8fb59eefe7e1eaaea67803634445ced172157d04f
6
+ metadata.gz: faf84243d53822d2bb64712f5ea2215377199e956bec31e11d55a6d361b8f4c5509a2c7516c04b33141509877b2ad7f2c17b116b8bfbb9377f896212190ff298
7
+ data.tar.gz: 854b534ca6c5b4d30f6bca3287144fdfc884e7a977ea2d875d226da0ddeb41d0da5b5294c0371444da630f049209259ff222cf986b998b45cebec5279938edf3
@@ -14,6 +14,10 @@ module Qti
14
14
  @title ||= xpath_with_single_check('.//xmlns:assessment/@title')&.content || File.basename(@path, '.xml')
15
15
  end
16
16
 
17
+ def external_assignment_id
18
+ @external_assignment_id ||= xpath_with_single_check('.//xmlns:assessment/@external_assignment_id')&.content
19
+ end
20
+
17
21
  def assessment_items
18
22
  @doc.xpath("//*[self::#{GROUP_ID} or self::xmlns:item[not(ancestor::#{GROUP_ID})]" \
19
23
  ' or self::xmlns:bankentry_item]')
@@ -83,7 +83,7 @@ module Qti
83
83
  # rubocop:enable Metrics/AbcSize
84
84
  def setvar_nodes(choice_nodes)
85
85
  choice_nodes.select do |choice_node|
86
- choice_node.at_xpath('.//xmlns:setvar')&.content&.to_f&.positive?
86
+ choice_node.at_xpath('.//xmlns:setvar')&.content&.present?
87
87
  end
88
88
  end
89
89
  end
@@ -13,6 +13,10 @@ module Qti
13
13
  @identifier ||= xpath_with_single_check('.//xmlns:objectbank/@ident')&.content
14
14
  end
15
15
 
16
+ def canvas_item_bank
17
+ @canvas_item_bank ||= xpath_with_single_check('.//xmlns:objectbank/@canvas_item_bank')&.content
18
+ end
19
+
16
20
  # tells us whether the bank was an account or course bank
17
21
  def bank_type
18
22
  @bank_type ||= xpath_with_single_check(
@@ -13,6 +13,10 @@ module Qti
13
13
  @title ||= xpath_with_single_check('//xmlns:assessmentTest/@title')&.content || File.basename(@path, '.xml')
14
14
  end
15
15
 
16
+ def external_assignment_id
17
+ nil
18
+ end
19
+
16
20
  def assessment_items
17
21
  # Return the xml files we should be parsing
18
22
  @assessment_items ||= begin
data/lib/qti/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qti
2
- VERSION = '2.22.6'.freeze
2
+ VERSION = '2.23.1'.freeze
3
3
  end
@@ -0,0 +1,69 @@
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
+ <assessment title="1.2 Import Quiz" ident="A1001">
4
+ <section title="Main" ident="S1002">
5
+ <item ident="d74b47a4abeeed159e030bfecbcecea2" title="My question title">
6
+ <itemmetadata>
7
+ <qtimetadata>
8
+ <qtimetadatafield>
9
+ <fieldlabel>question_type</fieldlabel>
10
+ <fieldentry>multiple_choice_question</fieldentry>
11
+ </qtimetadatafield>
12
+ <qtimetadatafield>
13
+ <fieldlabel>points_possible</fieldlabel>
14
+ <fieldentry>10.0</fieldentry>
15
+ </qtimetadatafield>
16
+ <qtimetadatafield>
17
+ <fieldlabel>original_answer_ids</fieldlabel>
18
+ <fieldentry>93bbcb84-3281-4d99-b243-79ba4051e654,3cd6d311-07cd-4ec0-b2db-3048e6cf1128</fieldentry>
19
+ </qtimetadatafield>
20
+ <qtimetadatafield>
21
+ <fieldlabel>assessment_question_identifierref</fieldlabel>
22
+ <fieldentry>9f47365e112840d80a79a960b1b0b6a7</fieldentry>
23
+ </qtimetadatafield>
24
+ <qtimetadatafield>
25
+ <fieldlabel>calculator_type</fieldlabel>
26
+ <fieldentry>none</fieldentry>
27
+ </qtimetadatafield>
28
+ </qtimetadata>
29
+ </itemmetadata>
30
+ <presentation>
31
+ <material>
32
+ <mattext texttype="text/html">&lt;p&gt;the correct answer is letter A&lt;/p&gt;</mattext>
33
+ </material>
34
+ <response_lid ident="response1" rcardinality="Single">
35
+ <render_choice>
36
+ <response_label ident="93bbcb84-3281-4d99-b243-79ba4051e654">
37
+ <material>
38
+ <mattext texttype="text/html">A</mattext>
39
+ </material>
40
+ </response_label>
41
+ <response_label ident="3cd6d311-07cd-4ec0-b2db-3048e6cf1128">
42
+ <material>
43
+ <mattext texttype="text/html">B</mattext>
44
+ </material>
45
+ </response_label>
46
+ </render_choice>
47
+ </response_lid>
48
+ </presentation>
49
+ <resprocessing>
50
+ <outcomes>
51
+ <decvar maxvalue="100" minvalue="0" varname="SCORE" vartype="Decimal"/>
52
+ </outcomes>
53
+ <respcondition>
54
+ <conditionvar>
55
+ <varequal respident="response1">93bbcb84-3281-4d99-b243-79ba4051e654</varequal>
56
+ </conditionvar>
57
+ <setvar action="Set" varname="SCORE">0.0</setvar>
58
+ </respcondition>
59
+ <respcondition correctanswer="Yes">
60
+ <conditionvar>
61
+ <varequal respident="response1">3cd6d311-07cd-4ec0-b2db-3048e6cf1128</varequal>
62
+ </conditionvar>
63
+ <setvar action="Set" varname="SCORE">0.0</setvar>
64
+ </respcondition>
65
+ </resprocessing>
66
+ </item>
67
+ </section>
68
+ </assessment>
69
+ </questestinterop>
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="ISO-8859-1"?>
2
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
- <assessment title="1.2 Import Quiz" ident="A1001">
3
+ <assessment title="1.2 Import Quiz" ident="A1001" external_assignment_id="801785">
4
4
  <section title="Main" ident="S1002">
5
5
  <item title="Grading - specific - 3 pt score" ident="QUE_1003">
6
6
  <presentation>
@@ -138,7 +138,7 @@ describe Qti::V1::Models::AssessmentItem do
138
138
  describe '#scoring_data_structs' do
139
139
  it 'grabs the rcardinality and scoring data value' do
140
140
  struct = loaded_class.send(:scoring_data_structs)
141
- expect(struct.first.values).to eq 'QUE_1006_A2'
141
+ expect(struct.first.values).to eq 'QUE_1005_A1'
142
142
  expect(struct.first.rcardinality).to eq 'Single'
143
143
  end
144
144
  end
@@ -266,4 +266,26 @@ describe Qti::V1::Models::AssessmentItem do
266
266
  end
267
267
  end
268
268
  end
269
+
270
+ context 'multiple choice with "vary points by answer" and answers with zero points' do
271
+ let(:file_path) { File.join('spec', 'fixtures', 'items_1.2', 'choice_vary_points_by_answer_zero_points.xml') }
272
+ let(:test_object) { Qti::V1::Models::Assessment.from_path!(file_path) }
273
+ let(:assessment_item_refs) { test_object.assessment_items }
274
+ let(:loaded_class) { described_class.new(assessment_item_refs.first) }
275
+
276
+ describe '#scoring_data_structs' do
277
+ it 'collects all the correct answers' do
278
+ struct = loaded_class.scoring_data_structs
279
+ expect(struct.size).to eq 2
280
+ expect(struct.map(&:values)).to eq %w[93bbcb84-3281-4d99-b243-79ba4051e654 3cd6d311-07cd-4ec0-b2db-3048e6cf1128]
281
+ end
282
+
283
+ it 'collect all the points answer points' do
284
+ struct = loaded_class.scoring_data_structs
285
+ expect(struct.size).to eq 2
286
+ expect(struct.map(&:scoring_options)).to eq([{ 'points' => 0.0 },
287
+ { 'points' => 0.0, 'correct_answer' => true }])
288
+ end
289
+ end
290
+ end
269
291
  end
@@ -25,6 +25,12 @@ describe Qti::V1::Models::Assessment do
25
25
  expect(loaded_class.identifier).to eq(expected_identifier)
26
26
  end
27
27
  end
28
+
29
+ describe '#external_assignment_id' do
30
+ it 'retruns the external_assignment_id' do
31
+ expect(loaded_class.external_assignment_id).to eq(expected_external_assignment_id)
32
+ end
33
+ end
28
34
  end
29
35
 
30
36
  shared_examples_for 'verify quiz items' do
@@ -43,6 +49,7 @@ describe Qti::V1::Models::Assessment do
43
49
  let(:loaded_class) { described_class.from_path!(path) }
44
50
  let(:expected_title) { '1.2 Import Quiz' }
45
51
  let(:expected_identifier) { 'A1001' }
52
+ let(:expected_external_assignment_id) { '801785' }
46
53
  let(:expected_item_count) { 5 }
47
54
 
48
55
  include_examples('basic quiz fields')
@@ -52,6 +59,7 @@ describe Qti::V1::Models::Assessment do
52
59
  let(:path) { File.join(fixtures_path, 'feedback_quiz_1.2.xml') }
53
60
  let(:loaded_class) { described_class.from_path!(path) }
54
61
  let(:expected_title) { 'I Can Haz Feedback' }
62
+ let(:expected_external_assignment_id) { nil }
55
63
  let(:expected_identifier) { 'i618e88580f76f70a1ed28804f497df9c' }
56
64
  let(:expected_item_count) { 3 }
57
65
  let(:expected_item_data) do
@@ -82,6 +90,7 @@ describe Qti::V1::Models::Assessment do
82
90
  let(:path) { File.join(fixtures_path, 'all_canvas_simple_1.2.xml') }
83
91
  let(:loaded_class) { described_class.from_path!(path) }
84
92
  let(:expected_title) { 'Every Canvas Interaction' }
93
+ let(:expected_external_assignment_id) { nil }
85
94
  let(:expected_identifier) { 'ie09bc528e6ecd1cb9ebfafd940c20215' }
86
95
  let(:expected_item_count) { 10 }
87
96
  let(:expected_item_data) do
@@ -3,7 +3,7 @@ describe Qti::V1::Models::ObjectBank do
3
3
  <<~XML
4
4
  <?xml version="1.0" encoding="UTF-8"?>
5
5
  <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">
6
- <objectbank ident="gooblegobble12345">
6
+ <objectbank ident="gooblegobble12345" canvas_item_bank="true">
7
7
  <qtimetadata>
8
8
  <qtimetadatafield>
9
9
  <fieldlabel>not_a_bank_title</fieldlabel>
@@ -57,6 +57,14 @@ describe Qti::V1::Models::ObjectBank do
57
57
  end
58
58
  end
59
59
 
60
+ describe '#canvas_item_bank' do
61
+ it 'returns the canvas_item_bank' do
62
+ allow(File).to receive(:read).and_return(doc)
63
+ objectbank = described_class.new path: '/etc/FakeBank008.xml'
64
+ expect(objectbank.canvas_item_bank).to eq 'true'
65
+ end
66
+ end
67
+
60
68
  describe '#bank_type' do
61
69
  it 'has the bank_type attribute' do
62
70
  allow(File).to receive(:read).and_return(doc)
@@ -19,6 +19,10 @@ describe Qti::V2::Models::AssessmentTest do
19
19
  expect(loaded_class.identifier).to eq 'SPECTATUS-GENERATED-TEST'
20
20
  end
21
21
 
22
+ it 'has a nil external_assignment_id' do
23
+ expect(loaded_class.external_assignment_id).to be_nil
24
+ end
25
+
22
26
  it 'gets dependency file refs' do
23
27
  refs = loaded_class.assessment_items
24
28
  expect(refs.all? { |ref| File.extname(ref[:path]) == '.xml' })
data/spec/lib/qti_spec.rb CHANGED
@@ -35,7 +35,7 @@ describe Qti::Importer do
35
35
  assessment_items = importer.assessment_item_refs.map { |item| importer.create_assessment_item(item) }
36
36
  expect(assessment_items.count).to eq 5
37
37
  answer_arity = assessment_items.map { |item| item.scoring_data_structs.count }
38
- expect(answer_arity).to eq [1, 1, 4, 1, 1]
38
+ expect(answer_arity).to eq [2, 5, 7, 1, 1]
39
39
  end
40
40
 
41
41
  it 'sets the path and package root properly' do
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.22.6
4
+ version: 2.23.1
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-01-18 00:00:00.000000000 Z
15
+ date: 2024-06-25 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: actionview
@@ -403,6 +403,7 @@ files:
403
403
  - spec/fixtures/items_1.2/categorization.xml
404
404
  - spec/fixtures/items_1.2/choice.xml
405
405
  - spec/fixtures/items_1.2/choice_vary_points_by_answer.xml
406
+ - spec/fixtures/items_1.2/choice_vary_points_by_answer_zero_points.xml
406
407
  - spec/fixtures/items_1.2/essay.xml
407
408
  - spec/fixtures/items_1.2/essay_custom_settings.xml
408
409
  - spec/fixtures/items_1.2/fib.xml
@@ -783,6 +784,7 @@ test_files:
783
784
  - spec/fixtures/items_1.2/categorization.xml
784
785
  - spec/fixtures/items_1.2/choice.xml
785
786
  - spec/fixtures/items_1.2/choice_vary_points_by_answer.xml
787
+ - spec/fixtures/items_1.2/choice_vary_points_by_answer_zero_points.xml
786
788
  - spec/fixtures/items_1.2/essay.xml
787
789
  - spec/fixtures/items_1.2/essay_custom_settings.xml
788
790
  - spec/fixtures/items_1.2/fib.xml