qti 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qti.rb +14 -26
- data/lib/qti/models/manifest.rb +19 -5
- data/lib/qti/v1/models/assessment.rb +12 -0
- data/lib/qti/v2/models/assessment_test.rb +13 -1
- data/lib/qti/v2/models/interactions/categorization_interaction.rb +3 -3
- data/lib/qti/v2/models/interactions/match_interaction.rb +6 -6
- data/lib/qti/v2/models/interactions/match_item_tag_processors/associate_interaction_tag_processor.rb +1 -1
- data/lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb +1 -1
- data/lib/qti/v2/models/non_assessment_test.rb +26 -0
- data/lib/qti/v2/models/stimulus_item.rb +32 -0
- data/spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832.html +12 -0
- data/spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832.xml +52 -0
- data/spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_A.html +1 -0
- data/spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_B.html +1 -0
- data/spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_C.html +1 -0
- data/spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_D.html +1 -0
- data/spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078.html +4 -0
- data/spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078.xml +39 -0
- data/spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_A.html +1 -0
- data/spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_B.html +1 -0
- data/spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_C.html +1 -0
- data/spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_D.html +1 -0
- data/spec/fixtures/no_assessment_XML/imsmanifest.xml +769 -0
- data/spec/fixtures/no_assessment_XML/passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f.html +21 -0
- data/spec/fixtures/no_assessment_XML/passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f_instructions.html +7 -0
- data/spec/lib/qti/models/manifest_spec.rb +32 -6
- data/spec/lib/qti/v2/models/assessment_test_spec.rb +13 -2
- data/spec/lib/qti/v2/models/non_assessment_test_spec.rb +28 -0
- data/spec/lib/qti/v2/models/stimulus_item_spec.rb +27 -0
- data/spec/lib/qti_spec.rb +10 -13
- metadata +38 -2
@@ -0,0 +1,21 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
4
|
+
<title>¡El equipo de hockey te necesita!</title>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<div reference-title="¡El equipo de hockey te necesita!">
|
8
|
+
<div class="passage-block">
|
9
|
+
<div class="passage-text" style="">
|
10
|
+
<div class="title-block">
|
11
|
+
<div class="passage-title">
|
12
|
+
¡El equipo de hockey te necesita!
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<p><span style="font-family: helvetica; font-size: small;"><strong><span style="font-size: 12pt;">Listen to the audio passage.</span></strong><span style="font-weight: bold;"><span style="font-size: 12pt;"> </span><br clear="none" /></span></span></p>
|
16
|
+
<p><span style="font-family: helvetica; font-size: small;"><span style="font-weight: bold;"><span style="font-size: 12pt;">Audio file linked here</span></span></span></p>
|
17
|
+
</div>
|
18
|
+
</div>
|
19
|
+
</div>
|
20
|
+
</body>
|
21
|
+
</html>
|
data/spec/fixtures/no_assessment_XML/passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f_instructions.html
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
This audio stimulus will be a short lecture given by a man (about 40 years old).
|
2
|
+
|
3
|
+
Listen to the audio passage.
|
4
|
+
|
5
|
+
Estudiantes de la preparatoria Jefferson: Soy el profesor Ortíz, el profesor de educación física de la escuela. Estamos buscando jugadores para el nuevo equipo de hockey. Para estar en el equipo, hay que completar un formulario y presentar un examen físico. El examen es el viernes a las 10:00 de la mañana, en el gimnasio de la escuela.
|
6
|
+
|
7
|
+
¡Los esperamos!
|
@@ -3,17 +3,43 @@ require 'spec_helper'
|
|
3
3
|
fixtures_path = File.join('spec', 'fixtures')
|
4
4
|
|
5
5
|
describe Qti::Models::Manifest do
|
6
|
-
manifest_files =
|
7
|
-
manifest_files.each do |
|
6
|
+
manifest_files = ['test_qti_1.2', 'test_qti_1.2_canvas', 'test_qti_2.1', 'test_qti_2.2']
|
7
|
+
manifest_files.each do |mfile|
|
8
|
+
file = File.join(fixtures_path, mfile, 'imsmanifest.xml')
|
8
9
|
context "File: #{file}" do
|
9
10
|
it 'parses the manifest file without error' do
|
10
11
|
expect { described_class.from_path!(file) }.not_to raise_error
|
11
12
|
end
|
13
|
+
end
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
it 'returns a v1 assessment_test object if it finds a supported test file' do
|
17
|
+
qti1_files = ['test_qti_1.2', 'test_qti_1.2_canvas']
|
18
|
+
qti1_files.each do |qfile|
|
19
|
+
file = File.join(fixtures_path, qfile, 'imsmanifest.xml')
|
20
|
+
assessment_test = described_class.from_path!(file).assessment_test
|
21
|
+
expect(assessment_test).to be_kind_of(Qti::V1::Models::Assessment)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns a v2 assessment_test object if it finds a supported test file' do
|
26
|
+
qti2_files = ['test_qti_2.1', 'test_qti_2.2']
|
27
|
+
qti2_files.each do |qfile|
|
28
|
+
file = File.join(fixtures_path, qfile, 'imsmanifest.xml')
|
29
|
+
assessment_test = described_class.from_path!(file).assessment_test
|
30
|
+
expect(assessment_test).to be_kind_of(Qti::V2::Models::AssessmentTest)
|
17
31
|
end
|
18
32
|
end
|
33
|
+
|
34
|
+
it 'returns a v2 non assessment test if it is not a standard v2 package' do
|
35
|
+
file = File.join(fixtures_path, 'no_assessment_XML/imsmanifest.xml')
|
36
|
+
assessment_test = described_class.from_path!(file).assessment_test
|
37
|
+
expect(assessment_test).to be_kind_of(Qti::V2::Models::NonAssessmentTest)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'raises a non-supported QTI type if it finds no other supported type' do
|
41
|
+
file = File.join(fixtures_path, 'items_2.1/imsmanifest.xml')
|
42
|
+
expect { described_class.from_path!(file).assessment_test }.to raise_error('Unsupported QTI version')
|
43
|
+
end
|
44
|
+
|
19
45
|
end
|
@@ -18,7 +18,7 @@ describe Qti::V2::Models::AssessmentTest do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'gets dependency file refs' do
|
21
|
-
refs = loaded_class.
|
21
|
+
refs = loaded_class.assessment_items
|
22
22
|
expect(refs.all? { |ref| File.extname(ref) == '.xml' })
|
23
23
|
end
|
24
24
|
|
@@ -51,7 +51,7 @@ describe Qti::V2::Models::AssessmentTest do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'gets dependency file refs' do
|
54
|
-
refs = loaded_class.
|
54
|
+
refs = loaded_class.assessment_items
|
55
55
|
expect(refs.all? { |ref| File.extname(ref) == '.xml' })
|
56
56
|
end
|
57
57
|
end
|
@@ -72,4 +72,15 @@ describe Qti::V2::Models::AssessmentTest do
|
|
72
72
|
expect(assessment_test.title).to eq 'Test123'
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
describe '#create_stimulus' do
|
77
|
+
let(:path) { File.join(fixtures_path, 'test_qti_2.2', 'assessment.xml') }
|
78
|
+
let(:loaded_class) { described_class.from_path!(path) }
|
79
|
+
|
80
|
+
it 'creates a stimulus from a given file' do
|
81
|
+
stimulus_path = File.join(fixtures_path, 'no_assessment_XML', 'passages', '0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f.html')
|
82
|
+
stimulus = loaded_class.create_stimulus(stimulus_path)
|
83
|
+
expect(stimulus.title).to eq 'El equipo de hockey te necesita!'
|
84
|
+
end
|
85
|
+
end
|
75
86
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
fixtures_path = File.join('spec', 'fixtures')
|
4
|
+
|
5
|
+
describe Qti::V2::Models::NonAssessmentTest do
|
6
|
+
let(:path) { File.join(fixtures_path, 'no_assessment_XML', 'imsmanifest.xml') }
|
7
|
+
let(:loaded_class) { described_class.from_path!(path) }
|
8
|
+
|
9
|
+
it 'loads an AssessmentTest XML file' do
|
10
|
+
expect do
|
11
|
+
described_class.from_path!(path)
|
12
|
+
end.to_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#stimulus_ref' do
|
16
|
+
it 'should return the stimulus ref if it exists' do
|
17
|
+
item = loaded_class.assessment_items[1]
|
18
|
+
stimulus_ref = loaded_class.stimulus_ref(item)
|
19
|
+
expect(stimulus_ref).to eq File.join(File.dirname(path), "passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f.html")
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should return nil if no stimulus ref' do
|
23
|
+
item = loaded_class.assessment_items[0]
|
24
|
+
stimulus_ref = loaded_class.stimulus_ref(item)
|
25
|
+
expect(stimulus_ref).to be_nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Qti::V2::Models::StimulusItem do
|
4
|
+
let(:file_path) { File.join('spec', 'fixtures', 'no_assessment_XML', 'imsmanifest.xml') }
|
5
|
+
let(:test_object) { Qti::V2::Models::NonAssessmentTest.from_path!(file_path) }
|
6
|
+
let(:stimulus_ref) { test_object.stimulus_ref(test_object.assessment_items[1]) }
|
7
|
+
let(:loaded_class) { described_class.from_path!(stimulus_ref) }
|
8
|
+
|
9
|
+
it 'loads a stimulus ref' do
|
10
|
+
expect do
|
11
|
+
described_class.from_path!(stimulus_ref)
|
12
|
+
end.to_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has the title' do
|
16
|
+
expect(loaded_class.title).to eq 'El equipo de hockey te necesita!'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has sanitized item_body' do
|
20
|
+
expect(loaded_class.body).to include '<div'
|
21
|
+
expect(loaded_class.body).to include 'Listen to the audio passage.'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'has the identifier used to identify it in manifest file' do
|
25
|
+
expect(loaded_class.identifier).to eq '0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f'
|
26
|
+
end
|
27
|
+
end
|
data/spec/lib/qti_spec.rb
CHANGED
@@ -15,31 +15,32 @@ describe Qti::Importer do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
it 'raises an error' do
|
20
|
-
|
21
|
-
expect {
|
18
|
+
context 'unsupported QTI version' do
|
19
|
+
it 'raises an error if the QTI file doesn\'t match expected' do
|
20
|
+
file_path = File.join(fixtures_path, 'items_2.1')
|
21
|
+
expect { Qti::Importer.new(file_path) }.to raise_error('Unsupported QTI version')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'raises an error if there is no imsmanifest' do
|
25
|
+
file_path = File.join(fixtures_path, 'items_1.2')
|
26
|
+
expect { Qti::Importer.new(file_path) }.to raise_error('Manifest not found')
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
25
30
|
context 'QTI 1.2' do
|
26
31
|
let(:file_path) { File.join(fixtures_path, 'test_qti_1.2') }
|
27
|
-
let(:assessment_model) { Qti::V1::Models::Assessment }
|
28
32
|
|
29
33
|
include_examples 'initialize'
|
30
|
-
include_examples 'unsupported QTI version'
|
31
34
|
|
32
35
|
describe '#create_assessment_item' do
|
33
36
|
it 'create items with correct scoring structs' do
|
34
|
-
importer.
|
35
|
-
assessment_items = importer.assessment_item_refs.map { |ref| importer.create_assessment_item(ref) }
|
37
|
+
assessment_items = importer.assessment_item_refs.map { |item| importer.create_assessment_item(item) }
|
36
38
|
expect(assessment_items.count).to eq 5
|
37
39
|
answer_arity = assessment_items.map { |item| item.scoring_data_structs.count }
|
38
40
|
expect(answer_arity).to eq [1, 1, 4, 1, 1]
|
39
41
|
end
|
40
42
|
|
41
43
|
it 'sets the path and package root properly' do
|
42
|
-
importer.test_object
|
43
44
|
item = importer.create_assessment_item(importer.assessment_item_refs.first)
|
44
45
|
expect(item.path).to eq file_path + '/quiz.xml'
|
45
46
|
expect(item.package_root).to eq file_path + '/'
|
@@ -50,7 +51,6 @@ describe Qti::Importer do
|
|
50
51
|
let(:file_path) { File.join(fixtures_path, 'test_qti_1.2_canvas') }
|
51
52
|
|
52
53
|
it 'imports a canvas generated quiz' do
|
53
|
-
importer.test_object
|
54
54
|
expect(importer.assessment_item_refs.count).to eq 4
|
55
55
|
end
|
56
56
|
end
|
@@ -58,14 +58,11 @@ describe Qti::Importer do
|
|
58
58
|
|
59
59
|
context 'QTI 2.1' do
|
60
60
|
let(:file_path) { File.join(fixtures_path, 'test_qti_2.2') }
|
61
|
-
let(:assessment_model) { Qti::V1::Models::AssessmentTest }
|
62
61
|
|
63
62
|
include_examples 'initialize'
|
64
|
-
include_examples 'unsupported QTI version'
|
65
63
|
|
66
64
|
describe '#create_assessment_item' do
|
67
65
|
it 'sets the path and package root properly' do
|
68
|
-
importer.test_object
|
69
66
|
ref = importer.assessment_item_refs.first
|
70
67
|
item = importer.create_assessment_item(ref)
|
71
68
|
expect(item.path).to eq ref
|
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.
|
4
|
+
version: 0.8.0
|
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-08-
|
12
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -246,7 +246,9 @@ files:
|
|
246
246
|
- lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb
|
247
247
|
- lib/qti/v2/models/interactions/ordering_interaction.rb
|
248
248
|
- lib/qti/v2/models/interactions/short_text_interaction.rb
|
249
|
+
- lib/qti/v2/models/non_assessment_test.rb
|
249
250
|
- lib/qti/v2/models/scoring_data.rb
|
251
|
+
- lib/qti/v2/models/stimulus_item.rb
|
250
252
|
- spec/fixtures/items_1.2/choice.xml
|
251
253
|
- spec/fixtures/items_1.2/essay.xml
|
252
254
|
- spec/fixtures/items_1.2/fib.xml
|
@@ -349,6 +351,21 @@ files:
|
|
349
351
|
- spec/fixtures/items_2.1/text_entry.xml
|
350
352
|
- spec/fixtures/items_2.1/upload.xml
|
351
353
|
- spec/fixtures/items_2.1/upload_composite.xml
|
354
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832.html
|
355
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832.xml
|
356
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_A.html
|
357
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_B.html
|
358
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_C.html
|
359
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_D.html
|
360
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078.html
|
361
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078.xml
|
362
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_A.html
|
363
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_B.html
|
364
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_C.html
|
365
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_D.html
|
366
|
+
- spec/fixtures/no_assessment_XML/imsmanifest.xml
|
367
|
+
- spec/fixtures/no_assessment_XML/passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f.html
|
368
|
+
- spec/fixtures/no_assessment_XML/passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f_instructions.html
|
352
369
|
- spec/fixtures/test_qti_1.2.zip
|
353
370
|
- spec/fixtures/test_qti_1.2/contact info.png
|
354
371
|
- spec/fixtures/test_qti_1.2/exam1/my_files/org0/images/image.png
|
@@ -466,6 +483,8 @@ files:
|
|
466
483
|
- spec/lib/qti/v2/models/interactions/match_interaction_spec.rb
|
467
484
|
- spec/lib/qti/v2/models/interactions/ordering_interaction_spec.rb
|
468
485
|
- spec/lib/qti/v2/models/interactions/short_text_interaction_spec.rb
|
486
|
+
- spec/lib/qti/v2/models/non_assessment_test_spec.rb
|
487
|
+
- spec/lib/qti/v2/models/stimulus_item_spec.rb
|
469
488
|
- spec/lib/qti_spec.rb
|
470
489
|
- spec/spec_helper.rb
|
471
490
|
- spec/support/custom_matchers.rb
|
@@ -595,6 +614,21 @@ test_files:
|
|
595
614
|
- spec/fixtures/items_2.1/text_entry.xml
|
596
615
|
- spec/fixtures/items_2.1/upload.xml
|
597
616
|
- spec/fixtures/items_2.1/upload_composite.xml
|
617
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832.html
|
618
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832.xml
|
619
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_A.html
|
620
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_B.html
|
621
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_C.html
|
622
|
+
- spec/fixtures/no_assessment_XML/1c7db4f7-e933-4296-8979-963480422832_choice_D.html
|
623
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078.html
|
624
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078.xml
|
625
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_A.html
|
626
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_B.html
|
627
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_C.html
|
628
|
+
- spec/fixtures/no_assessment_XML/a4f3621a-195c-4847-a72c-69388250a078_choice_D.html
|
629
|
+
- spec/fixtures/no_assessment_XML/imsmanifest.xml
|
630
|
+
- spec/fixtures/no_assessment_XML/passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f.html
|
631
|
+
- spec/fixtures/no_assessment_XML/passages/0cfd5cf7-2c91-4b35-a57a-9f5d1709f68f_instructions.html
|
598
632
|
- spec/fixtures/test_qti_1.2.zip
|
599
633
|
- spec/fixtures/test_qti_1.2/contact info.png
|
600
634
|
- spec/fixtures/test_qti_1.2/exam1/my_files/org0/images/image.png
|
@@ -712,6 +746,8 @@ test_files:
|
|
712
746
|
- spec/lib/qti/v2/models/interactions/match_interaction_spec.rb
|
713
747
|
- spec/lib/qti/v2/models/interactions/ordering_interaction_spec.rb
|
714
748
|
- spec/lib/qti/v2/models/interactions/short_text_interaction_spec.rb
|
749
|
+
- spec/lib/qti/v2/models/non_assessment_test_spec.rb
|
750
|
+
- spec/lib/qti/v2/models/stimulus_item_spec.rb
|
715
751
|
- spec/lib/qti_spec.rb
|
716
752
|
- spec/spec_helper.rb
|
717
753
|
- spec/support/custom_matchers.rb
|