moodle2cc 0.1.1 → 0.1.2
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.
- 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
@@ -46,7 +46,7 @@ class TestUnitCanvasWiki < MiniTest::Unit::TestCase
|
|
46
46
|
|
47
47
|
assert_equal 'item', xml.root.name
|
48
48
|
assert_equal 'i7b382ae83ddb7cc9be1a12e517088bc4', xml.root.attributes['identifier'].value
|
49
|
-
assert_equal "My
|
49
|
+
assert_equal "My wiki", xml.root.xpath('title').text
|
50
50
|
assert_equal '5', xml.root.xpath('position').text
|
51
51
|
assert_equal '', xml.root.xpath('new_tab').text
|
52
52
|
assert_equal '0', xml.root.xpath('indent').text
|
@@ -101,7 +101,7 @@ class TestUnitCCConverter < MiniTest::Unit::TestCase
|
|
101
101
|
assert_equal 'Week 1', item.xpath('xmlns:title').text
|
102
102
|
end
|
103
103
|
|
104
|
-
def
|
104
|
+
def test_imsmanifest_does_not_create_item_for_sections_with_no_modules
|
105
105
|
xml = get_imsmanifest_xml
|
106
106
|
|
107
107
|
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[@identifier="i9a57aafbbb5993c28a89c2e363e97f87"]').first
|
@@ -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 "i09cb85ba0baf2ffee6aef5f2249dea69", item.attributes['identifier'].value
|
117
|
+
assert_equal "i3b3b3e626c91e725614a6ce837b6de34", 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 "i66b491d95b61e87f7ae71445a82a4d22", item.attributes['identifier'].value
|
135
|
+
assert_equal "idfd13c979a2bde97c18a4bcb51752001", 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
|
@@ -18,7 +18,6 @@ class TestUnitCCQuestion < MiniTest::Unit::TestCase
|
|
18
18
|
clean_tmp_folder
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
21
|
def test_it_converts_id
|
23
22
|
@question.id = 989
|
24
23
|
question = Moodle2CC::CC::Question.new @question
|
@@ -31,6 +30,12 @@ class TestUnitCCQuestion < MiniTest::Unit::TestCase
|
|
31
30
|
assert_equal "Basic Arithmetic", question.title
|
32
31
|
end
|
33
32
|
|
33
|
+
def test_it_converts_title_with_escaped_html
|
34
|
+
@question.name = "the <div> tag"
|
35
|
+
question = Moodle2CC::Canvas::Question.new @question
|
36
|
+
assert_equal "the <div> tag", question.title
|
37
|
+
end
|
38
|
+
|
34
39
|
def test_it_has_an_identifier_based_on_id
|
35
40
|
@question.id = 989
|
36
41
|
@question.instance_id = nil
|
data/test/unit/cc/wiki_test.rb
CHANGED
@@ -60,7 +60,7 @@ class TestUnitCCWiki < MiniTest::Unit::TestCase
|
|
60
60
|
wiki = Moodle2CC::CC::Wiki.new @mod
|
61
61
|
assert_equal 1, wiki.pages.length
|
62
62
|
|
63
|
-
assert_equal 'My
|
63
|
+
assert_equal 'My wiki', wiki.pages[0].title
|
64
64
|
assert_equal 'This is the summary', wiki.pages[0].body
|
65
65
|
assert_equal 'wiki_content/my-wiki.html', wiki.pages[0].href
|
66
66
|
assert_equal 'ib87fd4bafae6f3e3ee7dadb65b0e45a3', wiki.pages[0].identifier
|
@@ -24,7 +24,7 @@ class TestUnitMoodleMod < MiniTest::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_it_has_all_the_mods
|
27
|
-
assert_equal
|
27
|
+
assert_equal 14, @mods.length
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_it_has_an_id
|
@@ -290,7 +290,7 @@ class TestUnitMoodleMod < MiniTest::Unit::TestCase
|
|
290
290
|
end
|
291
291
|
|
292
292
|
def test_it_has_section_mods
|
293
|
-
assert_equal @course.sections.first.mods
|
293
|
+
assert_equal @course.sections.first.mods[1], @mods[0].section_mod
|
294
294
|
end
|
295
295
|
|
296
296
|
def test_it_has_a_grade_item
|
@@ -41,6 +41,10 @@ class TestUnitMoodleQuestion < MiniTest::Unit::TestCase
|
|
41
41
|
assert_equal 'How much is {a} + {b} ?', @calculated_question.text
|
42
42
|
end
|
43
43
|
|
44
|
+
def test_it_has_a_format
|
45
|
+
assert_equal 1, @calculated_question.format
|
46
|
+
end
|
47
|
+
|
44
48
|
def test_it_has_general_feedback
|
45
49
|
assert_equal 'This should be easy', @calculated_question.general_feedback
|
46
50
|
end
|
@@ -22,7 +22,7 @@ class TestUnitMoodleSection < MiniTest::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_it_has_all_the_sections
|
25
|
-
assert_equal
|
25
|
+
assert_equal 4, @sections.length
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_it_has_an_id
|
@@ -46,30 +46,47 @@ class TestUnitMoodleSection < MiniTest::Unit::TestCase
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_mods_have_an_id
|
49
|
-
assert 11111, @section.mods.
|
49
|
+
assert 11111, @section.mods[1].id
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_mods_have_an_instance_id
|
53
|
-
assert 987, @section.mods.
|
53
|
+
assert 987, @section.mods[1].instance_id
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_mods_have_an_indent
|
57
|
-
assert_equal 0, @section.mods[
|
57
|
+
assert_equal 0, @section.mods[1].indent
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_mods_have_a_visibility
|
61
|
-
assert_equal true, @section.mods[
|
61
|
+
assert_equal true, @section.mods[1].visible
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_mods_have_instances
|
65
|
-
assert_equal @course.mods.first.id, @section.mods.
|
65
|
+
assert_equal @course.mods.first.id, @section.mods[1].instance.id
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_mods_have_added
|
69
|
-
assert_equal 1338410699, @section.mods.
|
69
|
+
assert_equal 1338410699, @section.mods[1].added
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_mods_have_a_mod_type
|
73
|
-
assert_equal 'assignment', @section.mods.
|
73
|
+
assert_equal 'assignment', @section.mods[1].mod_type
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_first_mod_is_label_from_summary
|
77
|
+
mod = @section.mods.first
|
78
|
+
assert_equal "section_summary_mod_#{@section.id}", mod.id
|
79
|
+
assert_equal "section_summary_instance_#{@section.id}", mod.instance_id
|
80
|
+
assert_equal 'summary', mod.mod_type
|
81
|
+
assert_equal 0, mod.indent
|
82
|
+
assert_equal true, mod.visible
|
83
|
+
assert_equal @section, mod.section
|
84
|
+
|
85
|
+
instance = mod.instance
|
86
|
+
assert_equal mod, instance.section_mod
|
87
|
+
assert_equal "section_summary_instance_#{@section.id}", instance.id
|
88
|
+
assert_equal 'summary', instance.mod_type
|
89
|
+
assert_equal "This is the Syllabus", instance.name
|
90
|
+
assert_equal "<h1>This is the Syllabus</h1>", instance.content
|
74
91
|
end
|
75
92
|
end
|
@@ -80,6 +80,15 @@ class TestUnitCCResource < MiniTest::Unit::TestCase
|
|
80
80
|
assert_kind_of Moodle2CC::Canvas::Label, resource
|
81
81
|
end
|
82
82
|
|
83
|
+
def test_it_can_get_label_resource_from_summary_mod
|
84
|
+
mod = @backup.course.mods.find { |m| m.mod_type == "summary" }
|
85
|
+
resource = @cc_factory.get_resource_from_mod(mod)
|
86
|
+
assert_kind_of Moodle2CC::CC::Label, resource
|
87
|
+
|
88
|
+
resource = @canvas_factory.get_resource_from_mod(mod)
|
89
|
+
assert_kind_of Moodle2CC::Canvas::Label, resource
|
90
|
+
end
|
91
|
+
|
83
92
|
def test_it_can_get_web_content_resource_from_label_mod_with_img_tag
|
84
93
|
mod = @backup.course.mods.find { |m| m.mod_type == "label" }
|
85
94
|
mod.content = %(<img src="http://image.com/image.jpg" />")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moodle2cc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Durtschi
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-
|
20
|
+
date: 2012-08-03 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rubyzip
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
type: :runtime
|
91
91
|
version_requirements: *id005
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
|
-
name:
|
93
|
+
name: rdiscount
|
94
94
|
prerelease: false
|
95
95
|
requirement: &id006 !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
@@ -101,10 +101,10 @@ dependencies:
|
|
101
101
|
segments:
|
102
102
|
- 0
|
103
103
|
version: "0"
|
104
|
-
type: :
|
104
|
+
type: :runtime
|
105
105
|
version_requirements: *id006
|
106
106
|
- !ruby/object:Gem::Dependency
|
107
|
-
name:
|
107
|
+
name: rake
|
108
108
|
prerelease: false
|
109
109
|
requirement: &id007 !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
@@ -118,7 +118,7 @@ dependencies:
|
|
118
118
|
type: :development
|
119
119
|
version_requirements: *id007
|
120
120
|
- !ruby/object:Gem::Dependency
|
121
|
-
name:
|
121
|
+
name: minitest
|
122
122
|
prerelease: false
|
123
123
|
requirement: &id008 !ruby/object:Gem::Requirement
|
124
124
|
none: false
|
@@ -132,7 +132,7 @@ dependencies:
|
|
132
132
|
type: :development
|
133
133
|
version_requirements: *id008
|
134
134
|
- !ruby/object:Gem::Dependency
|
135
|
-
name: guard
|
135
|
+
name: guard
|
136
136
|
prerelease: false
|
137
137
|
requirement: &id009 !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
type: :development
|
147
147
|
version_requirements: *id009
|
148
148
|
- !ruby/object:Gem::Dependency
|
149
|
-
name: guard-
|
149
|
+
name: guard-bundler
|
150
150
|
prerelease: false
|
151
151
|
requirement: &id010 !ruby/object:Gem::Requirement
|
152
152
|
none: false
|
@@ -159,6 +159,20 @@ dependencies:
|
|
159
159
|
version: "0"
|
160
160
|
type: :development
|
161
161
|
version_requirements: *id010
|
162
|
+
- !ruby/object:Gem::Dependency
|
163
|
+
name: guard-minitest
|
164
|
+
prerelease: false
|
165
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
166
|
+
none: false
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
hash: 3
|
171
|
+
segments:
|
172
|
+
- 0
|
173
|
+
version: "0"
|
174
|
+
type: :development
|
175
|
+
version_requirements: *id011
|
162
176
|
description: Migrates Moodle backup ZIP to IMS Common Cartridge package
|
163
177
|
email:
|
164
178
|
- christopher.durtschi@gmail.com
|
@@ -189,6 +203,7 @@ files:
|
|
189
203
|
- lib/moodle2cc/canvas/label.rb
|
190
204
|
- lib/moodle2cc/canvas/question.rb
|
191
205
|
- lib/moodle2cc/canvas/question_bank.rb
|
206
|
+
- lib/moodle2cc/canvas/question_group.rb
|
192
207
|
- lib/moodle2cc/canvas/resource.rb
|
193
208
|
- lib/moodle2cc/canvas/templates/assignment.html.erb
|
194
209
|
- lib/moodle2cc/canvas/templates/syllabus.html.erb
|
@@ -231,6 +246,9 @@ files:
|
|
231
246
|
- test/fixtures/moodle_backup/course_files/folder/test.txt
|
232
247
|
- test/fixtures/moodle_backup/course_files/test.txt
|
233
248
|
- test/fixtures/moodle_backup/moodle.xml
|
249
|
+
- test/fixtures/moodle_backup_random_questions/course_files/folder/test.txt
|
250
|
+
- test/fixtures/moodle_backup_random_questions/course_files/test.txt
|
251
|
+
- test/fixtures/moodle_backup_random_questions/moodle.xml
|
234
252
|
- test/test_helper.rb
|
235
253
|
- test/test_question_helper.rb
|
236
254
|
- test/test_wiki_helper.rb
|
@@ -242,6 +260,7 @@ files:
|
|
242
260
|
- test/unit/canvas/discussion_topic_test.rb
|
243
261
|
- test/unit/canvas/label_test.rb
|
244
262
|
- test/unit/canvas/question_bank_test.rb
|
263
|
+
- test/unit/canvas/question_group_test.rb
|
245
264
|
- test/unit/canvas/question_test.rb
|
246
265
|
- test/unit/canvas/web_content_test.rb
|
247
266
|
- test/unit/canvas/web_link_test.rb
|
@@ -307,6 +326,9 @@ test_files:
|
|
307
326
|
- test/fixtures/moodle_backup/course_files/folder/test.txt
|
308
327
|
- test/fixtures/moodle_backup/course_files/test.txt
|
309
328
|
- test/fixtures/moodle_backup/moodle.xml
|
329
|
+
- test/fixtures/moodle_backup_random_questions/course_files/folder/test.txt
|
330
|
+
- test/fixtures/moodle_backup_random_questions/course_files/test.txt
|
331
|
+
- test/fixtures/moodle_backup_random_questions/moodle.xml
|
310
332
|
- test/test_helper.rb
|
311
333
|
- test/test_question_helper.rb
|
312
334
|
- test/test_wiki_helper.rb
|
@@ -318,6 +340,7 @@ test_files:
|
|
318
340
|
- test/unit/canvas/discussion_topic_test.rb
|
319
341
|
- test/unit/canvas/label_test.rb
|
320
342
|
- test/unit/canvas/question_bank_test.rb
|
343
|
+
- test/unit/canvas/question_group_test.rb
|
321
344
|
- test/unit/canvas/question_test.rb
|
322
345
|
- test/unit/canvas/web_content_test.rb
|
323
346
|
- test/unit/canvas/web_link_test.rb
|