moodle2cc 0.0.1 → 0.1.0

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/README.md CHANGED
@@ -1,10 +1,22 @@
1
1
  # Moodle2CC
2
2
 
3
- moodle2cc will convert Moodle 1.9 backup files into IMS Common Cartridge
4
- formatted files.
3
+ moodle2cc will convert Moodle 1.9 backup files into IMS Common Cartridge 1.1
4
+ formatted files.
5
+
6
+ Moodle information: http://moodle.org/
7
+
8
+ Common Cartridge information: http://www.imsglobal.org/cc/index.html
5
9
 
6
10
  ## Installation
7
11
 
12
+ ### Command line-only use
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 moodle2cc
17
+
18
+ ### For use in a Ruby application
19
+
8
20
  Add this line to your application's Gemfile:
9
21
 
10
22
  gem 'moodle2cc'
@@ -13,18 +25,24 @@ And then execute:
13
25
 
14
26
  $ bundle
15
27
 
16
- Or install it yourself as:
17
-
18
- $ gem install moodle2cc
19
-
20
28
  ## Usage
21
29
 
30
+ ### Command Line
31
+
22
32
  For Common Cartridge format
23
33
  $ moodle2cc migrate <path-to-moodle-backup> <path-to-cc-export-directory>
24
34
 
25
35
  For Canvas Common Cartridge format
26
36
  $ moodle2cc migrate --format=canvas <path-to-moodle-backup> <path-to-cc-export-directory>
27
37
 
38
+ ### Ruby Application
39
+
40
+ ```ruby
41
+ require 'moodle2cc'
42
+ migrator = Moodle2CC::Migrator.new moodle_zip_path, destination_bath
43
+ migrator.migrate
44
+ ```
45
+
28
46
  ## Contributing
29
47
 
30
48
  Run the tests:
@@ -22,10 +22,13 @@ class Moodle2CC::ResourceFactory
22
22
  @namespace.const_get(:Wiki).new(mod)
23
23
  when 'label'
24
24
  html = Nokogiri::HTML(mod.content)
25
- if html.text == mod.content && mod.content.length < 50 # label doesn't contain HTML
26
- @namespace.const_get(:Label).new(mod)
27
- else
25
+ if html.search('img[src]').length > 0 ||
26
+ html.search('a[href]').length > 0 ||
27
+ html.search('iframe[src]').length > 0 ||
28
+ html.text.strip.length > 50
28
29
  @namespace.const_get(:WebContent).new(mod)
30
+ else
31
+ @namespace.const_get(:Label).new(mod)
29
32
  end
30
33
  end
31
34
  end
@@ -1,3 +1,3 @@
1
1
  module Moodle2CC
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/moodle2cc.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  require File.expand_path('../lib/moodle2cc/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.authors = ["Christopher Durtschi", "Kevin Carter"]
6
- gem.email = ["christopher.durtschi@gmail.com", "cartkev@gmail.com"]
5
+ gem.authors = ["Christopher Durtschi", "Kevin Carter", "Instructure"]
6
+ gem.email = ["christopher.durtschi@gmail.com", "cartkev@gmail.com", "eng@instructure.com"]
7
7
  gem.description = %q{Migrates Moodle backup ZIP to IMS Common Cartridge package}
8
8
  gem.summary = %q{Migrates Moodle backup ZIP to IMS Common Cartridge package}
9
- gem.homepage = ""
9
+ gem.homepage = "https://github.com/instructure/moodle2cc"
10
10
 
11
11
  gem.add_runtime_dependency "rubyzip"
12
12
  gem.add_runtime_dependency "happymapper"
@@ -80,7 +80,7 @@ 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_web_content_resource_from_label_mod
83
+ def test_it_can_get_web_content_resource_from_label_mod_with_img_tag
84
84
  mod = @backup.course.mods.find { |m| m.mod_type == "label" }
85
85
  mod.content = %(<img src="http://image.com/image.jpg" />")
86
86
  resource = @cc_factory.get_resource_from_mod(mod)
@@ -90,6 +90,67 @@ class TestUnitCCResource < MiniTest::Unit::TestCase
90
90
  assert_kind_of Moodle2CC::Canvas::WebContent, resource
91
91
  end
92
92
 
93
+ def test_it_can_get_web_content_resource_from_label_mod_with_an_a_tag
94
+ mod = @backup.course.mods.find { |m| m.mod_type == "label" }
95
+ mod.content = %(<a href="http://www.google.com">Google</a>")
96
+ resource = @cc_factory.get_resource_from_mod(mod)
97
+ assert_kind_of Moodle2CC::CC::WebContent, resource
98
+
99
+ resource = @canvas_factory.get_resource_from_mod(mod)
100
+ assert_kind_of Moodle2CC::Canvas::WebContent, resource
101
+ end
102
+
103
+ def test_it_can_get_label_resource_from_label_mod_with_an_a_tag_with_no_href
104
+ mod = @backup.course.mods.find { |m| m.mod_type == "label" }
105
+ mod.content = %(<a name="Google">Google</a>")
106
+ resource = @cc_factory.get_resource_from_mod(mod)
107
+ assert_kind_of Moodle2CC::CC::Label, resource
108
+
109
+ resource = @canvas_factory.get_resource_from_mod(mod)
110
+ assert_kind_of Moodle2CC::Canvas::Label, resource
111
+ end
112
+
113
+ def test_it_can_get_web_content_resource_from_label_mod_with_an_iframe
114
+ mod = @backup.course.mods.find { |m| m.mod_type == "label" }
115
+ mod.content = %(<iframe src="http://www.google.com"></iframe>)
116
+ resource = @cc_factory.get_resource_from_mod(mod)
117
+ assert_kind_of Moodle2CC::CC::WebContent, resource
118
+
119
+ resource = @canvas_factory.get_resource_from_mod(mod)
120
+ assert_kind_of Moodle2CC::Canvas::WebContent, resource
121
+ end
122
+
123
+ def test_it_can_get_web_content_resource_from_label_mod_with_a_lot_of_text
124
+ mod = @backup.course.mods.find { |m| m.mod_type == "label" }
125
+ mod.content = %(
126
+ <p>
127
+ I will always test my code,
128
+ I will always test my code,
129
+ I will always test my code
130
+ </p>)
131
+ resource = @cc_factory.get_resource_from_mod(mod)
132
+ assert_kind_of Moodle2CC::CC::WebContent, resource
133
+
134
+ resource = @canvas_factory.get_resource_from_mod(mod)
135
+ assert_kind_of Moodle2CC::Canvas::WebContent, resource
136
+ end
137
+
138
+ def test_it_can_get_label_resource_from_label_mod_with_minimal_html
139
+ mod = @backup.course.mods.find { |m| m.mod_type == "label" }
140
+ mod.name = "Forum"
141
+ mod.content = %(
142
+ <h4 style="color: rgb(0, 0, 153); margin-left: 40px; font-weight: normal; ">
143
+ <font size="3">
144
+ <a name="Anker1"> Forum</a>
145
+ </font>
146
+ </h4>)
147
+ resource = @cc_factory.get_resource_from_mod(mod)
148
+ assert_kind_of Moodle2CC::CC::Label, resource
149
+
150
+ resource = @canvas_factory.get_resource_from_mod(mod)
151
+ assert_kind_of Moodle2CC::Canvas::Label, resource
152
+ end
153
+
93
154
  def test_it_can_get_assessment_resource_from_questionnaire_mod
94
155
  mod = @backup.course.mods.find { |m| m.mod_type == "questionnaire" }
95
156
  resource = @cc_factory.get_resource_from_mod(mod)
metadata CHANGED
@@ -1,22 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moodle2cc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christopher Durtschi
14
14
  - Kevin Carter
15
+ - Instructure
15
16
  autorequire:
16
17
  bindir: bin
17
18
  cert_chain: []
18
19
 
19
- date: 2012-07-23 00:00:00 Z
20
+ date: 2012-07-24 00:00:00 Z
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  name: rubyzip
@@ -162,6 +163,7 @@ description: Migrates Moodle backup ZIP to IMS Common Cartridge package
162
163
  email:
163
164
  - christopher.durtschi@gmail.com
164
165
  - cartkev@gmail.com
166
+ - eng@instructure.com
165
167
  executables:
166
168
  - moodle2cc
167
169
  extensions: []
@@ -264,7 +266,7 @@ files:
264
266
  - test/unit/moodle/question_test.rb
265
267
  - test/unit/moodle/section_test.rb
266
268
  - test/unit/resource_factory_test.rb
267
- homepage: ""
269
+ homepage: https://github.com/instructure/moodle2cc
268
270
  licenses: []
269
271
 
270
272
  post_install_message: