class Senkyoshi::Content
Constants
- CONTENT_TYPES
- MODULE_TYPES
Attributes
body[RW]
extendeddata[R]
files[RW]
title[RW]
url[RW]
Public Class Methods
from(xml, pre_data, resource_xids)
click to toggle source
# File lib/senkyoshi/models/content.rb, line 52 def self.from(xml, pre_data, resource_xids) type = xml.xpath("/CONTENT/CONTENTHANDLER/@value").first.text type.slice! "resource/" xml.xpath("//FILES/FILE").each do |file| file_name = ContentFile.clean_xid file.at("NAME").text is_attachment = CONTENT_TYPES[type] == "Attachment" if !resource_xids.include?(file_name) && is_attachment type = "x-bb-document" break end end if content_type = CONTENT_TYPES[type] content_class = Senkyoshi.const_get content_type content_class.new(pre_data[:file_name]).iterate_xml(xml, pre_data) end end
Public Instance Methods
canvas_conversion(course, _resources = nil)
click to toggle source
# File lib/senkyoshi/models/content.rb, line 110 def canvas_conversion(course, _resources = nil) course end
create_module(course)
click to toggle source
Calls superclass method
# File lib/senkyoshi/models/content.rb, line 114 def create_module(course) super(course) end
iterate_xml(xml, pre_data)
click to toggle source
# File lib/senkyoshi/models/content.rb, line 71 def iterate_xml(xml, pre_data) @points = pre_data[:points] || 0 @parent_title = pre_data[:parent_title] @indent = pre_data[:indent] @file_name = pre_data[:file_name] @title = xml.xpath("/CONTENT/TITLE/@value").first.text @url = xml.at("URL")["value"] @body = xml.xpath("/CONTENT/BODY/TEXT").first.text @extendeddata = xml.at("/CONTENT/EXTENDEDDATA/ENTRY") if @extendeddata @extendeddata = @extendeddata.text end @type = xml.xpath("/CONTENT/RENDERTYPE/@value").first.text @parent_id = pre_data[:parent_id] @module_type = MODULE_TYPES[self.class.name] @referred_to_title = pre_data[:referred_to_title] if pre_data[:assignment_id] && !pre_data[:assignment_id].empty? @id = pre_data[:assignment_id] end @files = xml.xpath("//FILES/FILE").map do |file| ContentFile.new(file) end @module_item = set_module if @module_type self end
set_module()
click to toggle source
# File lib/senkyoshi/models/content.rb, line 99 def set_module ModuleItem.new( @title, @module_type, @id, @url, @indent, @file_name, ).canvas_conversion end