canvas_cc 0.0.12 → 0.0.13
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/canvas_cc/canvas_cc/models/numerical_question.rb +2 -2
- data/lib/canvas_cc/canvas_cc/models/range.rb +6 -0
- data/lib/canvas_cc/canvas_cc/numerical_question_writer.rb +15 -7
- data/lib/canvas_cc/version.rb +1 -1
- data/lib/canvas_cc.rb +1 -0
- data/spec/moodle2cc/canvas_cc/numerical_question_writer_spec.rb +46 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 215d68e5bdbefbaab28a329496b73f6fe167d422
|
|
4
|
+
data.tar.gz: 76ab2243a6cdf4314a364cd1140319b0503f98aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe36f46276607099db48ce0b18715237f4c16adc34e9dd86f3bde2beaa2432968aed60be54faf19adeb18050d09e7bc589c85b673508c0ab4c4b4fe0a6a2f1bb
|
|
7
|
+
data.tar.gz: d898cb94005cf56feeaa1074e3d8d4e660197e84d134232443bc343c56da8a9cb9b7801db8f609752579f0b99fcaebd5a8e36211ce33c8378fe0f6c63143eddc
|
data/Gemfile.lock
CHANGED
|
@@ -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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
data/lib/canvas_cc/version.rb
CHANGED
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.
|
|
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
|
+
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
|