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

Constants inherited from Models::Base

Models::Base::ELEMENTS_REMAP

Instance Method Summary collapse

Methods inherited from Base

#qti_version

Methods inherited from Models::Base

#css_with_single_check, from_path!, #parse_xml, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #sanitize_content!, #xpath_with_single_check

Constructor Details

#initialize(node) ⇒ SimpleChoice

Returns a new instance of SimpleChoice.



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

def initialize(node)
  @node = node
end

Instance Method Details

#identifierObject



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

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

#item_bodyObject



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

def item_body
  @item_body ||= begin
    node = @node.dup
    node.children.filter(PROHIBITED_NODE_NAMES).map(&:unlink)
    node.content.strip.gsub(/\s+/, ' ')
  end
end