canvas_cc 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/canvas_cc/canvas_cc/matching_question_writer.rb +30 -1
- data/lib/canvas_cc/canvas_cc/models/matching_question.rb +2 -2
- data/lib/canvas_cc/version.rb +1 -1
- data/spec/moodle2cc/canvas_cc/matching_question_writer_spec.rb +17 -3
- data/spec/moodle2cc/canvas_cc/multiple_answers_question_writer_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7080470c3965daa5b415a043fbcd609737efed7
|
4
|
+
data.tar.gz: b327a4abf7c6915f5d3c3c8b694a4d4bf8044102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a406d76c71573444ad107ffec8f56f3e18ff58aa54d08775f94233b207132d2448cad1881d916c5da9eeda9e446df47d43ebf933c670223cb597f3a832ea6a8
|
7
|
+
data.tar.gz: 07d4d35fd462129363d1f0e67c2c0b0771e1ae483b6c041fa070dd87d6f1289975f22e2609b870bf3f137df79d93165ed1cbe3fc50414dbc4df069d13524c0cc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
canvas_cc (0.0.
|
4
|
+
canvas_cc (0.0.8)
|
5
5
|
builder
|
6
6
|
happymapper
|
7
7
|
nokogiri
|
@@ -49,10 +49,10 @@ GEM
|
|
49
49
|
rb-inotify (>= 0.9)
|
50
50
|
lumberjack (1.0.9)
|
51
51
|
method_source (0.8.2)
|
52
|
-
mini_portile (0.6.
|
52
|
+
mini_portile (0.6.1)
|
53
53
|
minitest (5.4.1)
|
54
|
-
nokogiri (1.6.
|
55
|
-
mini_portile (
|
54
|
+
nokogiri (1.6.4.1)
|
55
|
+
mini_portile (~> 0.6.0)
|
56
56
|
pry (0.10.1)
|
57
57
|
coderay (~> 1.1.0)
|
58
58
|
method_source (~> 0.8.1)
|
@@ -19,6 +19,15 @@ module CanvasCc::CanvasCC
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
next unless question.distractors
|
24
|
+
question.distractors.each do |distractor|
|
25
|
+
choice_node.response_label(:ident => Digest::MD5.hexdigest(distractor)) do |label_node|
|
26
|
+
label_node.material do |material_node|
|
27
|
+
material_node.mattext(distractor, :texttype => 'text/plain')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
@@ -34,10 +43,30 @@ module CanvasCc::CanvasCC
|
|
34
43
|
end
|
35
44
|
condition_node.setvar "%.2f" % score, :varname => 'SCORE', :action => 'Add'
|
36
45
|
end
|
46
|
+
|
47
|
+
next unless match.has_key?(:answer_feedback) && match[:answer_feedback].length > 0
|
48
|
+
processing_node.respcondition do |condition_node|
|
49
|
+
condition_node.conditionvar do |var_node|
|
50
|
+
var_node.not do |not_node|
|
51
|
+
not_node.varequal match[:id], :respident => "response_#{match[:id]}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
condition_node.displayfeedback :linkrefid => "#{match[:id]}_fb", :feedbacktype => 'Response'
|
55
|
+
end
|
37
56
|
end
|
38
57
|
end
|
39
58
|
|
40
59
|
def self.write_additional_nodes(item_node, question)
|
60
|
+
question.matches.each do |match|
|
61
|
+
next unless match.has_key?(:answer_feedback) && match[:answer_feedback].length > 0
|
62
|
+
item_node.itemfeedback(:ident => "#{match[:id]}_fb") do |feedback_node|
|
63
|
+
feedback_node.flow_mat do |flow_node|
|
64
|
+
flow_node.material do |material_node|
|
65
|
+
material_node.mattext match[:answer_feedback], :texttype => 'text/plain'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
41
70
|
end
|
42
71
|
end
|
43
|
-
end
|
72
|
+
end
|
data/lib/canvas_cc/version.rb
CHANGED
@@ -10,9 +10,10 @@ module CanvasCc::CanvasCC
|
|
10
10
|
question.title = 'its over nine thousannnd'
|
11
11
|
question.general_feedback = 'ur totes awesome'
|
12
12
|
question.material = 'this is a question, or is it?'
|
13
|
+
question.distractors = %w(distractor1 distractor2)
|
13
14
|
|
14
|
-
match1 = {:id => '1', :question_text => 'qtext', :question_text_format => '1', :answer_text => 'answer1'}
|
15
|
-
match2 = {:id => '2', :question_text => 'qtext2', :question_text_format => '1', :answer_text => 'answer2'}
|
15
|
+
match1 = {:id => '1', :question_text => 'qtext', :question_text_format => '1', :answer_text => 'answer1', :answer_feedback => 'good'}
|
16
|
+
match2 = {:id => '2', :question_text => 'qtext2', :question_text_format => '1', :answer_text => 'answer2', :answer_feedback => 'bad'}
|
16
17
|
question.matches = [match1, match2]
|
17
18
|
|
18
19
|
xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |node|
|
@@ -27,11 +28,15 @@ module CanvasCc::CanvasCC
|
|
27
28
|
expect(response.at_xpath('material/mattext[@texttype="text/plain"]').text).to eq match1[:question_text]
|
28
29
|
expect(response.at_xpath("render_choice/response_label[@ident=\"#{match1[:id]}\"]/material/mattext").text).to eq match1[:answer_text]
|
29
30
|
expect(response.at_xpath("render_choice/response_label[@ident=\"#{match2[:id]}\"]/material/mattext").text).to eq match2[:answer_text]
|
31
|
+
expect(response.at_xpath("render_choice/response_label[@ident=\"#{Digest::MD5.hexdigest(question.distractors[0])}\"]/material/mattext").text).to eq question.distractors[0]
|
32
|
+
expect(response.at_xpath("render_choice/response_label[@ident=\"#{Digest::MD5.hexdigest(question.distractors[1])}\"]/material/mattext").text).to eq question.distractors[1]
|
30
33
|
|
31
34
|
response = xml.at_xpath("item/presentation/response_lid[@ident=\"response_#{match2[:id]}\"]")
|
32
35
|
expect(response.at_xpath('material/mattext[@texttype="text/plain"]').text).to eq match2[:question_text]
|
33
36
|
expect(response.at_xpath("render_choice/response_label[@ident=\"#{match1[:id]}\"]/material/mattext").text).to eq match1[:answer_text]
|
34
37
|
expect(response.at_xpath("render_choice/response_label[@ident=\"#{match2[:id]}\"]/material/mattext").text).to eq match2[:answer_text]
|
38
|
+
expect(response.at_xpath("render_choice/response_label[@ident=\"#{Digest::MD5.hexdigest(question.distractors[0])}\"]/material/mattext").text).to eq question.distractors[0]
|
39
|
+
expect(response.at_xpath("render_choice/response_label[@ident=\"#{Digest::MD5.hexdigest(question.distractors[1])}\"]/material/mattext").text).to eq question.distractors[1]
|
35
40
|
|
36
41
|
condition = xml.at_xpath("item/resprocessing/respcondition/conditionvar[varequal=\"#{match1[:id]}\"]/..")
|
37
42
|
expect(condition.at_xpath("conditionvar/varequal[@respident=\"response_#{match1[:id]}\"]")).not_to be_nil
|
@@ -40,12 +45,21 @@ module CanvasCc::CanvasCC
|
|
40
45
|
expect(set_var.attributes['action'].value).to eq 'Add'
|
41
46
|
expect(set_var.text).to eq '50.00'
|
42
47
|
|
48
|
+
condition = xml.at_xpath("item/resprocessing/respcondition/conditionvar/not[varequal=\"#{match1[:id]}\"]/..")
|
49
|
+
expect(condition.at_xpath("not/varequal[@respident=\"response_#{match1[:id]}\"]")).not_to be_nil
|
50
|
+
expect(condition.at_xpath("not/varequal[@respident=\"response_#{match1[:id]}\"]").text).to eq("1")
|
51
|
+
|
43
52
|
condition = xml.at_xpath("item/resprocessing/respcondition/conditionvar[varequal=\"#{match2[:id]}\"]/..")
|
44
53
|
expect(condition.at_xpath("conditionvar/varequal[@respident=\"response_#{match2[:id]}\"]")).not_to be_nil
|
45
54
|
set_var = condition.at_xpath('setvar')
|
46
55
|
expect(set_var.attributes['varname'].value).to eq 'SCORE'
|
47
56
|
expect(set_var.attributes['action'].value).to eq 'Add'
|
48
57
|
expect(set_var.text).to eq '50.00'
|
58
|
+
|
59
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{match1[:id]}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
60
|
+
expect(feedback.text).to eq match1[:answer_feedback]
|
61
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{match2[:id]}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
62
|
+
expect(feedback.text).to eq match2[:answer_feedback]
|
49
63
|
end
|
50
64
|
end
|
51
|
-
end
|
65
|
+
end
|
@@ -29,7 +29,7 @@ module CanvasCc::CanvasCC
|
|
29
29
|
xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |node|
|
30
30
|
QuestionWriter.write_question(node, question)
|
31
31
|
end.doc
|
32
|
-
|
32
|
+
debugger
|
33
33
|
expect(xml.at_xpath('item/@ident').value).to eq question.identifier.to_s
|
34
34
|
expect(xml.at_xpath('item/@title').value).to eq question.title
|
35
35
|
expect(xml.at_xpath("item/itemmetadata/qtimetadata/qtimetadatafield[fieldlabel=\"question_type\" and fieldentry=\"#{question.question_type}\"]")).to_not be_nil
|
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.8
|
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-
|
11
|
+
date: 2014-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|