moodle2cc 0.2.26 → 0.2.27
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.
- checksums.yaml +8 -8
- data/Changelog +3 -0
- data/lib/moodle2cc/canvas_cc/models/page.rb +0 -1
- data/lib/moodle2cc/moodle2converter/converter_helper.rb +4 -4
- data/lib/moodle2cc/moodle2converter/label_converter.rb +0 -2
- data/lib/moodle2cc/moodle2converter/migrator.rb +13 -0
- data/lib/moodle2cc/moodle2converter/section_converter.rb +0 -2
- data/lib/moodle2cc/version.rb +1 -1
- data/spec/moodle2cc/canvas_cc/models/page_spec.rb +7 -5
- data/spec/moodle2cc/canvas_cc/page_writer_spec.rb +1 -0
- data/spec/moodle2cc/moodle2converter/label_converter_spec.rb +0 -3
- data/spec/moodle2cc/moodle2converter/migrator_spec.rb +3 -1
- data/spec/moodle2cc/moodle2converter/section_converter_spec.rb +0 -2
- data/spec/spec_helper.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjcyYjEyNjE5MjdkYjJiMzdjZjVhMjk4Mjc2YjRjOTUwMTc3NmY2Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2YyNTg2OTU0ZDhhM2IwNDUzNDhlZjdjMDU0MmIzMTc3MjBmZDI3ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWI4MDBjMGQxMGI1OWIzNzg2YzIyMDExYmQ0Njc3YjQ0YTA0MmNjMjk0Mzg4
|
10
|
+
ZjE4MjU2MzYzYjJmNGZmOWFhNzhhODZjZjA2MzVmMjEwYzRlYzdkYjZmOTE2
|
11
|
+
MzYyZGMyNDFiZDU0MDhjZDE4ZmY1ZmE5YzAzMmFkMzkxNGIwZjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDc5ZGM4NTlmYzVmODVlMWEyMzg4MDM5NzA5NTM1NWQzNGZhOTQyZDYxOWVi
|
14
|
+
ZWI2OTQzYmE3OGRlYTNmZTNlNGZmNTA1ZWRkNGUyNmQ0YWFjYWE2YjY4ZTZm
|
15
|
+
MWFjOWU4N2RkMzVjYTE5ZmYwMmM4YzZiYmRiMTk4ZTcxOGJhMDg=
|
data/Changelog
CHANGED
@@ -58,18 +58,18 @@ module Moodle2CC
|
|
58
58
|
|
59
59
|
def generate_unique_identifier_for(id, suffix = nil)
|
60
60
|
unique_id = "m2#{Digest::MD5.hexdigest(id.to_s)}#{suffix}"
|
61
|
-
|
62
|
-
if
|
61
|
+
id_set = Moodle2Converter::Migrator.unique_id_set
|
62
|
+
if id_set.include?(unique_id)
|
63
63
|
# i was under the impression that moodle ids would be unique themselves
|
64
64
|
# but i have been apparently misinformed
|
65
65
|
original_id = unique_id
|
66
66
|
index = 0
|
67
|
-
while
|
67
|
+
while id_set.include?(unique_id)
|
68
68
|
index += 1
|
69
69
|
unique_id = "#{original_id}#{index}"
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
72
|
+
id_set << unique_id
|
73
73
|
unique_id
|
74
74
|
end
|
75
75
|
|
@@ -29,8 +29,6 @@ module Moodle2CC
|
|
29
29
|
canvas_page.workflow_state = workflow_state(moodle_label.visible)
|
30
30
|
canvas_page.editing_roles = CanvasCC::Models::Page::EDITING_ROLE_TEACHER
|
31
31
|
canvas_page.body = moodle_label.intro
|
32
|
-
canvas_page.href = generate_unique_resource_path(CanvasCC::Models::Page::WIKI_CONTENT,
|
33
|
-
Moodle2CC::CanvasCC::Models::Page.convert_name_to_url(canvas_page.title))
|
34
32
|
pages << canvas_page
|
35
33
|
end
|
36
34
|
pages
|
@@ -4,6 +4,7 @@ module Moodle2CC::Moodle2Converter
|
|
4
4
|
include ConverterHelper
|
5
5
|
|
6
6
|
def initialize(source_file, output_dir)
|
7
|
+
self.class.clear_unique_id_set!
|
7
8
|
@extractor = Moodle2CC::Moodle2::Extractor.new(source_file)
|
8
9
|
@output_dir = output_dir
|
9
10
|
end
|
@@ -29,6 +30,10 @@ module Moodle2CC::Moodle2Converter
|
|
29
30
|
cc_course.pages += convert_labels(moodle_course.labels)
|
30
31
|
cc_course.pages += convert_glossaries(moodle_course)
|
31
32
|
|
33
|
+
cc_course.pages.each do |canvas_page|
|
34
|
+
canvas_page.href = generate_unique_resource_path(Moodle2CC::CanvasCC::Models::Page::WIKI_CONTENT, canvas_page.title)
|
35
|
+
end
|
36
|
+
|
32
37
|
cc_course.canvas_modules += convert_sections(moodle_course.sections)
|
33
38
|
|
34
39
|
resolve_duplicate_page_titles!(cc_course)
|
@@ -189,5 +194,13 @@ module Moodle2CC::Moodle2Converter
|
|
189
194
|
end
|
190
195
|
[Float::INFINITY]
|
191
196
|
end
|
197
|
+
|
198
|
+
def self.clear_unique_id_set!
|
199
|
+
@unique_id_set = Set.new
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.unique_id_set
|
203
|
+
@unique_id_set ||= Set.new
|
204
|
+
end
|
192
205
|
end
|
193
206
|
end
|
@@ -31,8 +31,6 @@ module Moodle2CC
|
|
31
31
|
canvas_page.workflow_state = workflow_state(moodle_section.visible)
|
32
32
|
canvas_page.editing_roles = CanvasCC::Models::Page::EDITING_ROLE_TEACHER
|
33
33
|
canvas_page.body = moodle_section.summary
|
34
|
-
canvas_page.href = generate_unique_resource_path(CanvasCC::Models::Page::WIKI_CONTENT, Moodle2CC::CanvasCC::Models::Page.convert_name_to_url("#{moodle_section.name}-summary"))
|
35
|
-
|
36
34
|
canvas_page
|
37
35
|
end
|
38
36
|
|
data/lib/moodle2cc/version.rb
CHANGED
@@ -18,16 +18,18 @@ module Moodle2CC::CanvasCC::Models
|
|
18
18
|
expect(page.identifier).to eq 3
|
19
19
|
end
|
20
20
|
|
21
|
-
it "sets the
|
21
|
+
it "sets the title" do
|
22
22
|
page.page_name = 'My Page Name'
|
23
|
-
expect(page.href).to eq 'wiki_content/my-page-name.html'
|
24
23
|
expect(page.title).to eq 'My Page Name'
|
25
24
|
end
|
26
25
|
|
26
|
+
it "converts names to urls" do
|
27
|
+
expect(page.class.convert_name_to_url('My Page Name')).to eq 'my-page-name'
|
28
|
+
end
|
29
|
+
|
27
30
|
it "truncates urls that are too long" do
|
28
|
-
|
29
|
-
|
30
|
-
expect(page.href).to eq expected
|
31
|
+
expected = "#{'a' * Moodle2CC::CanvasCC::Models::Page::MAX_URL_LENGTH}"
|
32
|
+
expect(page.class.convert_name_to_url('a' * 500)).to eq expected
|
31
33
|
end
|
32
34
|
|
33
35
|
end
|
@@ -13,6 +13,7 @@ describe Moodle2CC::CanvasCC::PageWriter do
|
|
13
13
|
page.identifier = 'my_id'
|
14
14
|
page.workflow_state = 'active'
|
15
15
|
page.body = '<h2>This is the body</h2>'
|
16
|
+
page.href = "testhref.html"
|
16
17
|
page.editing_roles = 'teachers'
|
17
18
|
page.page_name ='My Page Title'
|
18
19
|
writer.write
|
@@ -50,8 +50,6 @@ module Moodle2CC
|
|
50
50
|
|
51
51
|
describe '#convert_to_pages' do
|
52
52
|
it 'converts a moodle label with intro content to a page' do
|
53
|
-
subject.stub(:generate_unique_identifier) { 'some_random_id' }
|
54
|
-
|
55
53
|
moodle_label.id = '1'
|
56
54
|
moodle_label.name = 'label title'
|
57
55
|
moodle_label.intro = '<div>hey look i also have html content</div>'
|
@@ -67,7 +65,6 @@ module Moodle2CC
|
|
67
65
|
expect(page.title).to eq 'label title'
|
68
66
|
expect(page.editing_roles).to eq CanvasCC::Models::Page::EDITING_ROLE_TEACHER
|
69
67
|
expect(page.body).to eq moodle_label.intro
|
70
|
-
expect(page.href).to end_with("label-title.html")
|
71
68
|
end
|
72
69
|
|
73
70
|
it 'does not convert a plain moodle label to a page' do
|
@@ -6,7 +6,7 @@ module Moodle2CC
|
|
6
6
|
let(:canvas_course) { CanvasCC::Models::Course.new }
|
7
7
|
|
8
8
|
let(:moodle_course) { Moodle2CC::Moodle2::Models::Course.new }
|
9
|
-
let(:canvas_page) { Moodle2CC::CanvasCC::Models::Page.new }
|
9
|
+
let(:canvas_page) { p = Moodle2CC::CanvasCC::Models::Page.new; p.title = "sometitle"; p }
|
10
10
|
let(:canvas_discussion) {Moodle2CC::CanvasCC::Models::Discussion.new}
|
11
11
|
let(:canvas_assignment) {Moodle2CC::CanvasCC::Models::Assignment.new}
|
12
12
|
let(:canvas_assessment) {Moodle2CC::CanvasCC::Models::Assessment.new}
|
@@ -55,8 +55,10 @@ module Moodle2CC
|
|
55
55
|
it 'converts pages' do
|
56
56
|
moodle_course.pages = [:page1, :page2]
|
57
57
|
Moodle2Converter::PageConverter.any_instance.stub(:convert).and_return(canvas_page)
|
58
|
+
migrator.stub(:generate_unique_identifier).and_return('some_random_id')
|
58
59
|
migrator.migrate
|
59
60
|
expect(canvas_course.pages.compact).to eq [canvas_page, canvas_page]
|
61
|
+
expect(canvas_course.pages.first.href).to eq 'wiki_content/some_random_id/sometitle.html'
|
60
62
|
end
|
61
63
|
|
62
64
|
it 'converts wikis' do
|
@@ -42,7 +42,6 @@ module Moodle2CC
|
|
42
42
|
|
43
43
|
describe '#convert_to_summary_page' do
|
44
44
|
it 'converts the section summary to a page' do
|
45
|
-
subject.stub(:generate_unique_identifier).and_return('some_random_id')
|
46
45
|
moodle_section.name = 'Name'
|
47
46
|
moodle_section.summary = 'Summary Content'
|
48
47
|
moodle_section.visible = true
|
@@ -55,7 +54,6 @@ module Moodle2CC
|
|
55
54
|
expect(page.workflow_state).to eq 'active'
|
56
55
|
expect(page.editing_roles).to eq 'teachers'
|
57
56
|
expect(page.body).to eq 'Summary Content'
|
58
|
-
expect(page.href).to eq 'wiki_content/some_random_id/name-summary.html'
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,12 @@ require 'rspec'
|
|
2
2
|
require 'moodle2cc'
|
3
3
|
Dir["./spec/support/**/*.rb"].sort.each {|f| require f}
|
4
4
|
|
5
|
+
RSpec.configure do |c|
|
6
|
+
c.after :each do
|
7
|
+
Moodle2CC::Moodle2Converter::Migrator.clear_unique_id_set!
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
def fixture_path(path)
|
6
12
|
File.join(File.expand_path("../../test/fixtures", __FILE__), path)
|
7
13
|
end
|
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.2.
|
4
|
+
version: 0.2.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Durtschi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-10-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rubyzip
|