Class: Moodle2CC::Moodle2Converter::BookConverter
- Inherits:
-
Object
- Object
- Moodle2CC::Moodle2Converter::BookConverter
show all
- Includes:
- ConverterHelper
- Defined in:
- lib/moodle2cc/moodle2converter/book_converter.rb
Constant Summary
ConverterHelper::ACTIVITY_LOOKUP, ConverterHelper::ASSESSMENT_SUFFIX, ConverterHelper::ASSIGNMENT_SUFFIX, ConverterHelper::CHAPTER_SUFFIX, ConverterHelper::CHOICE_ASSESSMENT_SUFFIX, ConverterHelper::COURSE_SUFFIX, ConverterHelper::DISCUSSION_SUFFIX, ConverterHelper::EXTERNAL_URL_SUFFIX, ConverterHelper::FEEDBACK_ASSESSMENT_SUFFIX, ConverterHelper::FILE_SUFFIX, ConverterHelper::FOLDER_SUFFIX, ConverterHelper::GLOSSARY_SUFFIX, ConverterHelper::INTRO_SUFFIX, ConverterHelper::LTI_SUFFIX, ConverterHelper::MAX_TITLE_LENGTH, ConverterHelper::MODULE_SUFFIX, ConverterHelper::PAGE_SUFFIX, ConverterHelper::QUESTIONNAIRE_ASSESSMENT_SUFFIX, ConverterHelper::QUESTION_BANK_SUFFIX, ConverterHelper::SUMMARY_PAGE_SUFFIX
Instance Method Summary
collapse
#activity_content_type, #generate_unique_identifier, #generate_unique_identifier_for, #generate_unique_identifier_for_activity, #generate_unique_resource_path, #get_unique_identifier_for_activity, #truncate_text, #workflow_state
Instance Method Details
#convert(moodle_book) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/moodle2cc/moodle2converter/book_converter.rb', line 5
def convert(moodle_book)
canvas_module = convert_moodle_book(moodle_book)
moodle_book.chapters.each do |chapter|
canvas_module.module_items << convert_moodle_chapter(moodle_book, chapter)
end
canvas_module
end
|
#convert_to_module_items(moodle_book) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/moodle2cc/moodle2converter/book_converter.rb', line 36
def convert_to_module_items(moodle_book)
module_items = []
module_items << create_title(moodle_book)
module_items << create_introduction(moodle_book) if moodle_book.intro && moodle_book.intro.length > 0
module_items += moodle_book.chapters.map { |chapter| create_chapter(chapter) }
module_items
end
|
#convert_to_pages(moodle_book) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/moodle2cc/moodle2converter/book_converter.rb', line 13
def convert_to_pages(moodle_book)
pages = moodle_book.chapters.map do |moodle_chapter|
page = create_page(moodle_chapter.title)
page.identifier = generate_unique_identifier_for_activity(moodle_chapter)
page.body = moodle_chapter.content
page.workflow_state = workflow_state(moodle_book.visible)
page
end
if moodle_book.intro && moodle_book.intro.length > 0
page = create_page(moodle_book.name)
page.identifier = generate_unique_identifier_for_activity(moodle_book)
page.body = moodle_book.intro
if pages.any?{|p| page.title == p.title}
page.title = "#{truncate_text(page.title, MAX_TITLE_LENGTH - 20)} (Introduction)"
end
page.workflow_state = workflow_state(moodle_book.visible)
pages.unshift(page)
end
pages
end
|