moodle2cc 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog CHANGED
@@ -1,3 +1,7 @@
1
+ 2014-01-21 Version 0.1.11
2
+ * files with associated text/html content are now made into
3
+ html pages with that text and a link to the file
4
+
1
5
  2013-08-15 Version 0.1.10
2
6
  * improve multiple dropdown question handling
3
7
 
@@ -28,7 +28,7 @@ module Moodle2CC::CC
28
28
  create_manifest
29
29
  end
30
30
  create_web_resources
31
- Zip::ZipFile.open(imscc_tmp_path, Zip::ZipFile::CREATE) do |zipfile|
31
+ Zip::File.open(imscc_tmp_path, Zip::File::CREATE) do |zipfile|
32
32
  Dir["#{@export_dir}/**/*"].each do |file|
33
33
  zipfile.add(file.sub(@export_dir + '/', ''), file)
34
34
  end
@@ -10,6 +10,13 @@ module Moodle2CC::CC
10
10
  @rel_path = File.join(CC_WIKI_FOLDER, "#{file_slug(@title)}.html")
11
11
  body = mod.alltext
12
12
  body = mod.content || '' if body.nil? || body.length == 0
13
+ if body.nil? || body.length == 0 && mod.summary
14
+ body = mod.summary
15
+ url = mod.reference.to_s.strip
16
+ unless url.gsub(%r{http(s)?://}, '').length == 0
17
+ body += %(<p><a href="#{CGI.escapeHTML(url)}" title="#{CGI.escapeHTML(@title)}">#{@title}</a></p>)
18
+ end
19
+ end
13
20
  @body = convert_file_path_tokens(body)
14
21
  end
15
22
 
@@ -1,4 +1,4 @@
1
- require 'zip/zipfilesystem'
1
+ require 'zip'
2
2
 
3
3
  module Moodle2CC::Moodle
4
4
  class Backup
@@ -11,8 +11,8 @@ module Moodle2CC::Moodle
11
11
  has_one :course, Course
12
12
 
13
13
  def self.read(backup_file)
14
- Zip::ZipFile.open(backup_file) do |zipfile|
15
- xml = zipfile.file.read("moodle.xml")
14
+ Zip::File.open(backup_file) do |zipfile|
15
+ xml = zipfile.read("moodle.xml")
16
16
  backup = parse xml
17
17
  backup.backup_file = backup_file
18
18
  backup.files = zipfile.entries.select { |e| e.name =~ /^course_files/ && !e.directory? }.
@@ -22,14 +22,12 @@ module Moodle2CC::Moodle
22
22
  end
23
23
 
24
24
  def copy_files_to(dir)
25
- Zip::ZipFile.open(@backup_file) do |zipfile|
25
+ Zip::File.open(@backup_file) do |zipfile|
26
26
  @files.each do |file|
27
- zipfile.file.open("course_files/#{file}") do |zip|
28
- destination_file = File.join(dir, file)
29
- FileUtils.mkdir_p(File.dirname(destination_file))
30
- File.open(destination_file, 'w') do |f|
31
- f.write zip.read
32
- end
27
+ destination_file = File.join(dir, file)
28
+ FileUtils.mkdir_p(File.dirname(destination_file))
29
+ File.open(destination_file, 'w') do |f|
30
+ f.write zipfile.read("course_files/#{file}")
33
31
  end
34
32
  end
35
33
  end
@@ -11,7 +11,11 @@ class Moodle2CC::ResourceFactory
11
11
  when 'resource'
12
12
  case mod.type
13
13
  when 'file'
14
- @namespace.const_get(:WebLink).new(mod)
14
+ if mod.summary && mod.summary.length > 0
15
+ @namespace.const_get(:WebContent).new(mod)
16
+ else
17
+ @namespace.const_get(:WebLink).new(mod)
18
+ end
15
19
  when 'html', 'text'
16
20
  @namespace.const_get(:WebContent).new(mod)
17
21
  end
@@ -1,3 +1,3 @@
1
1
  module Moodle2CC
2
- VERSION = "0.1.10"
2
+ VERSION = "0.1.11"
3
3
  end
@@ -1,9 +1,10 @@
1
- require 'zip/zipfilesystem'
1
+ require 'zip'
2
2
 
3
3
  module TestHelper
4
4
  def create_moodle_backup_zip(backup_name='moodle_backup')
5
5
  moodle_backup_path = File.expand_path("../../../test/tmp/#{backup_name}.zip", __FILE__)
6
- Zip::ZipFile.open(moodle_backup_path, Zip::ZipFile::CREATE) do |zipfile|
6
+ Zip::File.open(moodle_backup_path, Zip::File::CREATE) do |zipfile|
7
+ zipfile.remove("moodle.xml") if zipfile.find_entry("moodle.xml")
7
8
  zipfile.add("moodle.xml", File.expand_path("../../../test/fixtures/#{backup_name}/moodle.xml", __FILE__))
8
9
  zipfile.mkdir("course_files")
9
10
  zipfile.mkdir("course_files/folder")
@@ -24,13 +25,13 @@ module TestHelper
24
25
  end
25
26
 
26
27
  def get_imsmanifest_xml
27
- Zip::ZipFile.open(@converter.imscc_path) do |zipfile|
28
+ Zip::File.open(@converter.imscc_path) do |zipfile|
28
29
  xml = Nokogiri::XML(zipfile.read("imsmanifest.xml"))
29
30
  end
30
31
  end
31
32
 
32
33
  def get_imscc_file(file)
33
- Zip::ZipFile.open(@converter.imscc_path) do |zipfile|
34
+ Zip::File.open(@converter.imscc_path) do |zipfile|
34
35
  zipfile.read(file)
35
36
  end
36
37
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.summary = %q{Migrates Moodle backup ZIP to IMS Common Cartridge package}
9
9
  gem.homepage = "https://github.com/instructure/moodle2cc"
10
10
 
11
- gem.add_runtime_dependency "rubyzip"
11
+ gem.add_runtime_dependency "rubyzip", '~> 1.0.0'
12
12
  gem.add_runtime_dependency "happymapper"
13
13
  gem.add_runtime_dependency "builder"
14
14
  gem.add_runtime_dependency "thor"
@@ -502,7 +502,7 @@
502
502
  <NAME>About Your Instructor</NAME>
503
503
  <TYPE>file</TYPE>
504
504
  <REFERENCE>http://en.wikipedia.org/wiki/Einstein</REFERENCE>
505
- <SUMMARY></SUMMARY>
505
+ <SUMMARY>Sometimes these include a summary</SUMMARY>
506
506
  <ALLTEXT></ALLTEXT>
507
507
  <POPUP>resizable=1,scrollbars=1,directories=1,location=1,menubar=1,toolbar=1,status=1,width=1024,height=768</POPUP>
508
508
  <OPTIONS></OPTIONS>
@@ -23,7 +23,7 @@ class TestUnitCCConverter < MiniTest::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_it_creates_imsmanifest_xml
26
- Zip::ZipFile.open(@converter.imscc_path) do |zipfile|
26
+ Zip::File.open(@converter.imscc_path) do |zipfile|
27
27
  assert zipfile.find_entry("imsmanifest.xml")
28
28
  end
29
29
  end
@@ -34,4 +34,13 @@ class TestUnitCanvasWebContent < MiniTest::Unit::TestCase
34
34
  assert_equal 'i6447ff05ab6e342a42302007a6e3bcb4', xml.root.xpath('identifierref').text
35
35
  end
36
36
 
37
+ def test_it_creates_web_content_item_from_link_with_summary
38
+ mod = @backup.course.mods.find { |m| m.mod_type == "resource" &&
39
+ (!m.summary.nil? && m.summary.length != 0)}
40
+ mod.type = 'file'
41
+ web_content = Moodle2CC::Canvas::WebContent.new mod
42
+
43
+ assert web_content.body.include?(mod.reference)
44
+ assert web_content.body.include?(mod.summary)
45
+ end
37
46
  end
@@ -23,7 +23,7 @@ class TestUnitCCConverter < MiniTest::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_it_creates_imsmanifest_xml
26
- Zip::ZipFile.open(@converter.imscc_path) do |zipfile|
26
+ Zip::File.open(@converter.imscc_path) do |zipfile|
27
27
  assert zipfile.find_entry("imsmanifest.xml")
28
28
  end
29
29
  end
@@ -69,8 +69,18 @@ class TestUnitCCResource < MiniTest::Unit::TestCase
69
69
  assert_kind_of Moodle2CC::Canvas::WebContent, resource
70
70
  end
71
71
 
72
+ def test_it_can_get_web_content_resource_from_file_resource_with_summary
73
+ mod = @backup.course.mods.find { |m| m.mod_type == "resource" && (!m.summary.nil? && m.summary.length != 0)}
74
+ mod.type = 'file'
75
+ resource = @cc_factory.get_resource_from_mod(mod)
76
+ assert_kind_of Moodle2CC::CC::WebContent, resource
77
+
78
+ resource = @canvas_factory.get_resource_from_mod(mod)
79
+ assert_kind_of Moodle2CC::Canvas::WebContent, resource
80
+ end
81
+
72
82
  def test_it_can_get_web_link_resource
73
- mod = @backup.course.mods.find { |m| m.mod_type == "resource" }
83
+ mod = @backup.course.mods.find { |m| m.mod_type == "resource" && (m.summary.nil? || m.summary.length == 0) }
74
84
  mod.type = 'file'
75
85
  resource = @cc_factory.get_resource_from_mod(mod)
76
86
  assert_kind_of Moodle2CC::CC::WebLink, resource
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.10
4
+ version: 0.1.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,24 +11,24 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-08-15 00:00:00.000000000 Z
14
+ date: 2014-01-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rubyzip
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ! '>='
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: '0'
23
+ version: 1.0.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  none: false
28
28
  requirements:
29
- - - ! '>='
29
+ - - ~>
30
30
  - !ruby/object:Gem::Version
31
- version: '0'
31
+ version: 1.0.0
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: happymapper
34
34
  requirement: !ruby/object:Gem::Requirement