Class: Senkyoshi::WikiPage
- Includes:
- Senkyoshi
- Defined in:
- lib/senkyoshi/models/wikipage.rb
Constant Summary
Constants included from Senkyoshi
BASE, PRE_RESOURCE_TYPE, RESOURCE_TYPE, VERSION
Constants inherited from Content
Content::CONTENT_TYPES, Content::MODULE_TYPES
Instance Attribute Summary
Attributes inherited from Content
#body, #extendeddata, #files, #id, #title, #url
Instance Method Summary collapse
- #_component_label(node) ⇒ Object
- #_extendeddata(extendeddata) ⇒ Object
- #_set_body(original_body, url, extendeddata) ⇒ Object
- #canvas_conversion(course, resources) ⇒ Object
Methods included from Senkyoshi
_config, account_id, build_file, build_heirarchy, canvas_token, canvas_url, cleanup, connect_content, create_canvas_course, create_random_hex, get_attribute_value, get_description, get_single_pre_data, get_text, get_title, initialize_course, iterate_files, iterate_xml, iterator_master, parse, parse_manifest, pre_iterator, read_file, scorm_launch_url, scorm_shared_auth, scorm_url, #true?
Methods inherited from Content
#create_module, from, #get_pre_data, #iterate_xml, #set_module
Methods inherited from Resource
#_search_and_replace, #cleanup, #fix_html, #matches_xid?
Instance Method Details
#_component_label(node) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/senkyoshi/models/wikipage.rb', line 65 def _component_label(node) visible = true?(node.search("vislableToStudents/@value").to_s) if visible component_label = node.search("componentLabel/@value").to_s overridden = true?(node.search("labelOverridden/@value").to_s) if overridden component_label else component_label.split(".").last.capitalize end else "" end end |
#_extendeddata(extendeddata) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/senkyoshi/models/wikipage.rb', line 55 def _extendeddata(extendeddata) Nokogiri::XML(extendeddata). search("LessonPlanComponent"). map do |node| _component_label(node) + node.search("componentValue/@value").to_s end. compact. join(" ") end |
#_set_body(original_body, url, extendeddata) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/senkyoshi/models/wikipage.rb', line 36 def _set_body(original_body, url, extendeddata) body = original_body.dup if !url.empty? body = %{ <a href="#{url}"> #{url} </a> #{body} } end if extendeddata body = %{ #{body} #{_extendeddata(extendeddata)} } end body end |
#canvas_conversion(course, resources) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/senkyoshi/models/wikipage.rb', line 7 def canvas_conversion(course, resources) unless @title == "--TOP--" page_count = course.pages. select { |p| p.title.start_with? @title }.count @title = "#{@title}-#{page_count + 1}" if page_count > 0 page = CanvasCc::CanvasCC::Models::Page.new @body = _set_body(@body, @url, @extendeddata) page.body = fix_html(@body, resources) page.identifier = @id page.page_name = @title page.workflow_state = "active" # Add page links to page body @files.each do |file| if canvas_file = course.files.detect { |f| f.identifier == file.name } page.body << file.canvas_conversion(canvas_file) else page.body << "<p>File: " + file.linkname + " -- doesn't exist in blackboard</p>" end end course.pages << page course = create_module(course) end course end |