Class: Moodle2CC::CC::WebContent
- Inherits:
-
Object
- Object
- Moodle2CC::CC::WebContent
- Defined in:
- lib/moodle2cc/cc/web_content.rb
Direct Known Subclasses
Constant Summary
Constants included from CCHelper
CCHelper::ASSESSMENT_CC_QTI, CCHelper::ASSESSMENT_META, CCHelper::ASSESSMENT_NON_CC_FOLDER, CCHelper::ASSESSMENT_TYPE, CCHelper::ASSIGNMENT_GROUPS, CCHelper::ASSIGNMENT_SETTINGS, CCHelper::BASIC_LTI, CCHelper::BLTI_NAMESPACE, CCHelper::CANVAS_NAMESPACE, CCHelper::CANVAS_PLATFORM, CCHelper::CC_ASSIGNMENT_FOLDER, CCHelper::CC_EXTENSION, CCHelper::CC_WIKI_FOLDER, CCHelper::COURSE_SETTINGS, CCHelper::COURSE_SETTINGS_DIR, CCHelper::COURSE_TOKEN, CCHelper::DISCUSSION_TOPIC, CCHelper::EVENTS, CCHelper::EXTERNAL_FEEDS, CCHelper::EXTERNAL_TOOLS, CCHelper::FILES_META, CCHelper::GRADING_STANDARDS, CCHelper::IMS_DATE, CCHelper::IMS_DATETIME, CCHelper::LEARNING_OUTCOMES, CCHelper::LOR, CCHelper::MANIFEST, CCHelper::MEDIA_OBJECTS_FOLDER, CCHelper::MODULE_META, CCHelper::MOODLE_FILEBASE_TOKEN, CCHelper::MOODLE_SLASH_TOKEN, CCHelper::OBJECT_TOKEN, CCHelper::QTI_ASSESSMENT_TYPE, CCHelper::QTI_EXTENSION, CCHelper::QUESTION_BANK, CCHelper::RUBRICS, CCHelper::SYLLABUS, CCHelper::WEBCONTENT, CCHelper::WEB_CONTENT_TOKEN, CCHelper::WEB_LINK, CCHelper::WEB_RESOURCES_FOLDER, CCHelper::WIKI_FOLDER, CCHelper::WIKI_TOKEN, CCHelper::XSD_URI
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
Instance Method Summary collapse
- #create_files(export_dir) ⇒ Object
- #create_html(export_dir) ⇒ Object
- #create_resource_node(resources_node) ⇒ Object
-
#initialize(mod) ⇒ WebContent
constructor
A new instance of WebContent.
Methods included from Resource
#create_organization_item_node, included
Methods included from CCHelper
#convert_file_path_tokens, convert_file_path_tokens, #create_key, create_key, create_mod_key, #create_mod_key, #create_resource_key, create_resource_key, file_query_string, #file_slug, file_slug, #get_html_title_and_body, #get_html_title_and_body_and_id, #get_html_title_and_body_and_meta_fields, ims_date, #ims_date, ims_datetime, #ims_datetime, media_object_info
Constructor Details
#initialize(mod) ⇒ WebContent
Returns a new instance of WebContent.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/moodle2cc/cc/web_content.rb', line 8 def initialize(mod) super @rel_path = File.join(CC_WIKI_FOLDER, "#{file_slug(@title)}.html") body = mod.alltext body = mod.content || '' if body.nil? || body.length == 0 if body.nil? || body.length == 0 && mod.summary body = mod.summary url = mod.reference.to_s.strip unless url.gsub(%r{http(s)?://}, '').length == 0 body += %(<p><a href="#{CGI.escapeHTML(url)}" title="#{CGI.escapeHTML(@title)}">#{@title}</a></p>) end end @body = convert_file_path_tokens(body) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/moodle2cc/cc/web_content.rb', line 6 def body @body end |
Instance Method Details
#create_files(export_dir) ⇒ Object
34 35 36 |
# File 'lib/moodle2cc/cc/web_content.rb', line 34 def create_files(export_dir) create_html(export_dir) end |
#create_html(export_dir) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/moodle2cc/cc/web_content.rb', line 38 def create_html(export_dir) template = File.('../templates/wiki_content.html.erb', __FILE__) path = File.join(export_dir, @rel_path) FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w') do |file| erb = ERB.new(File.read(template)) file.write(erb.result(binding)) end end |
#create_resource_node(resources_node) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/moodle2cc/cc/web_content.rb', line 23 def create_resource_node(resources_node) href = @rel_path resources_node.resource( :type => WEBCONTENT, :identifier => identifier, :href => href ) do |resource_node| resource_node.file(:href => href) end end |