Class: Qti::V2::Models::Choices::SimpleChoice

Inherits:
Base show all
Defined in:
lib/qti/v2/models/choices/simple_choice.rb

Direct Known Subclasses

SimpleAssociableChoice

Constant Summary collapse

PROHIBITED_NODE_NAMES =
%w[feedbackInline].join(',').freeze

Constants inherited from Base

Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS

Instance Attribute Summary

Attributes inherited from Models::Base

#doc, #manifest, #package_root, #path, #resource

Instance Method Summary collapse

Methods inherited from Base

#qti_version

Methods inherited from Models::Base

#css_with_single_check, from_path!, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!, #xpath_with_single_check

Constructor Details

#initialize(node, parent) ⇒ SimpleChoice

Returns a new instance of SimpleChoice.



8
9
10
11
# File 'lib/qti/v2/models/choices/simple_choice.rb', line 8

def initialize(node, parent)
  @node = node
  copy_paths_from_item(parent)
end

Instance Method Details

#identifierObject



13
14
15
# File 'lib/qti/v2/models/choices/simple_choice.rb', line 13

def identifier
  @identifier ||= @node.attributes['identifier'].value
end

#item_bodyObject



17
18
19
20
21
22
23
# File 'lib/qti/v2/models/choices/simple_choice.rb', line 17

def item_body
  @item_body ||= begin
    node = @node.dup
    node.children.filter(PROHIBITED_NODE_NAMES).map(&:unlink)
    sanitize_content!(node.to_html)
  end
end