moodle2cc 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/moodle2cc.rb +2 -0
- data/lib/moodle2cc/canvas/assessment.rb +18 -3
- data/lib/moodle2cc/canvas/converter.rb +4 -2
- data/lib/moodle2cc/canvas/course.rb +2 -4
- data/lib/moodle2cc/canvas/question.rb +11 -8
- data/lib/moodle2cc/canvas/question_bank.rb +6 -3
- data/lib/moodle2cc/canvas/question_group.rb +35 -0
- data/lib/moodle2cc/cc/converter.rb +1 -1
- data/lib/moodle2cc/cc/question.rb +1 -1
- data/lib/moodle2cc/cc/wiki.rb +1 -1
- data/lib/moodle2cc/logger.rb +5 -1
- data/lib/moodle2cc/moodle/course.rb +5 -1
- data/lib/moodle2cc/moodle/question.rb +1 -0
- data/lib/moodle2cc/moodle/section.rb +25 -3
- data/lib/moodle2cc/resource_factory.rb +1 -1
- data/lib/moodle2cc/version.rb +1 -1
- data/moodle2cc.gemspec +1 -0
- data/test/fixtures/moodle_backup/moodle.xml +20 -12
- data/test/fixtures/moodle_backup_random_questions/course_files/folder/test.txt +1 -0
- data/test/fixtures/moodle_backup_random_questions/course_files/test.txt +1 -0
- data/test/fixtures/moodle_backup_random_questions/moodle.xml +357 -0
- data/test/test_helper.rb +7 -7
- data/test/unit/canvas/assessment_test.rb +43 -0
- data/test/unit/canvas/converter_test.rb +14 -2
- data/test/unit/canvas/course_test.rb +7 -7
- data/test/unit/canvas/question_bank_test.rb +19 -0
- data/test/unit/canvas/question_group_test.rb +90 -0
- data/test/unit/canvas/question_test.rb +37 -38
- data/test/unit/canvas/wiki_test.rb +1 -1
- data/test/unit/cc/converter_test.rb +15 -3
- data/test/unit/cc/question_test.rb +6 -1
- data/test/unit/cc/wiki_test.rb +1 -1
- data/test/unit/moodle/mod_test.rb +2 -2
- data/test/unit/moodle/question_test.rb +4 -0
- data/test/unit/moodle/section_test.rb +25 -8
- data/test/unit/resource_factory_test.rb +9 -0
- metadata +33 -10
data/test/test_helper.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
require 'zip/zipfilesystem'
|
2
2
|
|
3
3
|
module TestHelper
|
4
|
-
def create_moodle_backup_zip
|
5
|
-
moodle_backup_path = File.expand_path("../tmp
|
4
|
+
def create_moodle_backup_zip(backup_name='moodle_backup')
|
5
|
+
moodle_backup_path = File.expand_path("../tmp/#{backup_name}.zip", __FILE__)
|
6
6
|
Zip::ZipFile.open(moodle_backup_path, Zip::ZipFile::CREATE) do |zipfile|
|
7
|
-
zipfile.add("moodle.xml", File.expand_path("../fixtures/
|
7
|
+
zipfile.add("moodle.xml", File.expand_path("../fixtures/#{backup_name}/moodle.xml", __FILE__))
|
8
8
|
zipfile.mkdir("course_files")
|
9
9
|
zipfile.mkdir("course_files/folder")
|
10
|
-
zipfile.add("course_files/test.txt", File.expand_path("../fixtures/
|
11
|
-
zipfile.add("course_files/folder/test.txt", File.expand_path("../fixtures/
|
10
|
+
zipfile.add("course_files/test.txt", File.expand_path("../fixtures/#{backup_name}/course_files/test.txt", __FILE__))
|
11
|
+
zipfile.add("course_files/folder/test.txt", File.expand_path("../fixtures/#{backup_name}/course_files/folder/test.txt", __FILE__))
|
12
12
|
end
|
13
13
|
moodle_backup_path
|
14
14
|
end
|
15
15
|
|
16
|
-
def convert_moodle_backup(format='cc')
|
16
|
+
def convert_moodle_backup(format='cc', backup_name='moodle_backup')
|
17
17
|
raise "must be 'cc' or 'canvas'" unless ['cc', 'canvas'].include?(format)
|
18
18
|
converter_class = format == 'cc' ? Moodle2CC::CC::Converter : Moodle2CC::Canvas::Converter
|
19
|
-
@backup_path = create_moodle_backup_zip
|
19
|
+
@backup_path = create_moodle_backup_zip(backup_name)
|
20
20
|
@backup = Moodle2CC::Moodle::Backup.read @backup_path
|
21
21
|
@export_dir = File.expand_path("../tmp", __FILE__)
|
22
22
|
@converter = converter_class.new @backup, @export_dir
|
@@ -122,6 +122,49 @@ class TestUnitCanvasAssessment < MiniTest::Unit::TestCase
|
|
122
122
|
assert_equal 'survey', assessment.quiz_type
|
123
123
|
end
|
124
124
|
|
125
|
+
def test_it_converts_questions
|
126
|
+
assessment = Moodle2CC::Canvas::Assessment.new @mod
|
127
|
+
assert_equal 5, assessment.questions.length
|
128
|
+
assert_kind_of Moodle2CC::Canvas::Question, assessment.questions[0]
|
129
|
+
assert_kind_of Moodle2CC::Canvas::Question, assessment.questions[1]
|
130
|
+
assert_kind_of Moodle2CC::Canvas::Question, assessment.questions[2]
|
131
|
+
assert_kind_of Moodle2CC::Canvas::Question, assessment.questions[3]
|
132
|
+
assert_kind_of Moodle2CC::Canvas::Question, assessment.questions[4]
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_it_converts_question_groups
|
136
|
+
convert_moodle_backup('canvas', 'moodle_backup_random_questions')
|
137
|
+
mod = @backup.course.mods.find { |m| m.mod_type == "quiz" }
|
138
|
+
assessment = Moodle2CC::Canvas::Assessment.new mod
|
139
|
+
|
140
|
+
assert_equal 5, assessment.questions.length
|
141
|
+
assert_kind_of Moodle2CC::Canvas::QuestionGroup, assessment.questions[0]
|
142
|
+
assert_kind_of Moodle2CC::Canvas::QuestionGroup, assessment.questions[1]
|
143
|
+
assert_kind_of Moodle2CC::Canvas::Question, assessment.questions[2]
|
144
|
+
assert_kind_of Moodle2CC::Canvas::QuestionGroup, assessment.questions[3]
|
145
|
+
assert_kind_of Moodle2CC::Canvas::QuestionGroup, assessment.questions[4]
|
146
|
+
|
147
|
+
assert_equal 1, assessment.questions[0].id
|
148
|
+
assert_equal 'Group 1', assessment.questions[0].title
|
149
|
+
assert_equal 2, assessment.questions[0].selection_number
|
150
|
+
assert_equal 1, assessment.questions[0].points_per_item
|
151
|
+
|
152
|
+
assert_equal 2, assessment.questions[1].id
|
153
|
+
assert_equal 'Group 2', assessment.questions[1].title
|
154
|
+
assert_equal 1, assessment.questions[1].selection_number
|
155
|
+
assert_equal 2, assessment.questions[1].points_per_item
|
156
|
+
|
157
|
+
assert_equal 3, assessment.questions[3].id
|
158
|
+
assert_equal 'Group 3', assessment.questions[3].title
|
159
|
+
assert_equal 1, assessment.questions[3].selection_number
|
160
|
+
assert_equal 1, assessment.questions[3].points_per_item
|
161
|
+
|
162
|
+
assert_equal 4, assessment.questions[4].id
|
163
|
+
assert_equal 'Group 4', assessment.questions[4].title
|
164
|
+
assert_equal 1, assessment.questions[4].selection_number
|
165
|
+
assert_equal 1, assessment.questions[4].points_per_item
|
166
|
+
end
|
167
|
+
|
125
168
|
def test_it_has_a_non_cc_assessments_identifier
|
126
169
|
@mod.id = 321
|
127
170
|
assessment = Moodle2CC::Canvas::Assessment.new @mod
|
@@ -113,11 +113,17 @@ class TestUnitCCConverter < MiniTest::Unit::TestCase
|
|
113
113
|
|
114
114
|
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[1]/xmlns:item[1]').first
|
115
115
|
assert item
|
116
|
+
assert_equal "i421aa3e876264b528cdc0c22cf9b2124", item.attributes['identifier'].value
|
117
|
+
assert_equal "i2bbef1184ce7da2a0f6d9038cb872c28", item.attributes['identifierref'].value
|
118
|
+
assert_equal 'This is the Syllabus', item.xpath('xmlns:title').text
|
119
|
+
|
120
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[1]/xmlns:item[2]').first
|
121
|
+
assert item
|
116
122
|
assert_equal "i10241816e5909d8e76da003b2814c6a4", item.attributes['identifier'].value
|
117
123
|
assert_equal "i6b162484accdf6081cea43b39219d129", item.attributes['identifierref'].value
|
118
124
|
assert_equal 'Create a Rails site', item.xpath('xmlns:title').text
|
119
125
|
|
120
|
-
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[1]/xmlns:item[
|
126
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[1]/xmlns:item[3]').first
|
121
127
|
assert item
|
122
128
|
assert_equal "i966437b815a49aad86a356bc8aa8f24a", item.attributes['identifier'].value
|
123
129
|
assert_equal "i15aaccec404aa2ad557108a689bbba8f", item.attributes['identifierref'].value
|
@@ -125,11 +131,17 @@ class TestUnitCCConverter < MiniTest::Unit::TestCase
|
|
125
131
|
|
126
132
|
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[2]/xmlns:item[1]').first
|
127
133
|
assert item
|
134
|
+
assert_equal "i61c91e0962069aa79c40a406a6c38e3e", item.attributes['identifier'].value
|
135
|
+
assert_equal "i9c32ce07701475bf3eb14257f2d6def4", item.attributes['identifierref'].value
|
136
|
+
assert_equal 'Week 1 Summary', item.xpath('xmlns:title').text
|
137
|
+
|
138
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[2]/xmlns:item[2]').first
|
139
|
+
assert item
|
128
140
|
assert_equal "ie8e11ad7a1b32660f6aeaf94948faa22", item.attributes['identifier'].value
|
129
141
|
assert_equal "if7091ac80f57e45c757345555327b248", item.attributes['identifierref'].value
|
130
142
|
assert_equal 'Announcements', item.xpath('xmlns:title').text
|
131
143
|
|
132
|
-
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[2]/xmlns:item[
|
144
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[2]/xmlns:item[3]').first
|
133
145
|
assert item
|
134
146
|
assert_equal "ifcf0624ce811c812c749c53f3c914f20", item.attributes['identifier'].value
|
135
147
|
assert_equal "iddbfacadb16c78a584f81538cd53cc72", item.attributes['identifierref'].value
|
@@ -123,25 +123,25 @@ class TestUnitCanvasCourse < MiniTest::Unit::TestCase
|
|
123
123
|
|
124
124
|
assert_equal 'iebbd12be3d1d1ba16e241599099c4795', xml.xpath('//xmlns:modules/xmlns:module').first.attributes['identifier'].value
|
125
125
|
|
126
|
-
|
126
|
+
assert_equal 3, xml.xpath('//xmlns:modules/xmlns:module').count
|
127
127
|
|
128
128
|
module_node = xml.xpath('//xmlns:modules/xmlns:module[1]').first
|
129
129
|
assert_equal 'Week 0', module_node.xpath('xmlns:title').text
|
130
130
|
assert_equal '0', module_node.xpath('xmlns:position').text
|
131
131
|
assert_equal 'false', module_node.xpath('xmlns:require_sequential_progress').text
|
132
|
-
assert_equal
|
132
|
+
assert_equal 3, module_node.xpath('xmlns:items').first.xpath('xmlns:item').count
|
133
133
|
|
134
134
|
module_node = xml.xpath('//xmlns:modules/xmlns:module[2]').first
|
135
135
|
assert_equal 'Week 1', module_node.xpath('xmlns:title').text
|
136
136
|
assert_equal '1', module_node.xpath('xmlns:position').text
|
137
137
|
assert_equal 'false', module_node.xpath('xmlns:require_sequential_progress').text
|
138
|
-
assert_equal
|
139
|
-
|
140
|
-
item_node = module_node.xpath('xmlns:items/xmlns:item[9]').first
|
141
|
-
refute item_node, 'item exists for invisible mod'
|
138
|
+
assert_equal 9, module_node.xpath('xmlns:items').first.xpath('xmlns:item').count
|
142
139
|
|
143
140
|
module_node = xml.xpath('//xmlns:modules/xmlns:module[3]').first
|
144
|
-
|
141
|
+
assert_equal 'Week 3', module_node.xpath('xmlns:title').text
|
142
|
+
assert_equal '3', module_node.xpath('xmlns:position').text
|
143
|
+
assert_equal 'false', module_node.xpath('xmlns:require_sequential_progress').text
|
144
|
+
assert_equal 2, module_node.xpath('xmlns:items').first.xpath('xmlns:item').count
|
145
145
|
end
|
146
146
|
|
147
147
|
def test_it_creates_assignment_groups_xml
|
@@ -28,6 +28,25 @@ class TestUnitCanvasQuestionBank < MiniTest::Unit::TestCase
|
|
28
28
|
assert_equal 'Default for Beginning Ruby on Rails', question_bank.title
|
29
29
|
end
|
30
30
|
|
31
|
+
def test_it_converts_questions
|
32
|
+
question_bank = Moodle2CC::Canvas::QuestionBank.new @question_category
|
33
|
+
assert_equal 5, question_bank.questions.length
|
34
|
+
assert_kind_of Moodle2CC::Canvas::Question, question_bank.questions[0]
|
35
|
+
assert_kind_of Moodle2CC::Canvas::Question, question_bank.questions[1]
|
36
|
+
assert_kind_of Moodle2CC::Canvas::Question, question_bank.questions[2]
|
37
|
+
assert_kind_of Moodle2CC::Canvas::Question, question_bank.questions[3]
|
38
|
+
assert_kind_of Moodle2CC::Canvas::Question, question_bank.questions[4]
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_it_does_not_convert_random_questions
|
42
|
+
convert_moodle_backup('canvas', 'moodle_backup_random_questions')
|
43
|
+
mod = @backup.course.mods.find { |m| m.mod_type == "quiz" }
|
44
|
+
question_category = @backup.course.question_categories.first
|
45
|
+
question_bank = Moodle2CC::Canvas::QuestionBank.new question_category
|
46
|
+
|
47
|
+
assert_equal 2, question_bank.questions.length
|
48
|
+
end
|
49
|
+
|
31
50
|
def test_it_has_an_identifier
|
32
51
|
@question_category.id = 121
|
33
52
|
question_bank = Moodle2CC::Canvas::QuestionBank.new @question_category
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'test/test_helper'
|
4
|
+
require 'moodle2cc'
|
5
|
+
|
6
|
+
class TestUnitCanvasQuestionGroup < MiniTest::Unit::TestCase
|
7
|
+
include TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
convert_moodle_backup 'canvas', 'moodle_backup_random_questions'
|
11
|
+
@course = @backup.course
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
clean_tmp_folder
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_it_has_an_id
|
19
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new :id => 1
|
20
|
+
assert_equal 1, question_group.id
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_it_has_an_id_that_defaults_to_1
|
24
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new
|
25
|
+
assert_equal 1, question_group.id
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_it_has_a_title_from_the_id
|
29
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new :id => 1
|
30
|
+
assert_equal 'Group 1', question_group.title
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_it_has_a_selection_number
|
34
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new
|
35
|
+
assert_equal 1, question_group.selection_number
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_it_can_increment_the_selection_number
|
39
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new
|
40
|
+
question_group.increment_selection_number
|
41
|
+
assert_equal 2, question_group.selection_number
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_it_has_points_per_item
|
45
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new :points_per_item => 2
|
46
|
+
assert_equal 2, question_group.points_per_item
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_it_has_points_per_item_that_defaults_to_1
|
50
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new
|
51
|
+
assert_equal 1, question_group.points_per_item
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_it_has_a_question_bank
|
55
|
+
question_category = @course.question_categories.first
|
56
|
+
question_bank = Moodle2CC::Canvas::QuestionBank.new question_category
|
57
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new :question_bank => question_bank
|
58
|
+
assert_equal question_bank, question_group.question_bank
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_it_has_a_sourcebank_ref
|
62
|
+
question_category = @course.question_categories.first
|
63
|
+
question_bank = Moodle2CC::Canvas::QuestionBank.new question_category
|
64
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new :question_bank => question_bank
|
65
|
+
assert_equal question_bank.identifier, question_group.sourcebank_ref
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_it_has_an_identifer_based_on_id
|
69
|
+
question_group = Moodle2CC::Canvas::QuestionGroup.new :id => 1
|
70
|
+
assert_equal 'i5432a6c714ced15aecdc0209411ecbe9', question_group.identifier
|
71
|
+
# question_group_1
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_it_creates_item_xml
|
75
|
+
mod = @course.mods.find { |mod| mod.mod_type == 'quiz' }
|
76
|
+
assessment = Moodle2CC::Canvas::Assessment.new mod
|
77
|
+
question_group = assessment.questions.first
|
78
|
+
node = Builder::XmlMarkup.new
|
79
|
+
xml = Nokogiri::XML(question_group.create_item_xml(node))
|
80
|
+
|
81
|
+
assert xml.root, 'root element does not exist'
|
82
|
+
assert_equal 'section', xml.root.name
|
83
|
+
assert_equal 'Group 1', xml.root.attributes['title'].value
|
84
|
+
assert_equal 'i5432a6c714ced15aecdc0209411ecbe9', xml.root.attributes['ident'].value
|
85
|
+
|
86
|
+
assert_equal question_group.sourcebank_ref, xml.root.xpath('selection_ordering/selection/sourcebank_ref').text
|
87
|
+
assert_equal '2', xml.root.xpath('selection_ordering/selection/selection_number').text
|
88
|
+
assert_equal '1', xml.root.xpath('selection_ordering/selection/selection_extension/points_per_item').text
|
89
|
+
end
|
90
|
+
end
|
@@ -18,16 +18,8 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
18
18
|
clean_tmp_folder
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
|
23
|
-
question = Moodle2CC::Canvas::Question.new @question
|
24
|
-
assert_equal 989, question.id
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_it_converts_title
|
28
|
-
@question.name = "Basic Arithmetic"
|
29
|
-
question = Moodle2CC::Canvas::Question.new @question
|
30
|
-
assert_equal "Basic Arithmetic", question.title
|
21
|
+
def test_it_inherits_from_cc
|
22
|
+
assert Moodle2CC::Canvas::Question.ancestors.include?(Moodle2CC::CC::Question), 'does not inherit from base CC class'
|
31
23
|
end
|
32
24
|
|
33
25
|
def test_it_converts_length
|
@@ -128,6 +120,13 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
128
120
|
assert_equal "How much is [a] + [b] ?", question.material
|
129
121
|
end
|
130
122
|
|
123
|
+
def test_it_converts_markdown_text_to_html_material
|
124
|
+
@question.text = "This is **bold** and this is _italic_"
|
125
|
+
@question.format = 4 # markdown
|
126
|
+
question = Moodle2CC::Canvas::Question.new @question
|
127
|
+
assert_equal "<p>This is <strong>bold</strong> and this is <em>italic</em></p>\n", question.material
|
128
|
+
end
|
129
|
+
|
131
130
|
def test_it_converts_material_for_multiple_dropdowns_question
|
132
131
|
multiple_dropdowns_question!
|
133
132
|
@question.content = "This is a rating question"
|
@@ -413,7 +412,7 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
413
412
|
|
414
413
|
general_feedback = xml.root.xpath('itemfeedback[@ident="general_fb"]').first
|
415
414
|
assert general_feedback, 'no feeback node'
|
416
|
-
material = general_feedback.xpath('flow_mat/material/mattext[@texttype="text/
|
415
|
+
material = general_feedback.xpath('flow_mat/material/mattext[@texttype="text/html"]').first
|
417
416
|
assert material, 'no feedback text'
|
418
417
|
assert_equal 'This should be easy', material.text
|
419
418
|
end
|
@@ -512,14 +511,14 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
512
511
|
|
513
512
|
response = xml.root.xpath('presentation/response_lid[@ident="response_123"]').first
|
514
513
|
assert response, 'response for first matching question does not exist'
|
515
|
-
assert_equal 'Ruby on Rails is written in this language', response.xpath('material/mattext[@texttype="text/
|
514
|
+
assert_equal 'Ruby on Rails is written in this language', response.xpath('material/mattext[@texttype="text/html"]').text
|
516
515
|
assert_equal 'Ruby', response.xpath('render_choice/response_label[@ident="123"]/material/mattext').text
|
517
516
|
assert_equal 'Python', response.xpath('render_choice/response_label[@ident="234"]/material/mattext').text
|
518
517
|
assert_equal 'CoffeeScript', response.xpath('render_choice/response_label[@ident="345"]/material/mattext').text
|
519
518
|
|
520
519
|
response = xml.root.xpath('presentation/response_lid[@ident="response_345"]').first
|
521
520
|
assert response, 'response for second matching question does not exist'
|
522
|
-
assert_equal 'Files with .coffee extension use which language?', response.xpath('material/mattext[@texttype="text/
|
521
|
+
assert_equal 'Files with .coffee extension use which language?', response.xpath('material/mattext[@texttype="text/html"]').text
|
523
522
|
assert_equal 'Ruby', response.xpath('render_choice/response_label[@ident="123"]/material/mattext').text
|
524
523
|
assert_equal 'Python', response.xpath('render_choice/response_label[@ident="234"]/material/mattext').text
|
525
524
|
assert_equal 'CoffeeScript', response.xpath('render_choice/response_label[@ident="345"]/material/mattext').text
|
@@ -552,10 +551,10 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
552
551
|
response = xml.root.xpath('presentation/response_lid[@ident="response1"]').first
|
553
552
|
assert response, 'response for multiple choice question does not exist'
|
554
553
|
assert_equal 'Single', response.attributes['rcardinality'].value
|
555
|
-
assert_equal 'Ruby', response.xpath('render_choice/response_label[@ident="123"]/material/mattext[@texttype="text/
|
556
|
-
assert_equal 'CoffeeScript', response.xpath('render_choice/response_label[@ident="234"]/material/mattext[@texttype="text/
|
557
|
-
assert_equal 'Java', response.xpath('render_choice/response_label[@ident="345"]/material/mattext[@texttype="text/
|
558
|
-
assert_equal 'Clojure', response.xpath('render_choice/response_label[@ident="456"]/material/mattext[@texttype="text/
|
554
|
+
assert_equal 'Ruby', response.xpath('render_choice/response_label[@ident="123"]/material/mattext[@texttype="text/html"]').text
|
555
|
+
assert_equal 'CoffeeScript', response.xpath('render_choice/response_label[@ident="234"]/material/mattext[@texttype="text/html"]').text
|
556
|
+
assert_equal 'Java', response.xpath('render_choice/response_label[@ident="345"]/material/mattext[@texttype="text/html"]').text
|
557
|
+
assert_equal 'Clojure', response.xpath('render_choice/response_label[@ident="456"]/material/mattext[@texttype="text/html"]').text
|
559
558
|
|
560
559
|
# Feedback
|
561
560
|
feedback = xml.root.xpath('resprocessing/respcondition[@continue="Yes"]/conditionvar/varequal[@respident="response1" and text()="123"]/../..').first
|
@@ -578,19 +577,19 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
578
577
|
display = feedback.xpath('displayfeedback[@feedbacktype="Response"][@linkrefid="456_fb"]').first
|
579
578
|
assert display, 'display feedback does not exist for fourth answer'
|
580
579
|
|
581
|
-
feedback = xml.root.xpath('itemfeedback[@ident="123_fb"]/flow_mat/material/mattext[@texttype="text/
|
580
|
+
feedback = xml.root.xpath('itemfeedback[@ident="123_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
582
581
|
assert feedback, 'feedback text does not exist for first answer'
|
583
582
|
assert_equal 'Yippee!', feedback.text
|
584
583
|
|
585
|
-
feedback = xml.root.xpath('itemfeedback[@ident="234_fb"]/flow_mat/material/mattext[@texttype="text/
|
584
|
+
feedback = xml.root.xpath('itemfeedback[@ident="234_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
586
585
|
assert feedback, 'feedback text does not exist for second answer'
|
587
586
|
assert_equal 'Nope', feedback.text
|
588
587
|
|
589
|
-
feedback = xml.root.xpath('itemfeedback[@ident="345_fb"]/flow_mat/material/mattext[@texttype="text/
|
588
|
+
feedback = xml.root.xpath('itemfeedback[@ident="345_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
590
589
|
assert feedback, 'feedback text does not exist for third answer'
|
591
590
|
assert_equal 'No way', feedback.text
|
592
591
|
|
593
|
-
feedback = xml.root.xpath('itemfeedback[@ident="456_fb"]/flow_mat/material/mattext[@texttype="text/
|
592
|
+
feedback = xml.root.xpath('itemfeedback[@ident="456_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
594
593
|
assert feedback, 'feedback text does not exist for fourth answer'
|
595
594
|
assert_equal 'Not even close', feedback.text
|
596
595
|
|
@@ -627,18 +626,18 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
627
626
|
response = xml.root.xpath('presentation/response_lid[@ident="response_response1"]').first
|
628
627
|
assert response, 'first response for multiple dropdowns question does not exist'
|
629
628
|
assert response.xpath('material/mattext["response1"]').first, 'material text does not exist for multiple dropdowns question first response'
|
630
|
-
assert_equal '1=Almost Never', response.xpath('render_choice/response_label[@ident="11"]/material/mattext[@texttype="text/
|
631
|
-
assert_equal '2=Sometimes', response.xpath('render_choice/response_label[@ident="12"]/material/mattext[@texttype="text/
|
632
|
-
assert_equal '3=Always', response.xpath('render_choice/response_label[@ident="13"]/material/mattext[@texttype="text/
|
629
|
+
assert_equal '1=Almost Never', response.xpath('render_choice/response_label[@ident="11"]/material/mattext[@texttype="text/html"]').text
|
630
|
+
assert_equal '2=Sometimes', response.xpath('render_choice/response_label[@ident="12"]/material/mattext[@texttype="text/html"]').text
|
631
|
+
assert_equal '3=Always', response.xpath('render_choice/response_label[@ident="13"]/material/mattext[@texttype="text/html"]').text
|
633
632
|
refute response.xpath('render_choice/response_label[4]').first, 'there should not be a response for answer text'
|
634
633
|
refute response.xpath('render_choice/response_label[5]').first, 'there should not be a response for answer text'
|
635
634
|
|
636
635
|
response = xml.root.xpath('presentation/response_lid[@ident="response_response2"]').first
|
637
636
|
assert response, 'second response for multiple dropdowns question does not exist'
|
638
637
|
assert response.xpath('material/mattext["response2"]').first, 'material text does not exist for multiple dropdowns question second response'
|
639
|
-
assert_equal '1=Almost Never', response.xpath('render_choice/response_label[@ident="21"]/material/mattext[@texttype="text/
|
640
|
-
assert_equal '2=Sometimes', response.xpath('render_choice/response_label[@ident="22"]/material/mattext[@texttype="text/
|
641
|
-
assert_equal '3=Always', response.xpath('render_choice/response_label[@ident="23"]/material/mattext[@texttype="text/
|
638
|
+
assert_equal '1=Almost Never', response.xpath('render_choice/response_label[@ident="21"]/material/mattext[@texttype="text/html"]').text
|
639
|
+
assert_equal '2=Sometimes', response.xpath('render_choice/response_label[@ident="22"]/material/mattext[@texttype="text/html"]').text
|
640
|
+
assert_equal '3=Always', response.xpath('render_choice/response_label[@ident="23"]/material/mattext[@texttype="text/html"]').text
|
642
641
|
refute response.xpath('render_choice/response_label[4]').first, 'there should not be a response for answer text'
|
643
642
|
refute response.xpath('render_choice/response_label[5]').first, 'there should not be a response for answer text'
|
644
643
|
|
@@ -664,9 +663,9 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
664
663
|
# Responses
|
665
664
|
response = xml.root.xpath('presentation/response_lid[@ident="response1" and @rcardinality="Multiple"]').first
|
666
665
|
assert response, 'response for multiple answers question does not exist'
|
667
|
-
assert_equal 'Ruby', response.xpath('render_choice/response_label[@ident="1"]/material/mattext[@texttype="text/
|
668
|
-
assert_equal 'Javascript', response.xpath('render_choice/response_label[@ident="2"]/material/mattext[@texttype="text/
|
669
|
-
assert_equal 'Python', response.xpath('render_choice/response_label[@ident="3"]/material/mattext[@texttype="text/
|
666
|
+
assert_equal 'Ruby', response.xpath('render_choice/response_label[@ident="1"]/material/mattext[@texttype="text/html"]').text
|
667
|
+
assert_equal 'Javascript', response.xpath('render_choice/response_label[@ident="2"]/material/mattext[@texttype="text/html"]').text
|
668
|
+
assert_equal 'Python', response.xpath('render_choice/response_label[@ident="3"]/material/mattext[@texttype="text/html"]').text
|
670
669
|
|
671
670
|
# Conditions
|
672
671
|
condition = xml.root.xpath('resprocessing/respcondition[@continue="No"]').first
|
@@ -707,7 +706,7 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
707
706
|
feedback = condition.xpath('displayfeedback[@feedbacktype="Response" and @linkrefid="43_fb"]').first
|
708
707
|
assert feedback, 'displayfeedback does not exist for first answer'
|
709
708
|
|
710
|
-
feedback = xml.root.xpath('itemfeedback[@ident="43_fb"]/flow_mat/material/mattext[@texttype="text/
|
709
|
+
feedback = xml.root.xpath('itemfeedback[@ident="43_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
711
710
|
assert feedback, 'feedback text does not exist for first answer'
|
712
711
|
assert_equal 'Great age!', feedback.text
|
713
712
|
end
|
@@ -758,13 +757,13 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
758
757
|
feedback = condition.xpath('displayfeedback[@feedbacktype="Response" and @linkrefid="42_fb"]').first
|
759
758
|
assert feedback, 'displayfeedback does not exist for third answer'
|
760
759
|
|
761
|
-
feedback = xml.root.xpath('itemfeedback[@ident="40_fb"]/flow_mat/material/mattext[@texttype="text/
|
760
|
+
feedback = xml.root.xpath('itemfeedback[@ident="40_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
762
761
|
assert feedback, 'feedback text does not exist for first answer'
|
763
762
|
assert_equal 'Good choice!', feedback.text
|
764
|
-
feedback = xml.root.xpath('itemfeedback[@ident="41_fb"]/flow_mat/material/mattext[@texttype="text/
|
763
|
+
feedback = xml.root.xpath('itemfeedback[@ident="41_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
765
764
|
assert feedback, 'feedback text does not exist for second answer'
|
766
765
|
assert_equal 'Not what I would have chosen...', feedback.text
|
767
|
-
feedback = xml.root.xpath('itemfeedback[@ident="42_fb"]/flow_mat/material/mattext[@texttype="text/
|
766
|
+
feedback = xml.root.xpath('itemfeedback[@ident="42_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
768
767
|
assert feedback, 'feedback text does not exist for third answer'
|
769
768
|
assert_equal "You're kidding, right?", feedback.text
|
770
769
|
end
|
@@ -779,8 +778,8 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
779
778
|
response = xml.root.xpath('presentation/response_lid').first
|
780
779
|
assert_equal 'Single', response.attributes['rcardinality'].value
|
781
780
|
assert_equal 'response1', response.attributes['ident'].value
|
782
|
-
assert response.xpath('render_choice/response_label[@ident="44"]/material/mattext[@texttype="text/
|
783
|
-
assert response.xpath('render_choice/response_label[@ident="45"]/material/mattext[@texttype="text/
|
781
|
+
assert response.xpath('render_choice/response_label[@ident="44"]/material/mattext[@texttype="text/html" and text()="True"]').first, 'true response choice does not exist'
|
782
|
+
assert response.xpath('render_choice/response_label[@ident="45"]/material/mattext[@texttype="text/html" and text()="False"]').first, 'false response choice does not exist'
|
784
783
|
|
785
784
|
condition = xml.root.xpath('resprocessing/respcondition[@continue="No"]/conditionvar/varequal[@respident="response1" and text()="44"]/../..').first
|
786
785
|
assert condition, 'condition does not exist for first answer'
|
@@ -796,10 +795,10 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
796
795
|
setvar = condition.xpath('setvar[@varname="SCORE" and @action="Set" and text()="0"]').first
|
797
796
|
assert setvar, 'setvar does not exist for second answer'
|
798
797
|
|
799
|
-
feedback = xml.root.xpath('itemfeedback[@ident="44_fb"]/flow_mat/material/mattext[@texttype="text/
|
798
|
+
feedback = xml.root.xpath('itemfeedback[@ident="44_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
800
799
|
assert feedback, 'feedback text does not exist for first answer'
|
801
800
|
assert_equal 'Smarty pants!', feedback.text
|
802
|
-
feedback = xml.root.xpath('itemfeedback[@ident="45_fb"]/flow_mat/material/mattext[@texttype="text/
|
801
|
+
feedback = xml.root.xpath('itemfeedback[@ident="45_fb"]/flow_mat/material/mattext[@texttype="text/html"]').first
|
803
802
|
assert feedback, 'feedback text does not exist for second answer'
|
804
803
|
assert_equal 'What exactly are you doing?', feedback.text
|
805
804
|
end
|