Class: CanvasCc::Canvas::DiscussionTopic
- Inherits:
-
CanvasCc::CC::DiscussionTopic
- Object
- CanvasCc::CC::DiscussionTopic
- CanvasCc::Canvas::DiscussionTopic
- Includes:
- Resource
- Defined in:
- lib/canvas_cc/canvas/discussion_topic.rb
Instance Attribute Summary collapse
-
#identifierref ⇒ Object
Returns the value of attribute identifierref.
-
#position ⇒ Object
Returns the value of attribute position.
-
#posted_at ⇒ Object
Returns the value of attribute posted_at.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #create_files(export_dir) ⇒ Object
- #create_module_meta_item_elements(item_node) ⇒ Object
- #create_resource_node(resources_node) ⇒ Object
- #create_resource_sub_nodes(resource_node) ⇒ Object
- #create_topic_meta_xml(export_dir) ⇒ Object
-
#initialize(mod, position = 0) ⇒ DiscussionTopic
constructor
A new instance of DiscussionTopic.
Methods included from Resource
Constructor Details
#initialize(mod, position = 0) ⇒ DiscussionTopic
Returns a new instance of DiscussionTopic.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 6 def initialize(mod, position=0) super @text = convert_file_path_tokens(mod.intro) if mod.section_mod && mod.section_mod.added.to_i > 0 @posted_at = ims_datetime(Time.at(mod.section_mod.added)) end @position = position @type = 'topic' @identifierref = create_key(@id, 'topic_meta_') end |
Instance Attribute Details
#identifierref ⇒ Object
Returns the value of attribute identifierref.
4 5 6 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 4 def identifierref @identifierref end |
#position ⇒ Object
Returns the value of attribute position.
4 5 6 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 4 def position @position end |
#posted_at ⇒ Object
Returns the value of attribute posted_at.
4 5 6 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 4 def posted_at @posted_at end |
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 4 def type @type end |
Instance Method Details
#create_files(export_dir) ⇒ Object
34 35 36 37 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 34 def create_files(export_dir) super (export_dir) end |
#create_module_meta_item_elements(item_node) ⇒ Object
63 64 65 66 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 63 def (item_node) item_node.content_type 'DiscussionTopic' item_node.identifierref @identifier end |
#create_resource_node(resources_node) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 19 def create_resource_node(resources_node) super resources_node.resource( :type => LOR, :identifier => @identifierref, :href => "#{@identifierref}.xml" ) do |resource_node| resource_node.file(:href => "#{@identifierref}.xml") end end |
#create_resource_sub_nodes(resource_node) ⇒ Object
30 31 32 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 30 def create_resource_sub_nodes(resource_node) resource_node.dependency(:identifierref => @identifierref) end |
#create_topic_meta_xml(export_dir) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/canvas_cc/canvas/discussion_topic.rb', line 39 def (export_dir) path = File.join(export_dir, "#{@identifierref}.xml") File.open(path, 'w') do |file| document = Builder::XmlMarkup.new(:target => file, :indent => 2) document.instruct! document.topicMeta( :identifier => @identifierref, 'xsi:schemaLocation' => "http://canvas.instructure.com/xsd/cccv1p0 http://canvas.instructure.com/xsd/cccv1p0.xsd", 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns' => "http://canvas.instructure.com/xsd/cccv1p0" ) do || .topic_id identifier .title @title .posted_at @posted_at .position @position .type @type .pinned @pinned .delayed_post_at @delayed_post_at .lock_at @lock_at end end end |