Class: Moodle2CC::Moodle2Converter::HtmlConverter

Inherits:
Object
  • Object
show all
Includes:
ConverterHelper
Defined in:
lib/moodle2cc/moodle2converter/html_converter.rb

Constant Summary collapse

OBJECT_TOKEN =
"$CANVAS_OBJECT_REFERENCE$"
COURSE_TOKEN =
"$CANVAS_COURSE_REFERENCE$"
WIKI_TOKEN =
"$WIKI_REFERENCE$"
WEB_CONTENT_TOKEN =
"$IMS_CC_FILEBASE$"
MEDIA_TYPES =
{'mp3' => 'audio/mp3', 'wav' => 'audio/wav', 'mp4' => 'video/mp4', 'webm' => 'video/webm'}

Constants included from ConverterHelper

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

Methods included from ConverterHelper

#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

Constructor Details

#initialize(canvas_files, moodle_course) ⇒ HtmlConverter

Returns a new instance of HtmlConverter.



11
12
13
14
15
16
17
# File 'lib/moodle2cc/moodle2converter/html_converter.rb', line 11

def initialize(canvas_files, moodle_course)
  @moodle_course = moodle_course
  @file_index = {}
  @moodle_course.files.each do |f|
    @file_index[f.file_path.downcase + f.file_name.downcase] = canvas_files.find { |cc_f| cc_f.identifier == f.content_hash }
  end
end

Instance Method Details

#convert(content) ⇒ Object



19
20
21
22
23
# File 'lib/moodle2cc/moodle2converter/html_converter.rb', line 19

def convert(content)
  content = update_links(content.gsub('id="main"', ''))
  content = convert_equations(content)
  content
end