Class: Senkyoshi::Content
- Inherits:
-
FileResource
- Object
- Resource
- FileResource
- Senkyoshi::Content
- Defined in:
- lib/senkyoshi/models/content.rb
Direct Known Subclasses
Constant Summary collapse
- CONTENT_TYPES =
{ "x-bb-asmt-test-link" => "Quiz", "x-bb-asmt-survey-link" => "Quiz", "x-bb-assignment" => "Assignment", "x-bbpi-selfpeer-type1" => "Assignment", "x-bb-document" => "WikiPage", "x-bb-file" => "Attachment", "x-bb-audio" => "Attachment", "x-bb-image" => "Attachment", "x-bb-video" => "Attachment", "x-bb-externallink" => "ExternalUrl", "x-bb-blankpage" => "WikiPage", "x-bb-lesson" => "WikiPage", "x-bb-folder" => "WikiPage", "x-bb-module-page" => "WikiPage", "x-bb-lesson-plan" => "WikiPage", "x-bb-syllabus" => "WikiPage", "x-bb-courselink" => "WikiPage", }.freeze
- MODULE_TYPES =
{ "Senkyoshi::Attachment" => "Attachment", "Senkyoshi::Assignment" => "Assignment", "Senkyoshi::ExternalUrl" => "ExternalUrl", "Senkyoshi::WikiPage" => "WikiPage", "Senkyoshi::Quiz" => "Quizzes::Quiz", }.freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#extendeddata ⇒ Object
readonly
Returns the value of attribute extendeddata.
-
#files ⇒ Object
Returns the value of attribute files.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from FileResource
Class Method Summary collapse
Instance Method Summary collapse
- #canvas_conversion(course, _resources = nil) ⇒ Object
- #create_module(course) ⇒ Object
- #iterate_xml(xml, pre_data) ⇒ Object
- #set_module ⇒ Object
Methods inherited from FileResource
Methods inherited from Resource
#_find_directories, #_fix_path, #_matches_directory_xid?, #_search_and_replace, #cleanup, #fix_html, get_pre_data, #matches_xid?, #strip_xid
Constructor Details
This class inherits a constructor from Senkyoshi::FileResource
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
49 50 51 |
# File 'lib/senkyoshi/models/content.rb', line 49 def body @body end |
#extendeddata ⇒ Object (readonly)
Returns the value of attribute extendeddata.
50 51 52 |
# File 'lib/senkyoshi/models/content.rb', line 50 def extendeddata @extendeddata end |
#files ⇒ Object
Returns the value of attribute files.
49 50 51 |
# File 'lib/senkyoshi/models/content.rb', line 49 def files @files end |
#title ⇒ Object
Returns the value of attribute title.
49 50 51 |
# File 'lib/senkyoshi/models/content.rb', line 49 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
49 50 51 |
# File 'lib/senkyoshi/models/content.rb', line 49 def url @url end |
Class Method Details
.from(xml, pre_data, resource_xids) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# 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 = CONTENT_TYPES[type] == "Attachment" if !resource_xids.include?(file_name) && 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 |
Instance Method Details
#canvas_conversion(course, _resources = nil) ⇒ Object
110 111 112 |
# File 'lib/senkyoshi/models/content.rb', line 110 def canvas_conversion(course, _resources = nil) course end |
#create_module(course) ⇒ Object
114 115 116 |
# File 'lib/senkyoshi/models/content.rb', line 114 def create_module(course) super(course) end |
#iterate_xml(xml, pre_data) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# 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 ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/senkyoshi/models/content.rb', line 99 def set_module ModuleItem.new( @title, @module_type, @id, @url, @indent, @file_name, ).canvas_conversion end |