cc2html 0.0.1
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/Gemfile +4 -0
- data/Gemfile.lock +69 -0
- data/Guardfile +10 -0
- data/LICENSE +18 -0
- data/README.md +45 -0
- data/Rakefile +12 -0
- data/bin/cc2html +6 -0
- data/cc2html.gemspec +31 -0
- data/lib/cc2html/builder.rb +15 -0
- data/lib/cc2html/cli.rb +15 -0
- data/lib/cc2html/converter.rb +21 -0
- data/lib/cc2html/epub_builder.rb +96 -0
- data/lib/cc2html/html_builder.rb +23 -0
- data/lib/cc2html/templates/epub/chapter.html.erb +54 -0
- data/lib/cc2html/templates/epub/descriptor.opf.erb +21 -0
- data/lib/cc2html/templates/epub/navigation.html.erb +11 -0
- data/lib/cc2html/templates/html/assignment.html.erb +13 -0
- data/lib/cc2html/templates/html/index.html.erb +13 -0
- data/lib/cc2html/templates/html/wiki_content.html.erb +10 -0
- data/lib/cc2html/version.rb +3 -0
- data/lib/cc2html.rb +10 -0
- data/lib/ims/cc/assignment.rb +37 -0
- data/lib/ims/cc/cc.rb +16 -0
- data/lib/ims/cc/lom.rb +65 -0
- data/lib/ims/cc/manifest.rb +59 -0
- data/lib/ims/cc/metadata.rb +10 -0
- data/lib/ims/cc/organizations.rb +37 -0
- data/lib/ims/cc/resources.rb +71 -0
- data/lib/ims/cc/topic.rb +14 -0
- data/lib/ims/cc/web_link.rb +11 -0
- data/lib/ims/cc.rb +19 -0
- data/lib/ims.rb +2 -0
- data/test/fixtures/cc_full_test.zip +0 -0
- data/test/fixtures/flat_imsmanifest.xml +134 -0
- data/test/unit/cc/assignment_test.rb +42 -0
- data/test/unit/cc/cc_test_helper.rb +8 -0
- data/test/unit/cc/manifest_metadata_test.rb +27 -0
- data/test/unit/cc/manifest_test.rb +8 -0
- data/test/unit/cc/organizations_test.rb +38 -0
- data/test/unit/cc/resources_test.rb +50 -0
- data/test/unit/cc/topic_test.rb +38 -0
- data/test/unit/cc/web_link_test.rb +35 -0
- metadata +277 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
module IMS::CC
|
2
|
+
class Manifest
|
3
|
+
include HappyMapper
|
4
|
+
|
5
|
+
attr_accessor :cartridge_zip_file, :manifest_file
|
6
|
+
|
7
|
+
tag 'manifest'
|
8
|
+
has_one :metadata, Metadata
|
9
|
+
has_one :organizations, IMS::CC::Organizations::Organizations
|
10
|
+
has_one :resources, IMS::CC::Resources::Resources
|
11
|
+
|
12
|
+
def self.read(backup_file)
|
13
|
+
if File.extname(backup_file) == ".xml"
|
14
|
+
manifest = parse File.read(backup_file)
|
15
|
+
manifest.manifest_file = backup_file
|
16
|
+
manifest.post_process
|
17
|
+
manifest
|
18
|
+
else
|
19
|
+
Zip::File.open(backup_file) do |zipfile|
|
20
|
+
entry = zipfile.get_entry("imsmanifest.xml")
|
21
|
+
xml = entry.get_input_stream.read
|
22
|
+
manifest = parse xml
|
23
|
+
manifest.cartridge_zip_file = backup_file
|
24
|
+
manifest.post_process
|
25
|
+
manifest
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def post_process
|
31
|
+
parse_references
|
32
|
+
connect_resources_to_org_item
|
33
|
+
end
|
34
|
+
|
35
|
+
def connect_resources_to_org_item
|
36
|
+
self.organizations.organization.item.items.each do |item|
|
37
|
+
next unless item.identifierref
|
38
|
+
if res = self.resources.find_by_identifier(item.identifierref)
|
39
|
+
item.resource = res
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def parse_references
|
45
|
+
if self.cartridge_zip_file
|
46
|
+
Zip::File.open(self.cartridge_zip_file) do |zipfile|
|
47
|
+
self.resources.resources.each do |res|
|
48
|
+
if res.parseable_type? && !res.inline?
|
49
|
+
entry = zipfile.get_entry(res.reference_href)
|
50
|
+
xml = entry.get_input_stream.read
|
51
|
+
res.parse_reference(xml)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module IMS::CC
|
2
|
+
module Organizations
|
3
|
+
|
4
|
+
class Item
|
5
|
+
include HappyMapper
|
6
|
+
tag 'item'
|
7
|
+
attr_accessor :resource
|
8
|
+
|
9
|
+
attribute :identifier, String
|
10
|
+
attribute :identifierref, String
|
11
|
+
element :title, String
|
12
|
+
|
13
|
+
has_many :items, Item
|
14
|
+
end
|
15
|
+
|
16
|
+
class Organization
|
17
|
+
include HappyMapper
|
18
|
+
tag 'organization'
|
19
|
+
|
20
|
+
attribute :identifier, String
|
21
|
+
attribute :structure, String
|
22
|
+
has_one :item, Item
|
23
|
+
end
|
24
|
+
|
25
|
+
class Organizations
|
26
|
+
include HappyMapper
|
27
|
+
tag 'organizations'
|
28
|
+
|
29
|
+
has_one :organization, Organization
|
30
|
+
|
31
|
+
def find_item_by_identifier(id)
|
32
|
+
self.organization.item.items.find{|i| i.identifier == id}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module IMS::CC
|
2
|
+
module Resources
|
3
|
+
|
4
|
+
class File
|
5
|
+
include HappyMapper
|
6
|
+
tag 'file'
|
7
|
+
|
8
|
+
attribute :href, String
|
9
|
+
end
|
10
|
+
|
11
|
+
class Dependency
|
12
|
+
include HappyMapper
|
13
|
+
tag 'dependency'
|
14
|
+
|
15
|
+
attribute :identifierref, String
|
16
|
+
end
|
17
|
+
|
18
|
+
class Resource
|
19
|
+
PARSABLE_TYPES = /imsdt|imswl|assignment/
|
20
|
+
include HappyMapper
|
21
|
+
tag 'resource'
|
22
|
+
|
23
|
+
attribute :identifier, String
|
24
|
+
attribute :type, String
|
25
|
+
attribute :href, String
|
26
|
+
attribute :intendeduse, String
|
27
|
+
|
28
|
+
has_many :files, File
|
29
|
+
has_many :dependencies, Dependency
|
30
|
+
has_one :topic, IMS::CC::Topic
|
31
|
+
has_one :web_link, IMS::CC::WebLink
|
32
|
+
has_one :assignment, IMS::CC::Assignment::Assignment
|
33
|
+
|
34
|
+
def inline?
|
35
|
+
!!(self.files.count == 0 && (self.topic || self.web_link))
|
36
|
+
end
|
37
|
+
|
38
|
+
def parseable_type?
|
39
|
+
!!(self.type =~ PARSABLE_TYPES)
|
40
|
+
end
|
41
|
+
|
42
|
+
def reference_href
|
43
|
+
return if inline?
|
44
|
+
self.files.first.href
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse_reference(xml)
|
48
|
+
case self.type
|
49
|
+
when /imsdt/
|
50
|
+
self.topic = IMS::CC::Topic.parse(xml)
|
51
|
+
when /imswl/
|
52
|
+
self.web_link = IMS::CC::WebLink.parse(xml)
|
53
|
+
when /assignment/
|
54
|
+
self.assignment = IMS::CC::Assignment::Assignment.parse(xml)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Resources
|
60
|
+
include HappyMapper
|
61
|
+
tag 'resources'
|
62
|
+
|
63
|
+
has_many :resources, Resource
|
64
|
+
|
65
|
+
def find_by_identifier(id)
|
66
|
+
resources.find {|r|r.identifier == id}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
data/lib/ims/cc/topic.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module IMS::CC
|
2
|
+
class Topic
|
3
|
+
include HappyMapper
|
4
|
+
#register_namespace('http://www.imsglobal.org/xsd/imsccv1p3/imsdt_v1p3', 'dt3')
|
5
|
+
#register_namespace('http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1', 'dt1')
|
6
|
+
namespace 'http://www.imsglobal.org/xsd/imsccv1p3/imsdt_v1p3'
|
7
|
+
#namespace 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1'
|
8
|
+
|
9
|
+
tag 'topic'
|
10
|
+
element :title, String
|
11
|
+
element :text, String, :attributes => {:texttype => String}
|
12
|
+
has_one :attachments, IMS::CC::Attachments
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module IMS::CC
|
2
|
+
class WebLink
|
3
|
+
include HappyMapper
|
4
|
+
namespace 'http://www.imsglobal.org/xsd/imsccv1p3/imswl_v1p3'
|
5
|
+
#namespace 'http://www.imsglobal.org/xsd/imsccv1p1/imsdt_v1p1'
|
6
|
+
|
7
|
+
tag 'webLink'
|
8
|
+
element :title, String
|
9
|
+
element :url, String, :attributes => {href: String, target: String, windoFeatures: String}
|
10
|
+
end
|
11
|
+
end
|
data/lib/ims/cc.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#require 'builder'
|
2
|
+
require 'happymapper'
|
3
|
+
require 'zip'
|
4
|
+
|
5
|
+
require 'ims'
|
6
|
+
|
7
|
+
module IMS::CC
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'ims/cc/cc'
|
11
|
+
require 'ims/cc/lom'
|
12
|
+
require 'ims/cc/topic'
|
13
|
+
require 'ims/cc/web_link'
|
14
|
+
require 'ims/cc/assignment'
|
15
|
+
require 'ims/cc/metadata'
|
16
|
+
require 'ims/cc/resources'
|
17
|
+
require 'ims/cc/organizations'
|
18
|
+
require 'ims/cc/manifest'
|
19
|
+
|
data/lib/ims.rb
ADDED
Binary file
|
@@ -0,0 +1,134 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<manifest identifier="cctd0001"
|
3
|
+
xmlns="http://www.imsglobal.org/xsd/imsccv1p3/imscp_v1p1"
|
4
|
+
xmlns:lom="http://ltsc.ieee.org/xsd/imsccv1p3/LOM/resource"
|
5
|
+
xmlns:lomimscc="http://ltsc.ieee.org/xsd/imsccv1p3/LOM/manifest"
|
6
|
+
xmlns:cpx="http://www.imsglobal.org/xsd/imsccv1p3/imscp_extensionv1p2"
|
7
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
8
|
+
xsi:schemaLocation="http://ltsc.ieee.org/xsd/imsccv1p3/LOM/resource http://www.imsglobal.org/profile/cc/ccv1p3/LOM/ccv1p3_lomresource_v1p0.xsd
|
9
|
+
http://www.imsglobal.org/xsd/imsccv1p3/imscp_v1p1 http://www.imsglobal.org/profile/cc/ccv1p3/ccv1p3_imscp_v1p2_v1p0.xsd
|
10
|
+
http://ltsc.ieee.org/xsd/imsccv1p3/LOM/manifest http://www.imsglobal.org/profile/cc/ccv1p3/LOM/ccv1p3_lommanifest_v1p0.xsd
|
11
|
+
http://www.imsglobal.org/xsd/imsccv1p3/imscp_extensionv1p2 http://www.imsglobal.org/profile/cc/ccv1p3/ccv1p3_cpextensionv1p2_v1p0.xsd">
|
12
|
+
<metadata>
|
13
|
+
<schema>IMS Common Cartridge</schema>
|
14
|
+
<schemaversion>1.3.0</schemaversion>
|
15
|
+
<lomimscc:lom>
|
16
|
+
<lomimscc:general>
|
17
|
+
<lomimscc:title>
|
18
|
+
<lomimscc:string language="en-US">Common Cartridge Test</lomimscc:string>
|
19
|
+
</lomimscc:title>
|
20
|
+
<lomimscc:description>
|
21
|
+
<lomimscc:string language="en-US">CC 1.3 test with extension</lomimscc:string>
|
22
|
+
</lomimscc:description>
|
23
|
+
<lomimscc:keyword>
|
24
|
+
<lomimscc:string language="en-US">Sample</lomimscc:string>
|
25
|
+
</lomimscc:keyword>
|
26
|
+
<lomimscc:keyword>
|
27
|
+
<lomimscc:string language="en-US">Sample2</lomimscc:string>
|
28
|
+
</lomimscc:keyword>
|
29
|
+
</lomimscc:general>
|
30
|
+
<lomimscc:lifeCycle>
|
31
|
+
<lomimscc:contribute>
|
32
|
+
<lomimscc:date>
|
33
|
+
<lomimscc:dateTime>2012-06-07</lomimscc:dateTime>
|
34
|
+
</lomimscc:date>
|
35
|
+
</lomimscc:contribute>
|
36
|
+
</lomimscc:lifeCycle>
|
37
|
+
<lomimscc:rights>
|
38
|
+
<lomimscc:copyrightAndOtherRestrictions>
|
39
|
+
<lomimscc:value>yes</lomimscc:value>
|
40
|
+
</lomimscc:copyrightAndOtherRestrictions>
|
41
|
+
<lomimscc:description>
|
42
|
+
<lomimscc:string>Private (Copyrighted) - http://en.wikipedia.org/wiki/Copyright</lomimscc:string>
|
43
|
+
</lomimscc:description>
|
44
|
+
</lomimscc:rights>
|
45
|
+
</lomimscc:lom>
|
46
|
+
</metadata>
|
47
|
+
|
48
|
+
<organizations>
|
49
|
+
<organization identifier="O_1" structure="rooted-hierarchy">
|
50
|
+
<item identifier="I_1">
|
51
|
+
<item identifier="I_00000">
|
52
|
+
<title>CCv1.3 With Assignment</title>
|
53
|
+
<item identifier="I_00001" identifierref="Resource1">
|
54
|
+
<title>Cool Assignment</title>
|
55
|
+
</item>
|
56
|
+
<item identifier="I_00002" identifierref="Resource2">
|
57
|
+
<title>Assignment Discussions</title>
|
58
|
+
</item>
|
59
|
+
<item identifier="I_00003" identifierref="Resource3">
|
60
|
+
<title>Open2.net</title>
|
61
|
+
</item>
|
62
|
+
<item identifier="I_00004" identifierref="Resource4">
|
63
|
+
<title>LTI Launch</title>
|
64
|
+
</item>
|
65
|
+
</item>
|
66
|
+
</item>
|
67
|
+
</organization>
|
68
|
+
</organizations>
|
69
|
+
|
70
|
+
<resources>
|
71
|
+
|
72
|
+
<resource identifier="Resource1" type="assignment_xmlv1p0" intendeduse="assignment">
|
73
|
+
<lomimscc:lom>
|
74
|
+
<lomimscc:rights>
|
75
|
+
<lomimscc:copyrightAndOtherRestrictions>
|
76
|
+
<lomimscc:value>yes</lomimscc:value>
|
77
|
+
</lomimscc:copyrightAndOtherRestrictions>
|
78
|
+
<lomimscc:description>
|
79
|
+
<lomimscc:string>Private (Copyrighted) - http://en.wikipedia.org/wiki/Copyright</lomimscc:string>
|
80
|
+
</lomimscc:description>
|
81
|
+
</lomimscc:rights>
|
82
|
+
</lomimscc:lom>
|
83
|
+
<assignment xmlns="http://www.imsglobal.org/xsd/imscc_extensions/assignment"
|
84
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
85
|
+
xsi:schemaLocation="http://www.imsglobal.org/xsd/imscc_extensions/assignment http://www.imsglobal.org/profile/cc/cc_extensions/cc_extresource_assignmentv1p0_v1p0.xsd http://www.imsglobal.org/xsd/imscc_extensions/assignment ">
|
86
|
+
<title>Cool Assignment</title>
|
87
|
+
<text texttype="text/html">You should turn this in for points. <b>html!</b></text>
|
88
|
+
<instructor_text texttype="text/plain">Super Secret</instructor_text>
|
89
|
+
<gradable>true</gradable>
|
90
|
+
<submission_formats>
|
91
|
+
<format type="file"/>
|
92
|
+
<format type="text"/>
|
93
|
+
</submission_formats>
|
94
|
+
</assignment>
|
95
|
+
</resource>
|
96
|
+
|
97
|
+
<resource identifier="Resource2" type="imsdt_xmlv1p3">
|
98
|
+
<topic xmlns="http://www.imsglobal.org/xsd/imsccv1p3/imsdt_v1p3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsccv1p3/imsdt_v1p3 http://www.imsglobal.org/profile/cc/ccv1p3/ccv1p3_imsdt_v1p3.xsd">
|
99
|
+
<title>Assignment Discussions</title>
|
100
|
+
<text texttype="text/html">Discuss your results from the first assignment.</text>
|
101
|
+
<attachments>
|
102
|
+
<attachment href="test1.jpg" />
|
103
|
+
<attachment href="test2.gif" />
|
104
|
+
</attachments>
|
105
|
+
</topic>
|
106
|
+
</resource>
|
107
|
+
|
108
|
+
<resource identifier="Resource3" type="imswl_xmlv1p3">
|
109
|
+
<webLink xmlns="http://www.imsglobal.org/xsd/imsccv1p3/imswl_v1p3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsccv1p3/imswl_v1p3 http://www.imsglobal.org/profile/cc/ccv1p3/ccv1p3_imswl_v1p3.xsd">
|
110
|
+
<title>Open2.net: Science and Nature</title>
|
111
|
+
<url href="http://www.open2.net/sciencetechnologynature/"/>
|
112
|
+
</webLink>
|
113
|
+
</resource>
|
114
|
+
|
115
|
+
<resource identifier="Resource4" type="imsbasiclti_xmlv1p3">
|
116
|
+
<cartridge_basiclti_link
|
117
|
+
xmlns="http://www.imsglobal.org/xsd/imslticc_v1p0"
|
118
|
+
xmlns:blti="http://www.imsglobal.org/xsd/imsbasiclti_v1p0"
|
119
|
+
xmlns:lticm="http://www.imsglobal.org/xsd/imslticm_v1p0"
|
120
|
+
xmlns:lticp="http://www.imsglobal.org/xsd/imslticp_v1p0"
|
121
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.imsglobal.org/xsd/imslticc_v1p3 http://www.imsglobal.org/xsd/lti/ltiv1p1/imslticc_v1p1.xsd http://www.imsglobal.org/xsd/imslticp_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticp_v1p0.xsd http://www.imsglobal.org/xsd/imslticm_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imslticm_v1p0.xsd http://www.imsglobal.org/xsd/imsbasiclti_v1p0 http://www.imsglobal.org/xsd/lti/ltiv1p0/imsbasiclti_v1p0p1.xsd">
|
122
|
+
<blti:title>BLTI Test</blti:title>
|
123
|
+
<blti:description>Test a BLTI Link</blti:description>
|
124
|
+
<blti:launch_url>http://www.imsglobal.org/developers/BLTI/tool.php</blti:launch_url>
|
125
|
+
<blti:secure_launch_url>http://www.imsglobal.org/developers/BLTI/tool.php</blti:secure_launch_url>
|
126
|
+
</cartridge_basiclti_link>
|
127
|
+
</resource>
|
128
|
+
|
129
|
+
<resource identifier="Resource5" type="imsdt_xmlv1p3">
|
130
|
+
<dependency identifierref="Resource2"/>
|
131
|
+
</resource>
|
132
|
+
|
133
|
+
</resources>
|
134
|
+
</manifest>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'cc_test_helper'
|
2
|
+
|
3
|
+
class TestUnitAssignment < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::FLAT_MANIFEST_PATH
|
7
|
+
@resources = manifest.resources
|
8
|
+
@assignment = @resources.find_by_identifier("Resource1").assignment
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_it_gets_assignment_data
|
12
|
+
assert_instance_of IMS::CC::Assignment::Assignment, @assignment
|
13
|
+
assert_equal 'Cool Assignment', @assignment.title
|
14
|
+
assert_equal 'You should turn this in for points. <b>html!</b>', @assignment.text
|
15
|
+
assert_equal 'text/html', @assignment.text.texttype
|
16
|
+
assert_equal 'Super Secret', @assignment.instructor_text
|
17
|
+
assert_equal 'text/plain', @assignment.instructor_text.texttype
|
18
|
+
assert_equal true, @assignment.gradable
|
19
|
+
assert_equal ['file', 'text'], @assignment.submission_formats
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class TestUnitZippedAssignment < Minitest::Test
|
24
|
+
def setup
|
25
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::CARTRIDGE_PATH
|
26
|
+
@resources = manifest.resources
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_it_parses_reference
|
30
|
+
@assignment = @resources.find_by_identifier("I_00012_R").assignment
|
31
|
+
assert_instance_of IMS::CC::Assignment::Assignment, @assignment
|
32
|
+
assert_equal 2, @assignment.attachments.attachments.count
|
33
|
+
assert_equal '../I_00006_Media/angry_person.jpg', @assignment.attachments.attachments[0].href
|
34
|
+
assert_equal 'Learner', @assignment.attachments.attachments[0].role
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_it_parses_reference2
|
38
|
+
@assignment_resource = @resources.find_by_identifier("I_00013_R")
|
39
|
+
assert_instance_of IMS::CC::Assignment::Assignment, @assignment_resource.assignment
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'ims/cc'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module CCTestHelper
|
6
|
+
CARTRIDGE_PATH = File.expand_path("../../../fixtures/cc_full_test.zip", __FILE__)
|
7
|
+
FLAT_MANIFEST_PATH = File.expand_path("../../../fixtures/flat_imsmanifest.xml", __FILE__)
|
8
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'cc_test_helper'
|
2
|
+
|
3
|
+
class TestUnitMetadata < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::FLAT_MANIFEST_PATH
|
7
|
+
@meta = manifest.metadata
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_it_has_default_namespace_data
|
11
|
+
assert_equal @meta.schema, 'IMS Common Cartridge'
|
12
|
+
assert_equal @meta.schemaversion, '1.3.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_it_gets_general_lom
|
16
|
+
assert_instance_of IMS::CC::Lom::Lom, @meta.lom
|
17
|
+
assert_instance_of IMS::CC::Lom::General, @meta.lom.general
|
18
|
+
assert_instance_of IMS::CC::Lom::Title, @meta.lom.general.title
|
19
|
+
assert_instance_of IMS::CC::Lom::Description, @meta.lom.general.description
|
20
|
+
assert_equal "Common Cartridge Test", @meta.lom.general.title.title
|
21
|
+
assert_equal "CC 1.3 test with extension", @meta.lom.general.description.description
|
22
|
+
assert_equal ['Sample', 'Sample2'], @meta.lom.general.keywords.map(&:keyword)
|
23
|
+
assert_equal 'yes', @meta.lom.rights.copyrightAndOtherRestrictions.value
|
24
|
+
assert_equal 'Private (Copyrighted) - http://en.wikipedia.org/wiki/Copyright', @meta.lom.rights.description.description
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'cc_test_helper'
|
2
|
+
|
3
|
+
class TestUnitOrganizations < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::FLAT_MANIFEST_PATH
|
7
|
+
@orgs = manifest.organizations
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_it_gets_organizations
|
11
|
+
assert_instance_of IMS::CC::Organizations::Organizations, @orgs
|
12
|
+
assert_instance_of IMS::CC::Organizations::Organization, @orgs.organization
|
13
|
+
assert_equal 'O_1', @orgs.organization.identifier
|
14
|
+
assert_equal 'rooted-hierarchy', @orgs.organization.structure
|
15
|
+
end
|
16
|
+
|
17
|
+
# have to figure out why happy mapper gets all items instead of just 1st children
|
18
|
+
#def test_it_creates_item_tree
|
19
|
+
# assert_equal 1, @orgs.organization.item.items.count
|
20
|
+
# assert_equal 4, @orgs.organization.item.items[0].count
|
21
|
+
#end
|
22
|
+
|
23
|
+
def test_gets_item_info
|
24
|
+
assert_equal "I_00000", @orgs.organization.item.items[0].identifier
|
25
|
+
assert_equal "CCv1.3 With Assignment", @orgs.organization.item.items[0].title
|
26
|
+
assert_equal '', @orgs.organization.item.items[0].identifierref
|
27
|
+
|
28
|
+
assert_equal "I_00001", @orgs.organization.item.items[1].identifier
|
29
|
+
assert_equal "Cool Assignment", @orgs.organization.item.items[1].title
|
30
|
+
assert_equal "Resource1", @orgs.organization.item.items[1].identifierref
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_item_references_resource
|
34
|
+
item = @orgs.find_item_by_identifier('I_00001')
|
35
|
+
assert_equal 'Resource1', item.resource.identifier
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative 'cc_test_helper'
|
2
|
+
|
3
|
+
class TestUnitResources < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::FLAT_MANIFEST_PATH
|
7
|
+
@resources = manifest.resources
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_it_gets_resources
|
11
|
+
assert_instance_of IMS::CC::Resources::Resources, @resources
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_gets_resource_info
|
15
|
+
assert_instance_of IMS::CC::Resources::Resource, @resources.resources[0]
|
16
|
+
assert_equal 'Resource1', @resources.resources[0].identifier
|
17
|
+
assert_equal 'assignment_xmlv1p0', @resources.resources[0].type
|
18
|
+
assert_equal 'assignment', @resources.resources[0].intendeduse
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_gets_dependency_info
|
22
|
+
assert_equal 'Resource2', @resources.resources.last.dependencies[0].identifierref
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_it_recognizes_inline
|
26
|
+
assert_equal true, @resources.resources[1].inline?
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
class TestUnitZippedResources < Minitest::Test
|
32
|
+
def setup
|
33
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::CARTRIDGE_PATH
|
34
|
+
@resources = manifest.resources
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_it_gets_resources
|
38
|
+
assert_instance_of IMS::CC::Resources::Resources, @resources
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_gets_file_info
|
42
|
+
assert_equal 3, @resources.resources.find{|r|r.identifier == 'f5'}.files.count
|
43
|
+
assert_equal 'I_00001_R/Learning_Objectives.html', @resources.resources[0].files[0].href
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_it_recognizes_not_inline
|
47
|
+
@topic_resource = @resources.resources.find{|r|r.identifier == 'I_00006_R'}
|
48
|
+
assert_equal false, @topic_resource.inline?
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'cc_test_helper'
|
2
|
+
|
3
|
+
class TestUnitTopic < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::FLAT_MANIFEST_PATH
|
7
|
+
@resources = manifest.resources
|
8
|
+
@topic = @resources.resources[1].topic
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_it_gets_topic_data
|
12
|
+
assert_instance_of IMS::CC::Topic, @topic
|
13
|
+
assert_equal 'Assignment Discussions', @topic.title
|
14
|
+
assert_equal 'Discuss your results from the first assignment.', @topic.text
|
15
|
+
assert_equal 'text/html', @topic.text.texttype
|
16
|
+
assert_equal 2, @topic.attachments.attachments.count
|
17
|
+
assert_equal 'test1.jpg', @topic.attachments.attachments[0].href
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class TestUnitZippedTopics < Minitest::Test
|
23
|
+
def setup
|
24
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::CARTRIDGE_PATH
|
25
|
+
@resources = manifest.resources
|
26
|
+
@topic_resource = @resources.resources.find{|r|r.identifier == 'I_00006_R'}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_it_parses_reference
|
30
|
+
assert_instance_of IMS::CC::Topic, @topic_resource.topic
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_it_parses_reference2
|
34
|
+
@topic_resource = @resources.resources.find{|r|r.identifier == 'I_00009_R'}
|
35
|
+
assert_instance_of IMS::CC::Topic, @topic_resource.topic
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'cc_test_helper'
|
2
|
+
|
3
|
+
class TestUnitWebLink < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::FLAT_MANIFEST_PATH
|
7
|
+
@resources = manifest.resources
|
8
|
+
@weblink = @resources.find_by_identifier("Resource3").web_link
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_it_gets_weblink_data
|
12
|
+
assert_instance_of IMS::CC::WebLink, @weblink
|
13
|
+
assert_equal 'Open2.net: Science and Nature', @weblink.title
|
14
|
+
assert_equal 'http://www.open2.net/sciencetechnologynature/', @weblink.url.href
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
class TestUnitZippedWebLinks < Minitest::Test
|
20
|
+
def setup
|
21
|
+
manifest = IMS::CC::Manifest.read CCTestHelper::CARTRIDGE_PATH
|
22
|
+
@resources = manifest.resources
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_it_parses_reference
|
26
|
+
@weblink_resource = @resources.find_by_identifier("I_00005_R")
|
27
|
+
assert_instance_of IMS::CC::WebLink, @weblink_resource.web_link
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_it_parses_reference2
|
31
|
+
@weblink_resource = @resources.find_by_identifier("I_00007_R")
|
32
|
+
assert_instance_of IMS::CC::WebLink, @weblink_resource.web_link
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|