moodle2cc 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE +661 -0
- data/README.md +38 -0
- data/Rakefile +12 -0
- data/bin/moodle2cc +6 -0
- data/lib/moodle2cc.rb +60 -0
- data/lib/moodle2cc/canvas/.converter.rb.swo +0 -0
- data/lib/moodle2cc/canvas/.wiki.rb.swo +0 -0
- data/lib/moodle2cc/canvas/assessment.rb +109 -0
- data/lib/moodle2cc/canvas/assignment.rb +108 -0
- data/lib/moodle2cc/canvas/converter.rb +28 -0
- data/lib/moodle2cc/canvas/course.rb +145 -0
- data/lib/moodle2cc/canvas/discussion_topic.rb +64 -0
- data/lib/moodle2cc/canvas/label.rb +8 -0
- data/lib/moodle2cc/canvas/question.rb +468 -0
- data/lib/moodle2cc/canvas/question_bank.rb +54 -0
- data/lib/moodle2cc/canvas/resource.rb +16 -0
- data/lib/moodle2cc/canvas/templates/assignment.html.erb +9 -0
- data/lib/moodle2cc/canvas/templates/syllabus.html.erb +9 -0
- data/lib/moodle2cc/canvas/templates/wiki_content.html.erb +10 -0
- data/lib/moodle2cc/canvas/web_content.rb +10 -0
- data/lib/moodle2cc/canvas/web_link.rb +17 -0
- data/lib/moodle2cc/canvas/wiki.rb +25 -0
- data/lib/moodle2cc/cc/assessment.rb +25 -0
- data/lib/moodle2cc/cc/assignment.rb +66 -0
- data/lib/moodle2cc/cc/cc_helper.rb +282 -0
- data/lib/moodle2cc/cc/converter.rb +136 -0
- data/lib/moodle2cc/cc/course.rb +16 -0
- data/lib/moodle2cc/cc/discussion_topic.rb +53 -0
- data/lib/moodle2cc/cc/label.rb +6 -0
- data/lib/moodle2cc/cc/question.rb +23 -0
- data/lib/moodle2cc/cc/resource.rb +30 -0
- data/lib/moodle2cc/cc/templates/assignment.html.erb +9 -0
- data/lib/moodle2cc/cc/templates/syllabus.html.erb +9 -0
- data/lib/moodle2cc/cc/templates/wiki_content.html.erb +10 -0
- data/lib/moodle2cc/cc/web_content.rb +40 -0
- data/lib/moodle2cc/cc/web_link.rb +53 -0
- data/lib/moodle2cc/cc/wiki.rb +72 -0
- data/lib/moodle2cc/cli.rb +14 -0
- data/lib/moodle2cc/error.rb +3 -0
- data/lib/moodle2cc/migrator.rb +23 -0
- data/lib/moodle2cc/moodle/backup.rb +38 -0
- data/lib/moodle2cc/moodle/course.rb +24 -0
- data/lib/moodle2cc/moodle/grade_item.rb +24 -0
- data/lib/moodle2cc/moodle/info.rb +8 -0
- data/lib/moodle2cc/moodle/mod.rb +127 -0
- data/lib/moodle2cc/moodle/question.rb +98 -0
- data/lib/moodle2cc/moodle/question_category.rb +17 -0
- data/lib/moodle2cc/moodle/section.rb +37 -0
- data/lib/moodle2cc/resource_factory.rb +32 -0
- data/lib/moodle2cc/version.rb +3 -0
- data/moodle2cc.gemspec +29 -0
- data/test/acceptance/migrator_test.rb +23 -0
- data/test/fixtures/cc.imscc +0 -0
- data/test/fixtures/moodle_backup/course_files/folder/test.txt +1 -0
- data/test/fixtures/moodle_backup/course_files/test.txt +1 -0
- data/test/fixtures/moodle_backup/moodle.xml +916 -0
- data/test/test_helper.rb +43 -0
- data/test/test_question_helper.rb +107 -0
- data/test/test_wiki_helper.rb +21 -0
- data/test/unit/canvas/assessment_test.rb +218 -0
- data/test/unit/canvas/assignment_test.rb +220 -0
- data/test/unit/canvas/converter_test.rb +159 -0
- data/test/unit/canvas/course_test.rb +176 -0
- data/test/unit/canvas/discussion_topic_test.rb +129 -0
- data/test/unit/canvas/label_test.rb +32 -0
- data/test/unit/canvas/question_bank_test.rb +73 -0
- data/test/unit/canvas/question_test.rb +824 -0
- data/test/unit/canvas/web_content_test.rb +37 -0
- data/test/unit/canvas/web_link_test.rb +48 -0
- data/test/unit/canvas/wiki_test.rb +74 -0
- data/test/unit/cc/assessment_test.rb +48 -0
- data/test/unit/cc/assignment_test.rb +67 -0
- data/test/unit/cc/cc_helper_test.rb +19 -0
- data/test/unit/cc/converter_test.rb +159 -0
- data/test/unit/cc/course_test.rb +36 -0
- data/test/unit/cc/discussion_topic_test.rb +83 -0
- data/test/unit/cc/label_test.rb +29 -0
- data/test/unit/cc/question_test.rb +49 -0
- data/test/unit/cc/web_content_test.rb +76 -0
- data/test/unit/cc/web_link_test.rb +79 -0
- data/test/unit/cc/wiki_test.rb +139 -0
- data/test/unit/migrator_test.rb +56 -0
- data/test/unit/moodle/backup_test.rb +30 -0
- data/test/unit/moodle/course_test.rb +57 -0
- data/test/unit/moodle/grade_item_test.rb +72 -0
- data/test/unit/moodle/info_test.rb +21 -0
- data/test/unit/moodle/mod_test.rb +301 -0
- data/test/unit/moodle/question_category_test.rb +34 -0
- data/test/unit/moodle/question_test.rb +185 -0
- data/test/unit/moodle/section_test.rb +75 -0
- data/test/unit/resource_factory_test.rb +119 -0
- metadata +342 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'test/test_helper'
|
4
|
+
require 'moodle2cc'
|
5
|
+
|
6
|
+
class TestUnitCanvasWebContent < MiniTest::Unit::TestCase
|
7
|
+
include TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
convert_moodle_backup 'canvas'
|
11
|
+
@mod = @backup.course.mods.find { |m| m.mod_type == "resource" && m.type == "html" }
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
clean_tmp_folder
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_it_inherits_from_cc
|
19
|
+
assert Moodle2CC::Canvas::WebContent.ancestors.include?(Moodle2CC::CC::WebContent), 'does not inherit from base CC class'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_it_creates_item_in_module_meta
|
23
|
+
web_content = Moodle2CC::Canvas::WebContent.new @mod
|
24
|
+
node = Builder::XmlMarkup.new
|
25
|
+
xml = Nokogiri::XML(web_content.create_module_meta_item_node(node, 5))
|
26
|
+
|
27
|
+
assert_equal 'item', xml.root.name
|
28
|
+
assert_equal 'i6f06dd1384233e65fa28bd11b97c8b16', xml.root.attributes['identifier'].value
|
29
|
+
assert_equal "Instructor Resources", xml.root.xpath('title').text
|
30
|
+
assert_equal '5', xml.root.xpath('position').text
|
31
|
+
assert_equal '', xml.root.xpath('new_tab').text
|
32
|
+
assert_equal '1', xml.root.xpath('indent').text
|
33
|
+
assert_equal 'WikiPage', xml.root.xpath('content_type').text
|
34
|
+
assert_equal 'i6447ff05ab6e342a42302007a6e3bcb4', xml.root.xpath('identifierref').text
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'test/test_helper'
|
4
|
+
require 'moodle2cc'
|
5
|
+
|
6
|
+
class TestUnitCanvasWebLink < MiniTest::Unit::TestCase
|
7
|
+
include TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
convert_moodle_backup 'canvas'
|
11
|
+
@mod = @backup.course.mods.find { |m| m.mod_type == "resource" && m.type == "file" }
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
clean_tmp_folder
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_it_inherits_from_cc
|
19
|
+
assert Moodle2CC::Canvas::WebLink.ancestors.include?(Moodle2CC::CC::WebLink), 'does not inherit from base CC class'
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
def test_it_creates_item_in_module_meta
|
24
|
+
@mod.reference = "http://www.google.com/some-doc.html"
|
25
|
+
web_link = Moodle2CC::Canvas::WebLink.new @mod
|
26
|
+
node = Builder::XmlMarkup.new
|
27
|
+
xml = Nokogiri::XML(web_link.create_module_meta_item_node(node, 5))
|
28
|
+
|
29
|
+
assert_equal 'item', xml.root.name
|
30
|
+
assert_equal 'i966437b815a49aad86a356bc8aa8f24a', xml.root.attributes['identifier'].value
|
31
|
+
assert_equal "About Your Instructor", xml.root.xpath('title').text
|
32
|
+
assert_equal '5', xml.root.xpath('position').text
|
33
|
+
assert_equal '', xml.root.xpath('new_tab').text
|
34
|
+
assert_equal '1', xml.root.xpath('indent').text
|
35
|
+
assert_equal 'http://www.google.com/some-doc.html', xml.root.xpath('url').text
|
36
|
+
assert_equal 'ExternalUrl', xml.root.xpath('content_type').text
|
37
|
+
assert_equal 'i15aaccec404aa2ad557108a689bbba8f', xml.root.xpath('identifierref').text
|
38
|
+
|
39
|
+
@mod.reference = "some/local/file.html"
|
40
|
+
web_link = Moodle2CC::Canvas::WebLink.new @mod
|
41
|
+
node = Builder::XmlMarkup.new
|
42
|
+
xml = Nokogiri::XML(web_link.create_module_meta_item_node(node, 5))
|
43
|
+
|
44
|
+
assert_equal '', xml.root.xpath('url').text
|
45
|
+
assert_equal 'Attachment', xml.root.xpath('content_type').text
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'test/test_helper'
|
4
|
+
require 'test/test_wiki_helper'
|
5
|
+
require 'moodle2cc'
|
6
|
+
|
7
|
+
class TestUnitCanvasWiki < MiniTest::Unit::TestCase
|
8
|
+
include TestHelper
|
9
|
+
include TestWikiHelper
|
10
|
+
|
11
|
+
def setup
|
12
|
+
convert_moodle_backup 'canvas'
|
13
|
+
@mod = @backup.course.mods.find { |m| m.mod_type == "wiki" }
|
14
|
+
@wiki = Moodle2CC::Canvas::Wiki.new @mod
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
clean_tmp_folder
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_it_inherits_from_cc
|
22
|
+
assert Moodle2CC::Canvas::Wiki.ancestors.include?(Moodle2CC::CC::Wiki), 'does not inherit from base CC class'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_it_converts_pages
|
26
|
+
pages!
|
27
|
+
wiki = Moodle2CC::Canvas::Wiki.new @mod
|
28
|
+
assert_equal 2, wiki.pages.length
|
29
|
+
|
30
|
+
assert_equal 'My Wiki', wiki.pages[0].title
|
31
|
+
assert_equal 'Second version', wiki.pages[0].body
|
32
|
+
assert_equal 'wiki_content/my-wiki-my-wiki.html', wiki.pages[0].href
|
33
|
+
assert_equal 'i56eb35e2b44710c48f7aa6b6297e9c98', wiki.pages[0].identifier
|
34
|
+
|
35
|
+
assert_equal 'New Page', wiki.pages[1].title
|
36
|
+
assert_equal 'This is a link to <a href="%24WIKI_REFERENCE%24/wiki/my-wiki-my-wiki" title="My Wiki">My Wiki</a>', wiki.pages[1].body
|
37
|
+
assert_equal 'wiki_content/my-wiki-new-page.html', wiki.pages[1].href
|
38
|
+
assert_equal 'i56eb35e2b44710c48f7aa6b6297e9c98', wiki.pages[0].identifier
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
def test_it_creates_item_in_module_meta
|
43
|
+
wiki = Moodle2CC::Canvas::Wiki.new @mod
|
44
|
+
node = Builder::XmlMarkup.new
|
45
|
+
xml = Nokogiri::XML(wiki.create_module_meta_item_node(node, 5))
|
46
|
+
|
47
|
+
assert_equal 'item', xml.root.name
|
48
|
+
assert_equal 'i7b382ae83ddb7cc9be1a12e517088bc4', xml.root.attributes['identifier'].value
|
49
|
+
assert_equal "My Wiki", xml.root.xpath('title').text
|
50
|
+
assert_equal '5', xml.root.xpath('position').text
|
51
|
+
assert_equal '', xml.root.xpath('new_tab').text
|
52
|
+
assert_equal '0', xml.root.xpath('indent').text
|
53
|
+
assert_equal 'WikiPage', xml.root.xpath('content_type').text
|
54
|
+
assert_equal 'i56eb35e2b44710c48f7aa6b6297e9c98', xml.root.xpath('identifierref').text
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_it_creates_wiki_html
|
58
|
+
wiki = Moodle2CC::Canvas::Wiki.new @mod
|
59
|
+
tmp_dir = File.expand_path('../../../tmp', __FILE__)
|
60
|
+
wiki.create_html(tmp_dir)
|
61
|
+
|
62
|
+
html = Nokogiri::HTML(File.read(File.join(tmp_dir, 'wiki_content/my-wiki-my-wiki.html')))
|
63
|
+
assert html
|
64
|
+
assert_equal 'i56eb35e2b44710c48f7aa6b6297e9c98', html.search('meta[name="identifier"]').first.attributes['content'].value
|
65
|
+
assert_equal 'My Wiki', html.search('title').text
|
66
|
+
assert_equal 'Hello <a href="%24WIKI_REFERENCE%24/wiki/my-wiki-link" title="link">link</a>', html.search('body').inner_html.strip
|
67
|
+
|
68
|
+
html = Nokogiri::HTML(File.read(File.join(tmp_dir, 'wiki_content/my-wiki-link.html')))
|
69
|
+
assert html
|
70
|
+
assert_equal 'i13d1eba598141a33bd00dc38186d148a', html.search('meta[name="identifier"]').first.attributes['content'].value
|
71
|
+
assert_equal 'link', html.search('title').text
|
72
|
+
assert_equal 'This is a linked page', html.search('body').inner_html.strip
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'test/test_helper'
|
4
|
+
require 'moodle2cc'
|
5
|
+
|
6
|
+
class TestUnitCCAssessment < MiniTest::Unit::TestCase
|
7
|
+
include TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
convert_moodle_backup
|
11
|
+
@mod = @backup.course.mods.find { |m| m.mod_type == "quiz" }
|
12
|
+
@assessment = Moodle2CC::CC::Assessment.new @mod
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
clean_tmp_folder
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_it_converts_id
|
20
|
+
@mod.id = 321
|
21
|
+
assessment = Moodle2CC::CC::Assessment.new @mod
|
22
|
+
assert_equal 321, assessment.id
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_it_converts_title
|
26
|
+
@mod.name = "First Quiz"
|
27
|
+
assessment = Moodle2CC::CC::Assessment.new @mod
|
28
|
+
assert_equal "First Quiz", assessment.title
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_it_has_an_identifier
|
32
|
+
@mod.id = 321
|
33
|
+
assessment = Moodle2CC::CC::Assessment.new @mod
|
34
|
+
assert_equal 'i058d7533a77712b6e7757b34e66df7fc', assessment.identifier
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_it_creates_resource_in_imsmanifest
|
38
|
+
node = Builder::XmlMarkup.new
|
39
|
+
xml = node.root do |root_node|
|
40
|
+
@assessment.create_resource_node(node)
|
41
|
+
end
|
42
|
+
xml = Nokogiri::XML(xml)
|
43
|
+
|
44
|
+
resource = xml.root.xpath('resource[@type="imsqti_xmlv1p2/imscc_xmlv1p1/assessment"]').first
|
45
|
+
assert resource, 'assessment resource does not exist for assessment'
|
46
|
+
assert_equal 'i058d7533a77712b6e7757b34e66df7fc', resource.attributes['identifier'].value
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'test/test_helper'
|
4
|
+
require 'moodle2cc'
|
5
|
+
|
6
|
+
class TestUnitCCAssignment < MiniTest::Unit::TestCase
|
7
|
+
include TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
convert_moodle_backup
|
11
|
+
@mod = @backup.course.mods.find { |m| m.mod_type == "assignment" }
|
12
|
+
@workshop_mod = @backup.course.mods.find { |m| m.mod_type == "workshop" }
|
13
|
+
@assignment = Moodle2CC::CC::Assignment.new @mod
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
clean_tmp_folder
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_it_converts_id
|
21
|
+
@mod.id = 987
|
22
|
+
assignment = Moodle2CC::CC::Assignment.new @mod
|
23
|
+
assert_equal 987, assignment.id
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_it_converts_title
|
27
|
+
@mod.name = "Create a Rails site"
|
28
|
+
assignment = Moodle2CC::CC::Assignment.new @mod
|
29
|
+
assert_equal "Create a Rails site", assignment.title
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_it_converts_body
|
33
|
+
@mod.description = %(<h1>Hello World</h1><img src="$@FILEPHP@$$@SLASH@$folder$@SLASH@$stuff.jpg" />)
|
34
|
+
assignment = Moodle2CC::CC::Assignment.new @mod
|
35
|
+
assert_equal %(<h1>Hello World</h1><img src="$IMS_CC_FILEBASE$/folder/stuff.jpg" />), assignment.body
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_it_has_an_identifier
|
39
|
+
@mod.id = 987
|
40
|
+
assignment = Moodle2CC::CC::Assignment.new @mod
|
41
|
+
assert_equal 'i6b162484accdf6081cea43b39219d129', assignment.identifier
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_it_creates_resource_in_imsmanifest
|
45
|
+
node = Builder::XmlMarkup.new
|
46
|
+
xml = Nokogiri::XML(@assignment.create_resource_node(node))
|
47
|
+
|
48
|
+
resource = xml.xpath('resource').first
|
49
|
+
assert resource
|
50
|
+
assert_equal 'associatedcontent/imscc_xmlv1p1/learning-application-resource', resource.attributes['type'].value
|
51
|
+
assert_equal 'i6b162484accdf6081cea43b39219d129/create-a-rails-site.html', resource.attributes['href'].value
|
52
|
+
assert_equal 'i6b162484accdf6081cea43b39219d129', resource.attributes['identifier'].value
|
53
|
+
|
54
|
+
file = resource.xpath('file[@href="i6b162484accdf6081cea43b39219d129/create-a-rails-site.html"]').first
|
55
|
+
assert file
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_it_creates_assignment_html
|
59
|
+
tmp_dir = File.expand_path('../../../tmp', __FILE__)
|
60
|
+
@assignment.create_html(tmp_dir)
|
61
|
+
html = Nokogiri::HTML(File.read(File.join(tmp_dir, @assignment.identifier, 'create-a-rails-site.html')))
|
62
|
+
|
63
|
+
assert html
|
64
|
+
assert_equal 'Assignment: Create a Rails site', html.search('title').text
|
65
|
+
assert_equal '<h1>Hello World</h1>', html.search('body').inner_html.strip
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'test/test_helper'
|
3
|
+
require 'moodle2cc'
|
4
|
+
|
5
|
+
class TestUnitCCCCHelper < MiniTest::Unit::TestCase
|
6
|
+
include TestHelper
|
7
|
+
|
8
|
+
def test_it_creates_valid_file_names
|
9
|
+
assert_equal 'psy101-isnt-this-a-cool-course', Moodle2CC::CC::CCHelper.file_slug("PSY101 Isn't this a cool course?")
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_that_file_names_dont_end_with_a_period
|
13
|
+
assert_equal 'some-content', Moodle2CC::CC::CCHelper.file_slug('Some Content...')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_is_converts_file_path_tokens
|
17
|
+
assert_equal '$IMS_CC_FILEBASE$/folder/stuff.jpg', Moodle2CC::CC::CCHelper.convert_file_path_tokens('$@FILEPHP@$$@SLASH@$folder$@SLASH@$stuff.jpg')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'test/test_helper'
|
3
|
+
require 'moodle2cc'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
class TestUnitCCConverter < MiniTest::Unit::TestCase
|
7
|
+
include TestHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
convert_moodle_backup
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
clean_tmp_folder
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_it_has_the_path_to_the_imscc_package
|
18
|
+
assert_equal File.expand_path("../../../tmp/my-course.imscc", __FILE__), @converter.imscc_path
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_it_creates_imscc_package
|
22
|
+
assert File.exists?(@converter.imscc_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_it_creates_imsmanifest_xml
|
26
|
+
Zip::ZipFile.open(@converter.imscc_path) do |zipfile|
|
27
|
+
assert zipfile.find_entry("imsmanifest.xml")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_imsmanifest_has_manifest_root
|
32
|
+
xml = get_imsmanifest_xml
|
33
|
+
assert_equal "manifest", xml.root.name
|
34
|
+
assert_equal "i24f498fba015133ae97c6e6693a32b4d", xml.root.attributes['identifier'].value
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_imsmanifest_has_proper_namespaces
|
38
|
+
xml = get_imsmanifest_xml
|
39
|
+
assert_equal "http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1 http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imscp_v1p2_v1p0.xsd http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lomresource_v1p0.xsd http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest http://www.imsglobal.org/profile/cc/ccv1p1/LOM/ccv1p1_lommanifest_v1p0.xsd", xml.root.attributes['schemaLocation'].value
|
40
|
+
assert_equal "http://ltsc.ieee.org/xsd/imsccv1p1/LOM/resource", xml.namespaces['xmlns:lom']
|
41
|
+
assert_equal "http://ltsc.ieee.org/xsd/imsccv1p1/LOM/manifest", xml.namespaces['xmlns:lomimscc']
|
42
|
+
assert_equal "http://www.w3.org/2001/XMLSchema-instance", xml.namespaces['xmlns:xsi']
|
43
|
+
assert_equal "http://www.imsglobal.org/xsd/imsccv1p1/imscp_v1p1", xml.namespaces['xmlns']
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_imsmanifest_has_a_schema
|
47
|
+
xml = get_imsmanifest_xml
|
48
|
+
assert_equal "IMS Common Cartridge", xml.xpath('//xmlns:manifest/xmlns:metadata/xmlns:schema').text
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_imsmanifest_has_a_schemaversion
|
52
|
+
xml = get_imsmanifest_xml
|
53
|
+
assert_equal "1.1.0", xml.xpath('//xmlns:manifest/xmlns:metadata/xmlns:schemaversion').text
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_imsmanifest_has_the_course_fullname
|
57
|
+
xml = get_imsmanifest_xml
|
58
|
+
assert_equal "My Course", xml.xpath('//xmlns:manifest/xmlns:metadata/lomimscc:lom/lomimscc:general/lomimscc:title/lomimscc:string').text
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_imsmanifest_has_the_current_date
|
62
|
+
xml = get_imsmanifest_xml
|
63
|
+
now = Time.now.utc
|
64
|
+
assert_equal now.strftime("%Y-%m-%d"), xml.xpath('//xmlns:manifest/xmlns:metadata/lomimscc:lom/lomimscc:lifeCycle/lomimscc:contribute/lomimscc:date/lomimscc:dateTime').text
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_imsmanifest_has_the_copyright_restriction
|
68
|
+
xml = get_imsmanifest_xml
|
69
|
+
assert_equal "yes", xml.xpath('//xmlns:manifest/xmlns:metadata/lomimscc:lom/lomimscc:rights/lomimscc:copyrightAndOtherRestrictions/lomimscc:value').text
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_imsmanifest_has_the_copyright_description
|
73
|
+
xml = get_imsmanifest_xml
|
74
|
+
assert_equal 'Private (Copyrighted) - http://en.wikipedia.org/wiki/Copyright', xml.xpath('//xmlns:manifest/xmlns:metadata/lomimscc:lom/lomimscc:rights/lomimscc:description/lomimscc:string').text
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_imsmanifest_has_an_organization
|
78
|
+
xml = get_imsmanifest_xml
|
79
|
+
|
80
|
+
organization = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization').first
|
81
|
+
assert organization
|
82
|
+
assert_equal 'org_1', organization.attributes['identifier'].value
|
83
|
+
assert_equal 'rooted-hierarchy', organization.attributes['structure'].value
|
84
|
+
|
85
|
+
item = organization.xpath('xmlns:item').first
|
86
|
+
assert item
|
87
|
+
assert 'LearningModules', item.attributes['identifier'].value
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_imsmanifest_has_items_under_organization
|
91
|
+
xml = get_imsmanifest_xml
|
92
|
+
|
93
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[1]').first
|
94
|
+
assert item
|
95
|
+
assert_equal "iebbd12be3d1d1ba16e241599099c4795", item.attributes['identifier'].value
|
96
|
+
assert_equal 'Week 0', item.xpath('xmlns:title').text
|
97
|
+
|
98
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[2]').first
|
99
|
+
assert item
|
100
|
+
assert_equal "i84cbfb8e81c780e847d0087e024dd2f2", item.attributes['identifier'].value
|
101
|
+
assert_equal 'Week 1', item.xpath('xmlns:title').text
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_imsmanifest_does_not_create_item_for_invisible_sections
|
105
|
+
xml = get_imsmanifest_xml
|
106
|
+
|
107
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[@identifier="i9a57aafbbb5993c28a89c2e363e97f87"]').first
|
108
|
+
refute item, 'invisible section has item node'
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_imsmanifest_has_sub_items
|
112
|
+
xml = get_imsmanifest_xml
|
113
|
+
|
114
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[1]/xmlns:item[1]').first
|
115
|
+
assert item
|
116
|
+
assert_equal "i10241816e5909d8e76da003b2814c6a4", item.attributes['identifier'].value
|
117
|
+
assert_equal "i6b162484accdf6081cea43b39219d129", item.attributes['identifierref'].value
|
118
|
+
assert_equal 'Create a Rails site', 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
|
122
|
+
assert_equal "i966437b815a49aad86a356bc8aa8f24a", item.attributes['identifier'].value
|
123
|
+
assert_equal "i15aaccec404aa2ad557108a689bbba8f", item.attributes['identifierref'].value
|
124
|
+
assert_equal 'About Your Instructor', item.xpath('xmlns:title').text
|
125
|
+
|
126
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[2]/xmlns:item[1]').first
|
127
|
+
assert item
|
128
|
+
assert_equal "ie8e11ad7a1b32660f6aeaf94948faa22", item.attributes['identifier'].value
|
129
|
+
assert_equal "if7091ac80f57e45c757345555327b248", item.attributes['identifierref'].value
|
130
|
+
assert_equal 'Announcements', item.xpath('xmlns:title').text
|
131
|
+
|
132
|
+
item = xml.xpath('//xmlns:manifest/xmlns:organizations/xmlns:organization/xmlns:item/xmlns:item[2]/xmlns:item[2]').first
|
133
|
+
assert item
|
134
|
+
assert_equal "ifcf0624ce811c812c749c53f3c914f20", item.attributes['identifier'].value
|
135
|
+
assert_equal "iddbfacadb16c78a584f81538cd53cc72", item.attributes['identifierref'].value
|
136
|
+
assert_equal 'label123', item.xpath('xmlns:title').text
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_imsmanifest_has_file_resources
|
140
|
+
xml = get_imsmanifest_xml
|
141
|
+
|
142
|
+
resource = xml.xpath('//xmlns:manifest/xmlns:resources/xmlns:resource[@identifier="i2fbc9b5ef920655b8240824d3d7b677a"]').first
|
143
|
+
assert resource, 'resources does not exist for "web_resources/folder/test.txt" file'
|
144
|
+
assert_equal 'webcontent', resource.attributes['type'].value
|
145
|
+
assert_equal 'web_resources/folder/test.txt', resource.attributes['href'].value
|
146
|
+
assert resource.xpath('xmlns:file[@href="web_resources/folder/test.txt"]').first
|
147
|
+
|
148
|
+
resource = xml.xpath('//xmlns:manifest/xmlns:resources/xmlns:resource[@identifier="ib98bb8ec201a97840ae4ed4bb40207c0"]').first
|
149
|
+
assert resource, 'resources does not exist for "web_resources/test.txt" file'
|
150
|
+
assert_equal 'webcontent', resource.attributes['type'].value
|
151
|
+
assert_equal 'web_resources/test.txt', resource.attributes['href'].value
|
152
|
+
assert resource.xpath('xmlns:file[@href="web_resources/test.txt"]').first
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_it_deletes_all_files_except_imscc
|
156
|
+
refute File.exists? @converter.imscc_tmp_path
|
157
|
+
assert File.exists? @converter.imscc_path
|
158
|
+
end
|
159
|
+
end
|