Class: Qti::V1::Models::Base
- Inherits:
-
Models::Base
- Object
- Models::Base
- Qti::V1::Models::Base
- Defined in:
- lib/qti/v1/models/base.rb
Direct Known Subclasses
Assessment, AssessmentItem, BankEntryItem, Choices::FillBlankChoice, Choices::LogicalIdentifierChoice, Interactions::BaseInteraction, QuestionGroup, StimulusItem
Instance Attribute Summary
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path, #resource
Instance Method Summary collapse
- #qti_version ⇒ Object
- #return_inner_content!(node) ⇒ Object
- #sanitize_attributes(html) ⇒ Object
- #sanitize_attributes_by_node(node) ⇒ Object
Methods inherited from Models::Base
#css_with_single_check, from_path!, #initialize, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!, #xpath_with_single_check
Constructor Details
This class inherits a constructor from Qti::Models::Base
Instance Method Details
#qti_version ⇒ Object
7 8 9 |
# File 'lib/qti/v1/models/base.rb', line 7 def qti_version 1 end |
#return_inner_content!(node) ⇒ Object
11 12 13 14 15 |
# File 'lib/qti/v1/models/base.rb', line 11 def return_inner_content!(node) return CGI.unescapeHTML(node.inner_html).html_safe if html_node?(node) return node.text if text_node?(node) node.inner_html end |
#sanitize_attributes(html) ⇒ Object
17 18 19 20 21 |
# File 'lib/qti/v1/models/base.rb', line 17 def sanitize_attributes(html) node = Nokogiri::HTML.fragment(html) sanitize_attributes_by_node(node) node.to_html end |
#sanitize_attributes_by_node(node) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/qti/v1/models/base.rb', line 23 def sanitize_attributes_by_node(node) node.attribute_nodes.each do |a| matches = a.value.match(CANVAS_BLANK_REGEX) || [] a.value = a.value.gsub!('[', '[').gsub!(']', ']') if matches.length.positive? end node.children.each { |c| sanitize_attributes_by_node(c) } end |