qti 0.2.8 → 0.2.9

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
  SHA1:
3
- metadata.gz: f1ffa157da2eff8844d6cf3754586d6af2876202
4
- data.tar.gz: 967bfb19798aacaf580c92e929e9d543df996410
3
+ metadata.gz: f8b9abebcb7232e927515c0894e9edbd8d2bf2a7
4
+ data.tar.gz: 50f4b9e76ebdb5a32decf0abcb14cf0c753b0d37
5
5
  SHA512:
6
- metadata.gz: e38d08c2972bfc2b8372ad49a7d13ffe8617d919332e18d36d9ca4bb63919c6c70ab6262cfbdb0eca16cc07f8ce463994bda687203a9cc129414824d30fb99d6
7
- data.tar.gz: bdb891a76128ca772666858a6dccddb52e0c388816c00bb107450d02eca23fb9234eb90b183355e975f44320e882392b778fb149412bed72358df21096e8c5c2
6
+ metadata.gz: bb4ca859a429202fc4817201d41556db3c6302175b5a09ae31a3dac8bcc77af4b18472281b7b6dbce6735ec8898d74436d1f38c445553e614e72901ec3f0eb6d
7
+ data.tar.gz: 15f96e0ecab7bf5904e532d01f2858438dced5564d85a9333c53f9fed34a9c0145a98df52907a23ee6109220d35b683322bd84b0e93e4f2c807115392734349b
@@ -9,16 +9,12 @@ module Qti
9
9
  end
10
10
 
11
11
  def qti_1_href
12
- xpath_with_single_check(
13
- "//xmlns:resources/xmlns:resource[@type='imsqti_xmlv1p1']/@href"
14
- )&.content
12
+ xpath_with_single_check("//xmlns:resources/xmlns:resource[@type='imsqti_xmlv1p1']/@href")&.content
15
13
  end
16
14
 
17
15
  def qti_2_x_href
18
- xpath_with_single_check(
19
- "//xmlns:resources/xmlns:resource[@type='imsqti_test_xmlv2p1'
20
- or @type='imsqti_test_xmlv2p2']/@href"
21
- )&.content
16
+ xpath_with_single_check("//xmlns:resources/xmlns:resource[@type='imsqti_test_xmlv2p1']/@href")&.content ||
17
+ xpath_with_single_check("//xmlns:resources/xmlns:resource[@type='imsqti_test_xmlv2p2']/@href")&.content
22
18
  end
23
19
  end
24
20
  end
@@ -5,6 +5,8 @@ module Qti
5
5
  module V1
6
6
  module Models
7
7
  class AssessmentItem < Qti::V1::Models::Base
8
+ attr_reader :doc
9
+
8
10
  ScoringData = Struct.new(:values, :rcardinality)
9
11
 
10
12
  def initialize(item)
@@ -14,7 +16,8 @@ module Qti
14
16
  def item_body
15
17
  @item_body ||= begin
16
18
  node = @doc.dup
17
- prompt = node.at_xpath('./presentation/material/mattext').content
19
+ presentation = node.at_xpath('./presentation')
20
+ prompt = presentation.at_xpath('//material/mattext').content
18
21
  sanitize_content!(prompt)
19
22
  end
20
23
  end
@@ -44,18 +47,27 @@ module Qti
44
47
  end
45
48
 
46
49
  def scoring_data_structs
47
- @scoring_data_structs ||= begin
48
- rcardinality = @doc.at_xpath('//response_lid/@rcardinality').value
49
-
50
- choice_nodes = @doc.xpath('.//respcondition')
51
- value_nodes = []
52
- # We need to find an action of Set or Add greater than 0 bc there is no correct answer tag
53
- choice_nodes.each do |choice_node|
54
- value_nodes << choice_node if choice_node.at_xpath('.//setvar').content.to_f.positive?
50
+ @scoring_data_structs ||=
51
+ if ordering?
52
+ scoring_data_structs_for_ordering
53
+ else
54
+ choice_nodes = doc.xpath('//respcondition')
55
+ choice_nodes.select { |choice_node| choice_node.at_xpath('.//setvar').content.to_f.positive? }
56
+ .map { |value_node| ScoringData.new(value_node.at_xpath('//varequal').content, rcardinality) }
55
57
  end
56
- value_nodes.map { |value_node| ScoringData.new(value_node.at_xpath('//varequal').content, rcardinality) }
58
+ end
59
+
60
+ private
61
+
62
+ def scoring_data_structs_for_ordering
63
+ @doc.xpath('//conditionvar/varequal').map do |value_node|
64
+ ScoringData.new(value_node.content, rcardinality)
57
65
  end
58
66
  end
67
+
68
+ def ordering?
69
+ rcardinality == 'Ordered'
70
+ end
59
71
  end
60
72
  end
61
73
  end
@@ -3,14 +3,11 @@ module Qti
3
3
  module Models
4
4
  module Interactions
5
5
  class LogicalIdentifierInteraction < Qti::V1::Models::Base
6
- @node_name = 'response_lid'.freeze
7
6
  # This will know if a class matches
8
7
  def self.matches(node)
9
- matches = node.children.children.select { |n| n.name == @node_name }
10
- return false if matches.empty?
11
-
12
- raise Qti::UnsupportedSchema if matches.size > 1
13
- new(matches.first)
8
+ match = node.at_xpath('//response_lid')
9
+ return false unless match.present?
10
+ new(match)
14
11
  end
15
12
 
16
13
  def initialize(node)
@@ -0,0 +1,85 @@
1
+ <?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>
2
+ <!DOCTYPE questestinterop SYSTEM "ims_qtiasiv1p2.dtd" [
3
+ <!-- This is an IMS test extension for OBJECT rendering. -->
4
+ <!ELEMENT ims_render_object (flow_label+)>
5
+ <!ATTLIST ims_render_object
6
+ shuffle (Yes|No) 'No'
7
+ orientation (Row|Column) #REQUIRED >
8
+ ]>
9
+
10
+ <!-- Author: Colin Smythe -->
11
+
12
+ <!-- Date: 22nd January, 2002 -->
13
+
14
+ <!-- Version 1.2 Compliant Example: BasicExample009b -->
15
+
16
+ <!-- Basic Example with response processing. -->
17
+ <questestinterop>
18
+ <qticomment>This is a standard ordering of a list of words. Ordered response processing is demonstrated.</qticomment>
19
+ <item title = "Standard Object Ordering of text Item" ident = "IMS_V01_I_BasicExample009b">
20
+ <presentation label = "BasicExample009b">
21
+ <flow>
22
+ <material>
23
+ <mattext>What is the correct order for the days of the week ?</mattext>
24
+ </material>
25
+ <response_lid ident = "OB01" rcardinality = "Ordered" rtiming = "No">
26
+ <render_extension>
27
+ <ims_render_object shuffle = "No" orientation = "Row">
28
+ <flow_label>
29
+ <response_label ident = "A">
30
+ <material>
31
+ <mattext>Monday</mattext>
32
+ </material>
33
+ </response_label>
34
+ <response_label ident = "B">
35
+ <material>
36
+ <mattext>Tuesday</mattext>
37
+ </material>
38
+ </response_label>
39
+ <response_label ident = "C">
40
+ <material>
41
+ <mattext>Friday</mattext>
42
+ </material>
43
+ </response_label>
44
+ <response_label ident = "D">
45
+ <material>
46
+ <mattext>Thursday</mattext>
47
+ </material>
48
+ </response_label>
49
+ <response_label ident = "E">
50
+ <material>
51
+ <mattext>Wednesday</mattext>
52
+ </material>
53
+ </response_label>
54
+ </flow_label>
55
+ </ims_render_object>
56
+ </render_extension>
57
+ </response_lid>
58
+ </flow>
59
+ </presentation>
60
+ <resprocessing>
61
+ <outcomes>
62
+ <decvar varname = "ORDERSCORE" vartype = "Integer" defaultval = "1"/>
63
+ </outcomes>
64
+ <respcondition>
65
+ <qticomment>Scoring for the correct answer where the order is important.</qticomment>
66
+ <conditionvar>
67
+ <varequal respident = "OB01">A</varequal>
68
+ <varequal respident = "OB01">B</varequal>
69
+ <varequal respident = "OB01">E</varequal>
70
+ <varequal respident = "OB01">D</varequal>
71
+ <varequal respident = "OB01">C</varequal>
72
+ </conditionvar>
73
+ <setvar action = "Add" varname = "SCORE1"> 5 </setvar>
74
+ <displayfeedback feedbacktype = "Response" linkrefid = "Correct"/>
75
+ </respcondition>
76
+ </resprocessing>
77
+ <itemfeedback ident = "Correct" view = "Candidate">
78
+ <flow_mat>
79
+ <material>
80
+ <mattext>Yes, the correct order.</mattext>
81
+ </material>
82
+ </flow_mat>
83
+ </itemfeedback>
84
+ </item>
85
+ </questestinterop>
@@ -26,10 +26,20 @@ describe Qti::V1::Models::AssessmentItem do
26
26
  expect(loaded_class.points_possible).to eq '0'
27
27
  end
28
28
 
29
- it 'grabs the rcardinality and scoring data value' do
30
- struct = loaded_class.send(:scoring_data_structs)
31
- expect(struct.first.values).to eq 'QUE_1005_A1'
32
- expect(struct.first.rcardinality).to eq 'Single'
29
+ describe '#scoring_data_structs' do
30
+ it 'grabs the rcardinality and scoring data value' do
31
+ struct = loaded_class.send(:scoring_data_structs)
32
+ expect(struct.first.values).to eq 'QUE_1005_A1'
33
+ expect(struct.first.rcardinality).to eq 'Single'
34
+ end
35
+
36
+ it 'grabs scoring data value for ordering questions' do
37
+ doc = Nokogiri.XML(File.read('spec/fixtures/items_1.2/ordering.xml'), &:noblanks)
38
+ item = doc.at_xpath('//item')
39
+
40
+ assessment_item = described_class.new(item)
41
+ expect(assessment_item.scoring_data_structs.count).to eq 5
42
+ end
33
43
  end
34
44
 
35
45
  it 'has the identifier used to identify it in manifest/test files' 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: 0.2.8
4
+ version: 0.2.9
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-03-16 00:00:00.000000000 Z
12
+ date: 2017-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -218,6 +218,7 @@ files:
218
218
  - lib/qti/v2/models/interactions/extended_text_interaction.rb
219
219
  - spec/fixtures/items_1.2/multiple_answer.xml
220
220
  - spec/fixtures/items_1.2/multiple_choice.xml
221
+ - spec/fixtures/items_1.2/ordering.xml
221
222
  - spec/fixtures/items_1.2/true_false.xml
222
223
  - spec/fixtures/items_2.1/Example01-modalFeedback.xml
223
224
  - spec/fixtures/items_2.1/Example02-feedbackInline.xml
@@ -435,6 +436,7 @@ summary: QTI 1.2 and 2.1 import and export models
435
436
  test_files:
436
437
  - spec/fixtures/items_1.2/multiple_answer.xml
437
438
  - spec/fixtures/items_1.2/multiple_choice.xml
439
+ - spec/fixtures/items_1.2/ordering.xml
438
440
  - spec/fixtures/items_1.2/true_false.xml
439
441
  - spec/fixtures/items_2.1/Example01-modalFeedback.xml
440
442
  - spec/fixtures/items_2.1/Example02-feedbackInline.xml