canvas_cc 0.0.12 → 0.0.13

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: 634e631128ef78e7235bc84c81c835368dff8e54
4
- data.tar.gz: ed2995fa6f648444c01fcd947f76c3f4352ada7f
3
+ metadata.gz: 215d68e5bdbefbaab28a329496b73f6fe167d422
4
+ data.tar.gz: 76ab2243a6cdf4314a364cd1140319b0503f98aa
5
5
  SHA512:
6
- metadata.gz: 77fd48f7f6dbdd3140427b79104a31e70ceda37374394dbdebef95fdfde0a4adbce2c9deffd0c8fde0497e2a987c1fc7e298c6c52a1971c561ab61725ba3dc16
7
- data.tar.gz: 9e4b161dbdba73396a56afed3e4889cb4ddfcfe6b855a6fc519ff275951955ac1fcb47100b35856dd11f386c7f572e93692cae5d25421d3b527bcbfc2e9f9510
6
+ metadata.gz: fe36f46276607099db48ce0b18715237f4c16adc34e9dd86f3bde2beaa2432968aed60be54faf19adeb18050d09e7bc589c85b673508c0ab4c4b4fe0a6a2f1bb
7
+ data.tar.gz: d898cb94005cf56feeaa1074e3d8d4e660197e84d134232443bc343c56da8a9cb9b7801db8f609752579f0b99fcaebd5a8e36211ce33c8378fe0f6c63143eddc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- canvas_cc (0.0.12)
4
+ canvas_cc (0.0.13)
5
5
  builder
6
6
  happymapper
7
7
  nokogiri
@@ -2,6 +2,6 @@ module CanvasCc::CanvasCC::Models
2
2
  class NumericalQuestion < Question
3
3
  register_question_type 'numerical_question'
4
4
 
5
- attr_accessor :tolerances
5
+ attr_accessor :tolerances, :ranges
6
6
  end
7
- end
7
+ end
@@ -0,0 +1,6 @@
1
+ module CanvasCc::CanvasCC::Models
2
+ class Range
3
+ attr_accessor :low_range, :high_range
4
+
5
+ end
6
+ end
@@ -16,14 +16,22 @@ module CanvasCc::CanvasCC
16
16
  question.answers.each do |answer|
17
17
  tolerance = question.tolerances[answer.id]
18
18
  processing_node.respcondition(:continue => 'No') do |condition_node|
19
- condition_node.conditionvar do |var_node|
20
- var_node.or do |or_node|
21
- or_node.varequal answer.answer_text, :respident => 'response1'
22
- or_node.and do |and_node|
23
- and_node.vargte answer.answer_text.to_f - tolerance.to_f, :respident => 'response1'
24
- and_node.varlte answer.answer_text.to_f + tolerance.to_f, :respident => 'response1'
19
+ if answer.answer_text
20
+ condition_node.conditionvar do |var_node|
21
+ var_node.or do |or_node|
22
+ or_node.varequal answer.answer_text, :respident => 'response1'
23
+ or_node.and do |and_node|
24
+ and_node.vargte answer.answer_text.to_f - tolerance.to_f, :respident => 'response1'
25
+ and_node.varlte answer.answer_text.to_f + tolerance.to_f, :respident => 'response1'
26
+ end
25
27
  end
26
28
  end
29
+ elsif question.ranges.has_key?(answer.id)
30
+ range = question.ranges[answer.id]
31
+ condition_node.conditionvar do |var_node|
32
+ var_node.vargte range.low_range, :respident => 'response1'
33
+ var_node.varlte range.high_range, :respident => 'response1'
34
+ end
27
35
  end
28
36
  condition_node.setvar(convert_fraction_to_score(answer.fraction), :varname => "SCORE", :action => 'Set')
29
37
  if answer.feedback && answer.feedback.strip.length > 0
@@ -37,4 +45,4 @@ module CanvasCc::CanvasCC
37
45
  write_standard_answer_feedbacks(item_node, question)
38
46
  end
39
47
  end
40
- end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module CanvasCc
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
data/lib/canvas_cc.rb CHANGED
@@ -92,6 +92,7 @@ module CanvasCc
92
92
  autoload :Page, 'canvas_cc/canvas_cc/models/page'
93
93
  autoload :Discussion, 'canvas_cc/canvas_cc/models/discussion'
94
94
  autoload :WorkflowState, 'canvas_cc/canvas_cc/models/workflow_state'
95
+ autoload :Range, 'canvas_cc/canvas_cc/models/range'
95
96
  end
96
97
  end
97
98
  end
@@ -65,5 +65,50 @@ module CanvasCc::CanvasCC
65
65
  expect(setvar.attributes['varname'].value).to eq 'SCORE'
66
66
  expect(setvar.attributes['action'].value).to eq 'Set'
67
67
  end
68
+
69
+ it 'creates the range question item xml for a numerical question' do
70
+ question.identifier = 9001
71
+ question.title = 'its over nine thousannnd'
72
+ question.general_feedback = 'ur totes awesome'
73
+ question.material = 'this is a question, or is it?'
74
+ question.ranges = {}
75
+ question.tolerances = {}
76
+
77
+ answer1 = CanvasCc::CanvasCC::Models::Answer.new
78
+ answer1.id = 'answer1_id'
79
+ answer1.fraction = 1
80
+ answer1.feedback = 'feedbak1'
81
+ answer1_range = CanvasCc::CanvasCC::Models::Range.new
82
+ answer1_range.low_range = 1
83
+ answer1_range.high_range = 4
84
+ question.ranges[answer1.id] = answer1_range
85
+ question.answers = [answer1]
86
+
87
+ xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |node|
88
+ QuestionWriter.write_question(node, question)
89
+ end.doc
90
+ expect(xml.at_xpath('item/@ident').value).to eq question.identifier.to_s
91
+ expect(xml.at_xpath('item/@title').value).to eq question.title
92
+ expect(xml.at_xpath("item/itemmetadata/qtimetadata/qtimetadatafield[fieldlabel=\"question_type\" and fieldentry=\"#{question.question_type}\"]")).to_not be_nil
93
+
94
+ response = xml.at_xpath('item/presentation/response_str')
95
+ expect(response.attributes['rcardinality'].value).to eq 'Single'
96
+ expect(response.attributes['ident'].value).to eq 'response1'
97
+ expect(response.at_xpath('render_fib').attributes['fibtype'].value).to eq 'Decimal'
98
+ expect(response.at_xpath('render_fib/response_label').attributes['ident'].value).to eq 'answer1'
99
+
100
+ condition = xml.at_xpath("item/resprocessing/respcondition[@continue=\"No\"]/displayfeedback[@linkrefid=\"#{answer1.id}_fb\"]/..")
101
+ varequal = condition.at_xpath('conditionvar/or/varequal[@respident="response1"]')
102
+
103
+ vargte = condition.at_xpath('conditionvar/vargte[@respident="response1"]')
104
+ expect(vargte.text).to eq (answer1_range.low_range).to_s
105
+ varlte = condition.at_xpath('conditionvar/varlte[@respident="response1"]')
106
+ expect(varlte.text).to eq (answer1_range.high_range).to_s
107
+
108
+ setvar = condition.at_xpath('setvar')
109
+ expect(setvar.text).to eq '100'
110
+ expect(setvar.attributes['varname'].value).to eq 'SCORE'
111
+ expect(setvar.attributes['action'].value).to eq 'Set'
112
+ end
68
113
  end
69
- end
114
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_cc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -283,6 +283,7 @@ files:
283
283
  - lib/canvas_cc/canvas_cc/models/question.rb
284
284
  - lib/canvas_cc/canvas_cc/models/question_bank.rb
285
285
  - lib/canvas_cc/canvas_cc/models/question_group.rb
286
+ - lib/canvas_cc/canvas_cc/models/range.rb
286
287
  - lib/canvas_cc/canvas_cc/models/resource.rb
287
288
  - lib/canvas_cc/canvas_cc/models/web_content.rb
288
289
  - lib/canvas_cc/canvas_cc/models/web_link.rb