moodle2cc 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/Changelog +40 -0
- data/lib/moodle2cc/canvas/question.rb +6 -0
- data/lib/moodle2cc/moodle/question.rb +1 -0
- data/lib/moodle2cc/version.rb +1 -1
- data/{test → lib/test}/test_helper.rb +6 -6
- data/{test → lib/test}/test_question_helper.rb +0 -0
- data/{test → lib/test}/test_wiki_helper.rb +0 -0
- data/test/fixtures/moodle_backup/moodle.xml +1 -1
- data/test/unit/canvas/question_test.rb +10 -1
- data/test/unit/moodle/question_test.rb +4 -0
- metadata +8 -10
data/.travis.yml
ADDED
data/Changelog
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
2013-06-27 Version 0.1.7
|
2
|
+
* Include question images when converting to QTI
|
3
|
+
* Added travis setup for happiness
|
4
|
+
|
5
|
+
2012-12-07 Version 0.1.6
|
6
|
+
* Added Changelog
|
7
|
+
* Don't error out when trying to reference non-existent quiz question
|
8
|
+
|
9
|
+
2012-08-20 Version 0.1.5
|
10
|
+
|
11
|
+
* Readme improvements
|
12
|
+
* Listed todo items for complete Common Cartridge conversion support
|
13
|
+
* Added assignment conversion to plain CC
|
14
|
+
* Added wiki page conversion to plain CC
|
15
|
+
|
16
|
+
2012-08-15 Version 0.1.4
|
17
|
+
|
18
|
+
* More robust URI parsing
|
19
|
+
|
20
|
+
2012-08-06 Version 0.1.3
|
21
|
+
|
22
|
+
* Fix external link and attachment references
|
23
|
+
* Fix ordering of module items
|
24
|
+
|
25
|
+
|
26
|
+
2012-08-03 Version 0.1.2
|
27
|
+
|
28
|
+
* Add quiz support
|
29
|
+
* Better handle wiki titles and summaries
|
30
|
+
|
31
|
+
|
32
|
+
2012-07-26 Version 0.1.1
|
33
|
+
|
34
|
+
* Fix extra whitespace errors
|
35
|
+
* Add ability to inject logger during conversion process
|
36
|
+
|
37
|
+
|
38
|
+
2012-7-24 Version 0.1.0
|
39
|
+
|
40
|
+
* Initial release
|
@@ -116,6 +116,7 @@ module Moodle2CC::Canvas
|
|
116
116
|
material = question.text
|
117
117
|
material = question.content || '' if material.nil?
|
118
118
|
material = material.gsub(/\{(.*?)\}/, '[\1]')
|
119
|
+
material = image_html(question.image) + material unless question.image.nil? || question.image.strip == ''
|
119
120
|
material = RDiscount.new(material).to_html if question.format == 4 # markdown
|
120
121
|
@material = material
|
121
122
|
|
@@ -467,5 +468,10 @@ module Moodle2CC::Canvas
|
|
467
468
|
return 100 if fraction.nil?
|
468
469
|
(100 * fraction).to_i
|
469
470
|
end
|
471
|
+
|
472
|
+
def image_html(image)
|
473
|
+
image = image.strip
|
474
|
+
%{<img src="#{WEB_CONTENT_TOKEN}/#{image}" alt="#{image}"/>}
|
475
|
+
end
|
470
476
|
end
|
471
477
|
end
|
@@ -80,6 +80,7 @@ module Moodle2CC::Moodle
|
|
80
80
|
element :position, Integer, :tag => 'POSITION'
|
81
81
|
element :type, String, :tag => 'QTYPE'
|
82
82
|
element :type_id, Integer, :tag => 'TYPE_ID'
|
83
|
+
element :image, String, :tag => 'IMAGE'
|
83
84
|
has_many :numericals, Numerical
|
84
85
|
has_many :answers, Answer
|
85
86
|
has_many :calculations, Calculation
|
data/lib/moodle2cc/version.rb
CHANGED
@@ -2,13 +2,13 @@ require 'zip/zipfilesystem'
|
|
2
2
|
|
3
3
|
module TestHelper
|
4
4
|
def create_moodle_backup_zip(backup_name='moodle_backup')
|
5
|
-
moodle_backup_path = File.expand_path("
|
5
|
+
moodle_backup_path = File.expand_path("../../../test/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("
|
7
|
+
zipfile.add("moodle.xml", File.expand_path("../../../test/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("
|
11
|
-
zipfile.add("course_files/folder/test.txt", File.expand_path("
|
10
|
+
zipfile.add("course_files/test.txt", File.expand_path("../../../test/fixtures/#{backup_name}/course_files/test.txt", __FILE__))
|
11
|
+
zipfile.add("course_files/folder/test.txt", File.expand_path("../../../test/fixtures/#{backup_name}/course_files/folder/test.txt", __FILE__))
|
12
12
|
end
|
13
13
|
moodle_backup_path
|
14
14
|
end
|
@@ -18,7 +18,7 @@ module TestHelper
|
|
18
18
|
converter_class = format == 'cc' ? Moodle2CC::CC::Converter : Moodle2CC::Canvas::Converter
|
19
19
|
@backup_path = create_moodle_backup_zip(backup_name)
|
20
20
|
@backup = Moodle2CC::Moodle::Backup.read @backup_path
|
21
|
-
@export_dir = File.expand_path("
|
21
|
+
@export_dir = File.expand_path("../../../test/tmp", __FILE__)
|
22
22
|
@converter = converter_class.new @backup, @export_dir
|
23
23
|
@converter.convert
|
24
24
|
end
|
@@ -36,7 +36,7 @@ module TestHelper
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def clean_tmp_folder
|
39
|
-
Dir[File.expand_path("
|
39
|
+
Dir[File.expand_path("../../../test/tmp/*", __FILE__)].each do |file|
|
40
40
|
FileUtils.rm_r file
|
41
41
|
end
|
42
42
|
end
|
File without changes
|
File without changes
|
@@ -249,7 +249,7 @@
|
|
249
249
|
<NAME>Basic Arithmetic</NAME>
|
250
250
|
<QUESTIONTEXT>How much is {a} + {b} ?</QUESTIONTEXT>
|
251
251
|
<QUESTIONTEXTFORMAT>1</QUESTIONTEXTFORMAT>
|
252
|
-
<IMAGE
|
252
|
+
<IMAGE>test.jpg</IMAGE>
|
253
253
|
<GENERALFEEDBACK>This should be easy</GENERALFEEDBACK>
|
254
254
|
<DEFAULTGRADE>1</DEFAULTGRADE>
|
255
255
|
<PENALTY>0.1</PENALTY>
|
@@ -12,6 +12,7 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
12
12
|
convert_moodle_backup 'canvas'
|
13
13
|
@mod = @backup.course.mods.find { |mod| mod.mod_type == 'quiz' }
|
14
14
|
@question = @mod.questions.first
|
15
|
+
@question.image = nil
|
15
16
|
end
|
16
17
|
|
17
18
|
def teardown
|
@@ -120,6 +121,13 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
120
121
|
assert_equal "How much is [a] + [b] ?", question.material
|
121
122
|
end
|
122
123
|
|
124
|
+
def test_it_adds_image_tag_to_material
|
125
|
+
@question.text = "How much is {a} + {b} ?"
|
126
|
+
@question.image = "test.jpg"
|
127
|
+
question = Moodle2CC::Canvas::Question.new @question
|
128
|
+
assert_equal %{<img src="$IMS_CC_FILEBASE$/test.jpg" alt="test.jpg"/>How much is [a] + [b] ?}, question.material
|
129
|
+
end
|
130
|
+
|
123
131
|
def test_it_converts_markdown_text_to_html_material
|
124
132
|
@question.text = "This is **bold** and this is _italic_"
|
125
133
|
@question.format = 4 # markdown
|
@@ -381,6 +389,7 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
381
389
|
end
|
382
390
|
|
383
391
|
def test_it_creates_item_xml
|
392
|
+
@question.image = 'test.jpg'
|
384
393
|
question = Moodle2CC::Canvas::Question.new @question
|
385
394
|
node = Builder::XmlMarkup.new
|
386
395
|
xml = Nokogiri::XML(question.create_item_xml(node))
|
@@ -394,7 +403,7 @@ class TestUnitCanvasQuestion < MiniTest::Unit::TestCase
|
|
394
403
|
assert xml.root.xpath('itemmetadata/qtimetadata/qtimetadatafield[fieldlabel="points_possible" and fieldentry="1"]').first, 'does not have meta data for points possible'
|
395
404
|
assert xml.root.xpath('itemmetadata/qtimetadata/qtimetadatafield[fieldlabel="assessment_question_identifierref" and fieldentry="i04823ed56ffd4fd5f9c21db0cf25be6c"]').first, 'does not have meta data for assessment_question_identifierref'
|
396
405
|
|
397
|
-
assert_equal
|
406
|
+
assert_equal %{<img src="$IMS_CC_FILEBASE$/test.jpg" alt="test.jpg"/>How much is [a] + [b] ?}, xml.root.xpath('presentation/material/mattext[@texttype="text/html"]').text
|
398
407
|
|
399
408
|
# Score
|
400
409
|
outcome = xml.root.xpath('resprocessing/outcomes/decvar').first
|
@@ -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_image
|
45
|
+
assert_equal 'test.jpg', @calculated_question.image
|
46
|
+
end
|
47
|
+
|
44
48
|
def test_it_has_a_format
|
45
49
|
assert_equal 1, @calculated_question.format
|
46
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moodle2cc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rubyzip
|
@@ -200,6 +200,8 @@ extensions: []
|
|
200
200
|
extra_rdoc_files: []
|
201
201
|
files:
|
202
202
|
- .gitignore
|
203
|
+
- .travis.yml
|
204
|
+
- Changelog
|
203
205
|
- Gemfile
|
204
206
|
- Guardfile
|
205
207
|
- LICENSE
|
@@ -252,6 +254,9 @@ files:
|
|
252
254
|
- lib/moodle2cc/moodle/section.rb
|
253
255
|
- lib/moodle2cc/resource_factory.rb
|
254
256
|
- lib/moodle2cc/version.rb
|
257
|
+
- lib/test/test_helper.rb
|
258
|
+
- lib/test/test_question_helper.rb
|
259
|
+
- lib/test/test_wiki_helper.rb
|
255
260
|
- moodle2cc.gemspec
|
256
261
|
- test/acceptance/migrator_test.rb
|
257
262
|
- test/fixtures/cc.imscc
|
@@ -261,9 +266,6 @@ files:
|
|
261
266
|
- test/fixtures/moodle_backup_random_questions/course_files/folder/test.txt
|
262
267
|
- test/fixtures/moodle_backup_random_questions/course_files/test.txt
|
263
268
|
- test/fixtures/moodle_backup_random_questions/moodle.xml
|
264
|
-
- test/test_helper.rb
|
265
|
-
- test/test_question_helper.rb
|
266
|
-
- test/test_wiki_helper.rb
|
267
269
|
- test/tmp/.gitkeep
|
268
270
|
- test/unit/canvas/assessment_test.rb
|
269
271
|
- test/unit/canvas/assignment_test.rb
|
@@ -319,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
319
321
|
version: '0'
|
320
322
|
requirements: []
|
321
323
|
rubyforge_project:
|
322
|
-
rubygems_version: 1.8.
|
324
|
+
rubygems_version: 1.8.23
|
323
325
|
signing_key:
|
324
326
|
specification_version: 3
|
325
327
|
summary: Migrates Moodle backup ZIP to IMS Common Cartridge package
|
@@ -332,9 +334,6 @@ test_files:
|
|
332
334
|
- test/fixtures/moodle_backup_random_questions/course_files/folder/test.txt
|
333
335
|
- test/fixtures/moodle_backup_random_questions/course_files/test.txt
|
334
336
|
- test/fixtures/moodle_backup_random_questions/moodle.xml
|
335
|
-
- test/test_helper.rb
|
336
|
-
- test/test_question_helper.rb
|
337
|
-
- test/test_wiki_helper.rb
|
338
337
|
- test/tmp/.gitkeep
|
339
338
|
- test/unit/canvas/assessment_test.rb
|
340
339
|
- test/unit/canvas/assignment_test.rb
|
@@ -370,4 +369,3 @@ test_files:
|
|
370
369
|
- test/unit/moodle/question_test.rb
|
371
370
|
- test/unit/moodle/section_test.rb
|
372
371
|
- test/unit/resource_factory_test.rb
|
373
|
-
has_rdoc:
|