qti 0.7.4 → 0.7.5

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
  SHA1:
3
- metadata.gz: deda071ecd40bdcf24677df2f9cdbeda08122011
4
- data.tar.gz: 2c85623e45851776e8297faff563d0c0e34bb794
3
+ metadata.gz: 63fa9b2b81047aaee938481bce68da3d899eb32d
4
+ data.tar.gz: 831b6f6b6c000a64b416e61b26076b13a93e02bf
5
5
  SHA512:
6
- metadata.gz: 661ed1cf8ca710215e862e2d208229cc8f84cfaf2992ddfa24eb9e8f70f33386089e148a937b0d50497550710c1020f17f75f0084158d90507fd900f3555c332
7
- data.tar.gz: e67a91a599e8c5b2cd86cbfe66151bf74261d7bc0d5fc1f76d6b34363d4acea09178c4ac7b3e703085bb6c2667b8d24fe7d6897a7c75f6d8d35963a02ec560a9
6
+ metadata.gz: a019845b24220624a376864611519e20e1a814b042dda11c9807962d8d517c30beaaa62022745ebffbdbf718125d1c0f286a8d597716d9341fa0cd50410708d4
7
+ data.tar.gz: 5461bcbc16d58ed31b7e88211b286e6b709696cd5b22b74a84541a9e9c299d3916580eb0d6ac84a78d24d4d820219297cdf0475d15e80cd08c7afeebbb7d9fdf
@@ -28,9 +28,27 @@ module Qti
28
28
  @title ||= @doc.attribute('title').value
29
29
  end
30
30
 
31
+ def qti_metadata_children
32
+ @doc.at_xpath('.//xmlns:qtimetadata')&.children
33
+ end
34
+
35
+ def has_points_possible_qti_metadata?
36
+ if @doc.at_xpath('.//xmlns:qtimetadata').present?
37
+ points_possible_label = qti_metadata_children.children.find {|node| node.text == "points_possible"}
38
+ points_possible_label.present?
39
+ else
40
+ false
41
+ end
42
+ end
43
+
31
44
  def points_possible
32
45
  @points_possible ||= begin
33
- @doc.at_xpath('.//xmlns:decvar/@maxvalue')&.value || @doc.at_xpath('.//xmlns:decvar/@defaultval')&.value
46
+ if has_points_possible_qti_metadata?
47
+ points_possible_label = qti_metadata_children.children.find {|node| node.text == "points_possible"}
48
+ points_possible_node = points_possible_label.next.text
49
+ else
50
+ @doc.at_xpath('.//xmlns:decvar/@maxvalue')&.value || @doc.at_xpath('.//xmlns:decvar/@defaultval')&.value
51
+ end
34
52
  end
35
53
  end
36
54
 
@@ -62,5 +62,9 @@ describe Qti::V1::Models::AssessmentItem do
62
62
  expect(struct.map(&:values)).to eq ["4155", "6991", "1939"]
63
63
  end
64
64
  end
65
+
66
+ it 'sets the points possible from qtimetadata' do
67
+ expect(loaded_class.points_possible).to eq '1.0'
68
+ end
65
69
  end
66
70
  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: 0.7.4
4
+ version: 0.7.5
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-06-30 00:00:00.000000000 Z
12
+ date: 2017-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport