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.
Files changed (43) hide show
  1. data/Gemfile +4 -0
  2. data/Gemfile.lock +69 -0
  3. data/Guardfile +10 -0
  4. data/LICENSE +18 -0
  5. data/README.md +45 -0
  6. data/Rakefile +12 -0
  7. data/bin/cc2html +6 -0
  8. data/cc2html.gemspec +31 -0
  9. data/lib/cc2html/builder.rb +15 -0
  10. data/lib/cc2html/cli.rb +15 -0
  11. data/lib/cc2html/converter.rb +21 -0
  12. data/lib/cc2html/epub_builder.rb +96 -0
  13. data/lib/cc2html/html_builder.rb +23 -0
  14. data/lib/cc2html/templates/epub/chapter.html.erb +54 -0
  15. data/lib/cc2html/templates/epub/descriptor.opf.erb +21 -0
  16. data/lib/cc2html/templates/epub/navigation.html.erb +11 -0
  17. data/lib/cc2html/templates/html/assignment.html.erb +13 -0
  18. data/lib/cc2html/templates/html/index.html.erb +13 -0
  19. data/lib/cc2html/templates/html/wiki_content.html.erb +10 -0
  20. data/lib/cc2html/version.rb +3 -0
  21. data/lib/cc2html.rb +10 -0
  22. data/lib/ims/cc/assignment.rb +37 -0
  23. data/lib/ims/cc/cc.rb +16 -0
  24. data/lib/ims/cc/lom.rb +65 -0
  25. data/lib/ims/cc/manifest.rb +59 -0
  26. data/lib/ims/cc/metadata.rb +10 -0
  27. data/lib/ims/cc/organizations.rb +37 -0
  28. data/lib/ims/cc/resources.rb +71 -0
  29. data/lib/ims/cc/topic.rb +14 -0
  30. data/lib/ims/cc/web_link.rb +11 -0
  31. data/lib/ims/cc.rb +19 -0
  32. data/lib/ims.rb +2 -0
  33. data/test/fixtures/cc_full_test.zip +0 -0
  34. data/test/fixtures/flat_imsmanifest.xml +134 -0
  35. data/test/unit/cc/assignment_test.rb +42 -0
  36. data/test/unit/cc/cc_test_helper.rb +8 -0
  37. data/test/unit/cc/manifest_metadata_test.rb +27 -0
  38. data/test/unit/cc/manifest_test.rb +8 -0
  39. data/test/unit/cc/organizations_test.rb +38 -0
  40. data/test/unit/cc/resources_test.rb +50 -0
  41. data/test/unit/cc/topic_test.rb +38 -0
  42. data/test/unit/cc/web_link_test.rb +35 -0
  43. metadata +277 -0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cc2html.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,69 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cc2html (0.1.0)
5
+ builder
6
+ happymapper
7
+ nokogiri
8
+ rdiscount
9
+ rubyzip
10
+ thor
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ builder (3.2.2)
16
+ celluloid (0.15.2)
17
+ timers (~> 1.1.0)
18
+ coderay (1.0.9)
19
+ ffi (1.9.3)
20
+ formatador (0.2.4)
21
+ guard (2.2.3)
22
+ formatador (>= 0.2.4)
23
+ listen (~> 2.1)
24
+ lumberjack (~> 1.0)
25
+ pry (>= 0.9.12)
26
+ thor (>= 0.18.1)
27
+ guard-bundler (2.0.0)
28
+ bundler (~> 1.0)
29
+ guard (~> 2.2)
30
+ guard-minitest (2.0.0)
31
+ guard (~> 2.0)
32
+ minitest (>= 3.0)
33
+ happymapper (0.4.1)
34
+ libxml-ruby (~> 2.0)
35
+ libxml-ruby (2.7.0)
36
+ listen (2.2.0)
37
+ celluloid (>= 0.15.2)
38
+ rb-fsevent (>= 0.9.3)
39
+ rb-inotify (>= 0.9)
40
+ lumberjack (1.0.4)
41
+ method_source (0.8.2)
42
+ mini_portile (0.5.2)
43
+ minitest (5.0.8)
44
+ nokogiri (1.6.0)
45
+ mini_portile (~> 0.5.0)
46
+ pry (0.9.12.2)
47
+ coderay (~> 1.0.5)
48
+ method_source (~> 0.8)
49
+ slop (~> 3.4)
50
+ rake (10.1.0)
51
+ rb-fsevent (0.9.3)
52
+ rb-inotify (0.9.2)
53
+ ffi (>= 0.5.0)
54
+ rdiscount (2.1.7)
55
+ rubyzip (1.1.0)
56
+ slop (3.4.6)
57
+ thor (0.18.1)
58
+ timers (1.1.0)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ cc2html!
65
+ guard
66
+ guard-bundler
67
+ guard-minitest
68
+ minitest
69
+ rake
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard :bundler do
2
+ watch('Gemfile')
3
+ watch('cc2html.gemspec')
4
+ end
5
+
6
+ guard 'minitest' do
7
+ # with Minitest::Unit
8
+ watch(%r|^test/(.*)\/?(.*)_test\.rb|)
9
+ watch(%r|^lib/ims/cc/(.*?)([^/]+)\.rb|) { |m| "test/unit/#{m[1]}#{m[2]}_test.rb" }
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2013 Bracken Mosbacker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to use,
6
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
+ Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # cc2html
2
+
3
+ cc2html will convert Common Cartridge 1.3 packages into html or epub format
4
+
5
+ Common Cartridge information: http://www.imsglobal.org/cc/index.html
6
+
7
+ Use the [Github Issues](https://github.com/instructure/cc2html/issues?state=open)
8
+ for feature requests and bug reports.
9
+
10
+ ## Installation/Usage
11
+
12
+ ### Command line
13
+ Install RubyGems on your system, see http://rubygems.org/ for instructions.
14
+ Once RubyGems is installed you can install this gem:
15
+
16
+ $ gem install cc2html
17
+
18
+ Convert a Common Cartridge into HTML
19
+
20
+ $ cc2html migrate <path-to-cc-backup> <path-to-html-export-directory>
21
+
22
+ Or into an epub
23
+
24
+ $ cc2html migrate <path-to-cc-backup> <path-to-epub-export-directory> --format=epub
25
+ # then zip of the contents of the folder into a .epub
26
+
27
+ ## Todo
28
+
29
+ * Oh so much!
30
+ * Support converting all Common Cartridge versions
31
+ * Create chapters from organization sections
32
+ * Quiz conversion
33
+ * make epub zip automatically
34
+
35
+ ## Contributing
36
+
37
+ Run the tests:
38
+
39
+ $ bundle exec rake
40
+
41
+ 1. Fork it
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs.push "lib"
8
+ t.pattern = "test/**/*_test.rb"
9
+ t.verbose = true
10
+ end
11
+
12
+ task :default => :test
data/bin/cc2html ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'cc2html'
4
+ require 'cc2html/cli'
5
+
6
+ CC2HTML::CLI.start
data/cc2html.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/cc2html/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Bracken Mosbacker"]
6
+ gem.description = %q{Converts an IMS Common Cartridge package to a self-contained web site or epub}
7
+ gem.summary = %q{Converts an IMS Common Cartridge package to a self-contained web site or epub}
8
+ gem.homepage = "https://github.com/bracken/cc2html"
9
+
10
+ gem.add_runtime_dependency "rubyzip"
11
+ gem.add_runtime_dependency "happymapper"
12
+ gem.add_runtime_dependency "builder"
13
+ gem.add_runtime_dependency "thor"
14
+ gem.add_runtime_dependency "nokogiri"
15
+ gem.add_runtime_dependency "rdiscount"
16
+
17
+ gem.add_development_dependency "rake"
18
+ gem.add_development_dependency "minitest"
19
+ gem.add_development_dependency "guard"
20
+ gem.add_development_dependency "guard-bundler"
21
+ gem.add_development_dependency "guard-minitest"
22
+
23
+ gem.files = `git ls-files`.split($\)
24
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
25
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
+ gem.name = "cc2html"
27
+ gem.require_paths = ["lib"]
28
+ gem.version = CC2HTML::VERSION
29
+ gem.extra_rdoc_files = %W(LICENSE)
30
+ gem.license = 'MIT'
31
+ end
@@ -0,0 +1,15 @@
1
+ module CC2HTML
2
+ class Builder
3
+ def initialize(manifest, dest_dir)
4
+ @dest_dir = dest_dir
5
+ @manifest = manifest
6
+ @items = manifest.organizations.organization.item.items
7
+ lom = manifest.metadata.lom
8
+ @title = lom.general.title.title
9
+ @description = lom.general.description.description if lom.general.description
10
+ if lom.rights && lom.rights.description
11
+ @copy_info = lom.rights.description.description
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require 'thor'
2
+
3
+ module CC2HTML
4
+ class CLI < Thor
5
+ desc "migrate COMMON_CARTRIDGE_ZIP EXPORT_DIR", "Migrates Common Cartridge ZIP to an HTML representation"
6
+ method_option :format, :default => 'html'
7
+ method_options :format => :string
8
+
9
+ def migrate(source, destination)
10
+ converter = CC2HTML::Converter.new source, destination, options
11
+ converter.convert
12
+ puts "#{source} converted to #{converter.cc_file_path}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ module CC2HTML
2
+ class Converter
3
+ attr_reader :cc_file_path, :dest_dir
4
+
5
+ def initialize(cc_file_path, dest_dir, options={})
6
+ @cc_file_path = cc_file_path
7
+ @dest_dir = dest_dir
8
+ @settings = options
9
+ end
10
+
11
+ def convert
12
+ manifest = IMS::CC::Manifest.read(@cc_file_path)
13
+ if @settings[:format] == 'html'
14
+ CC2HTML::HtmlBuilder.new(manifest, @dest_dir, @cc_file_path).generate
15
+ elsif @settings[:format] == 'epub'
16
+ CC2HTML::EpubBuilder.new(manifest, @dest_dir, @cc_file_path).generate
17
+ end
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,96 @@
1
+ module CC2HTML
2
+ class EpubBuilder < Builder
3
+ TEMPLATE_DIR = '../templates/epub/'
4
+
5
+ def initialize(manifest, dest_dir, zip_file=nil)
6
+ super(manifest, dest_dir)
7
+ @file_name = 'cc_book'
8
+ @content_dir = File.join(@dest_dir, 'content')
9
+ @zip_file = zip_file
10
+ @items_with_resource = @items.select{|i|i.resource}
11
+ end
12
+
13
+ def generate
14
+ FileUtils.mkdir_p(@dest_dir)
15
+ create_mimetype_file
16
+ create_meta_inf
17
+ FileUtils.mkdir_p(@content_dir)
18
+ create_opf
19
+ create_nav
20
+ create_chapters
21
+ copy_html_webresources
22
+ end
23
+
24
+ def create_mimetype_file
25
+ File.open(File.join(@dest_dir, 'mimetype'), 'w') do |f|
26
+ f << "application/epub+zip\n"
27
+ end
28
+ end
29
+
30
+ def create_nav
31
+ template = File.expand_path(TEMPLATE_DIR + 'navigation.html.erb', __FILE__)
32
+ path = File.join(@content_dir = File.join(@dest_dir, 'content'), 'navigation.html')
33
+
34
+ File.open(path, 'w') do |file|
35
+ erb = ERB.new(File.read(template))
36
+ file.write(erb.result(binding))
37
+ end
38
+ end
39
+
40
+ def create_chapters
41
+ template = File.expand_path(TEMPLATE_DIR + 'chapter.html.erb', __FILE__)
42
+ @items_with_resource.each do |item|
43
+ next if item.resource.type == 'webcontent'
44
+ # so stupid... I'll fix later. :)
45
+ @item = item
46
+ path = File.join(@content_dir = File.join(@dest_dir, 'content'), item.identifierref + '.html')
47
+ File.open(path, 'w') do |file|
48
+ erb = ERB.new(File.read(template))
49
+ file.write(erb.result(binding))
50
+ end
51
+ end
52
+ end
53
+
54
+ def copy_html_webresources
55
+ return unless @zip_file.end_with?('zip') || @zip_file.end_with?('imscc')
56
+ Zip::File.open(@zip_file) do |zipfile|
57
+ @items_with_resource.each do |item|
58
+ if item.resource.type == 'webcontent' && item.resource.href && item.resource.href.end_with?('html')
59
+ puts item.identifier
60
+ path = File.join(@content_dir = File.join(@dest_dir, 'content'), item.identifierref + '.html')
61
+ File.open(path, 'w') do |file|
62
+ entry = zipfile.get_entry(item.resource.href)
63
+ file << entry.get_input_stream.read
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ def create_meta_inf
71
+ meta_dir = File.join(@dest_dir, 'META-INF')
72
+ FileUtils.mkdir_p(meta_dir)
73
+ File.open(File.join(meta_dir, 'container.xml'), 'w') do |f|
74
+ f << <<-XML
75
+ <?xml version="1.0"?>
76
+ <container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
77
+ <rootfiles>
78
+ <rootfile full-path="content/#{@file_name}.opf" media-type="application/oebps-package+xml"/>
79
+ </rootfiles>
80
+ </container>
81
+ XML
82
+ end
83
+ end
84
+
85
+ def create_opf
86
+ template = File.expand_path(TEMPLATE_DIR + 'descriptor.opf.erb', __FILE__)
87
+ path = File.join(@content_dir = File.join(@dest_dir, 'content'), @file_name + '.opf')
88
+
89
+ File.open(path, 'w') do |file|
90
+ erb = ERB.new(File.read(template))
91
+ file.write(erb.result(binding))
92
+ end
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,23 @@
1
+ module CC2HTML
2
+ class HtmlBuilder
3
+ TEMPLATE_DIR = '../templates/html/'
4
+ def initialize(manifest, dest_dir, zip_file)
5
+ @manifest = manifest
6
+ @dest_dir = dest_dir
7
+ @items = manifest.organizations.organization.item.items
8
+ end
9
+
10
+ def generate
11
+ FileUtils.mkdir_p(@dest_dir)
12
+ template = File.expand_path(TEMPLATE_DIR + 'index.html.erb', __FILE__)
13
+ path = File.join(@dest_dir, 'index.html')
14
+
15
+ #FileUtils.mkdir_p(File.dirname(path))
16
+ File.open(path, 'w') do |file|
17
+ erb = ERB.new(File.read(template))
18
+ file.write(erb.result(binding))
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>
3
+ <html xmlns="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
6
+ <title><%= @item.title %></title>
7
+ </head>
8
+ <body>
9
+ <h1><%= @item.title %></h1>
10
+
11
+ <% if asmnt = @item.resource.assignment %>
12
+ <h2>Assignment</h2>
13
+ <p><%= asmnt.text %></p>
14
+ <% if asmnt.instructor_text %>
15
+ <p>Instructor Text: <%= asmnt.instructor_text %></p>
16
+ <% end %>
17
+ <% if asmnt.submission_formats && asmnt.submission_formats.any? %>
18
+ <p>Ways to turn the assignment in:</p>
19
+ <ul>
20
+ <% asmnt.submission_formats.each do |sf| %>
21
+ <li><%= sf %></li>
22
+ <% end %>
23
+ </ul>
24
+ <% end %>
25
+ <% if asmnt.attachments %>
26
+ <h3>Attachments</h3>
27
+ <ul>
28
+ <% asmnt.attachments.attachments.each do |att| %>
29
+ <li><%= att.href %></li>
30
+ <% end %>
31
+ </ul>
32
+ <% end %>
33
+ <% end %>
34
+
35
+ <% if topic = @item.resource.topic %>
36
+ <h2>Discussion Topic</h2>
37
+ <p><%= topic.text %></p>
38
+ <% if topic.attachments %>
39
+ <h3>Attachments</h3>
40
+ <ul>
41
+ <% topic.attachments.attachments.each do |att| %>
42
+ <li><%= att.href %></li>
43
+ <% end %>
44
+ </ul>
45
+ <% end %>
46
+ <% end %>
47
+
48
+ <% if web_link = @item.resource.web_link %>
49
+ <p>Visit the web site <a href="<%= web_link.url.href %>"><%= web_link.title %></a></p>
50
+ <% end %>
51
+
52
+
53
+ </body>
54
+ </html>
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><package xmlns:opf="http://www.idpf.org/2007/opf" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="id">
2
+ <metadata>
3
+ <dc:rights><%= @copy_info || 'Public domain' %></dc:rights>
4
+ <dc:creator opf:file-as="Unknown, Author">Unknown Author</dc:creator>
5
+ <dc:title><%= @title %></dc:title>
6
+ <dc:language xsi:type="dcterms:RFC4646">en</dc:language>
7
+ <dc:date opf:event="publication"><%= Time.now.strftime("%Y-%m-%d") %></dc:date>
8
+ </metadata>
9
+ <manifest>
10
+ <item href="navigation.html" media-type="application/xhtml+xml" id="toc" properties="nav"/>
11
+ <% @items_with_resource.each do |item| %>
12
+ <item href="<%= item.identifierref %>.html" id="<%= item.identifierref %>" media-type="application/xhtml+xml"/>
13
+ <% end %>
14
+ </manifest>
15
+ <spine>
16
+ <itemref idref="toc" linear="yes"/>
17
+ <% @items_with_resource.each do |item| %>
18
+ <itemref idref="<%= item.identifierref %>" linear="yes"/>
19
+ <% end %>
20
+ </spine>
21
+ </package>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops">
3
+ <head><title>Table of contents</title></head>
4
+ <body><nav xmlns="http://www.w3.org/1999/xhtml" class="book" epub:type="toc">
5
+ <ol>
6
+ <% @items.each do |item| %>
7
+ <li><a href="<%= item.identifierref %>.html"><%= item.title %></a></li>
8
+ <% end %>
9
+ </ol>
10
+ </nav></body>
11
+ </html>
@@ -0,0 +1,13 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
+ <% if meta_fields
5
+ meta_fields.each_pair do |key, val|%>
6
+ <meta name="<%= key %>" content="<%= val %>" /> <% end %>
7
+ <% end %>
8
+ <title>Assignment: <%= title %></title>
9
+ </head>
10
+ <body>
11
+ <%= body %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,13 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
+ <title>Index</title>
5
+ </head>
6
+ <body>
7
+ <ul>
8
+ <% @items.each do |item| %>
9
+ <li><%= item.identifier %></li>
10
+ <% end %>
11
+ </ul>
12
+ </body>
13
+ </html>
@@ -0,0 +1,10 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
4
+ <title><%= title %></title>
5
+ <meta name="identifier" content="<%= identifier %>"/>
6
+ </head>
7
+ <body>
8
+ <%= body %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,3 @@
1
+ module CC2HTML
2
+ VERSION = "0.0.1"
3
+ end
data/lib/cc2html.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'ims/cc'
2
+ require 'erb'
3
+
4
+ module CC2HTML
5
+ end
6
+
7
+ require 'cc2html/converter'
8
+ require 'cc2html/builder'
9
+ require 'cc2html/html_builder'
10
+ require 'cc2html/epub_builder'
@@ -0,0 +1,37 @@
1
+ module IMS::CC
2
+ module Assignment
3
+
4
+ class Format
5
+ include HappyMapper
6
+
7
+ tag 'format'
8
+ attribute :type, String
9
+ end
10
+
11
+ class SubmissionFormats
12
+ include HappyMapper
13
+
14
+ tag 'submission_formats'
15
+ has_many :formats, Format
16
+ end
17
+
18
+ class Assignment
19
+ include HappyMapper
20
+ namespace 'http://www.imsglobal.org/xsd/imscc_extensions/assignment'
21
+
22
+ tag 'assignment'
23
+ element :title, String
24
+ element :text, String, :attributes => {href: String, texttype: String}
25
+ element :instructor_text, String, :attributes => {href: String, texttype: String}
26
+ element :gradable, Boolean
27
+ has_one :submission_formats, SubmissionFormats
28
+ has_one :attachments, IMS::CC::Attachments
29
+
30
+ after_parse do |assignment|
31
+ if assignment.submission_formats
32
+ assignment.submission_formats = assignment.submission_formats.formats.map{|f|f.type}
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
data/lib/ims/cc/cc.rb ADDED
@@ -0,0 +1,16 @@
1
+ module IMS::CC
2
+ class Attachment
3
+ include HappyMapper
4
+
5
+ tag 'attachment'
6
+ attribute :href, String
7
+ attribute :role, String
8
+ end
9
+
10
+ class Attachments
11
+ include HappyMapper
12
+
13
+ tag 'attachments'
14
+ has_many :attachments, Attachment
15
+ end
16
+ end
data/lib/ims/cc/lom.rb ADDED
@@ -0,0 +1,65 @@
1
+ module IMS::CC
2
+ module Lom
3
+ NAMESPACE = 'http://ltsc.ieee.org/xsd/imsccv1p3/LOM/manifest'
4
+
5
+ class Title
6
+ include HappyMapper
7
+ namespace NAMESPACE
8
+
9
+ tag 'title'
10
+ element :title, String, :tag => 'string'
11
+ end
12
+
13
+ class Description
14
+ include HappyMapper
15
+ namespace NAMESPACE
16
+
17
+ tag 'description'
18
+ element :description, String, :tag => 'string'
19
+ end
20
+
21
+ class Keyword
22
+ include HappyMapper
23
+ namespace NAMESPACE
24
+
25
+ tag 'keyword'
26
+ element :keyword, String, :tag => 'string'
27
+ end
28
+
29
+ class General
30
+ include HappyMapper
31
+ namespace NAMESPACE
32
+
33
+ tag 'general'
34
+ has_one :title, Title
35
+ has_one :description, Description
36
+ has_many :keywords, Keyword
37
+ end
38
+
39
+ class CopyrightAndOtherRestrictions
40
+ include HappyMapper
41
+ namespace NAMESPACE
42
+
43
+ tag 'copyrightAndOtherRestrictions'
44
+ element :value, String
45
+ end
46
+
47
+ class Rights
48
+ include HappyMapper
49
+ namespace NAMESPACE
50
+
51
+ tag 'rights'
52
+ has_one :copyrightAndOtherRestrictions, CopyrightAndOtherRestrictions
53
+ has_one :description, Description
54
+ end
55
+
56
+ class Lom
57
+ include HappyMapper
58
+ namespace NAMESPACE
59
+
60
+ tag 'lom'
61
+ has_one :general, General
62
+ has_one :rights, Rights
63
+ end
64
+ end
65
+ end