Class: Qti::V2::Models::Interactions::BaseInteraction
- Inherits:
-
Base
- Object
- Models::Base
- Base
- Qti::V2::Models::Interactions::BaseInteraction
- Defined in:
- lib/qti/v2/models/interactions/base_interaction.rb
Direct Known Subclasses
ChoiceInteraction, ExtendedTextInteraction, GapMatchInteraction, MatchInteraction, MatchItemTagProcesssors::AssociateInteractionTagProcessor, MatchItemTagProcesssors::MatchInteractionTagProcessor
Constant Summary
Constants inherited from Base
Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS
Constants inherited from Models::Base
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Attributes inherited from Models::Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(node) ⇒ BaseInteraction
constructor
A new instance of BaseInteraction.
- #scoring_data_structs ⇒ Object
- #shuffled? ⇒ Boolean
- #xpath_with_single_check(xpath) ⇒ Object
Methods inherited from Base
Methods inherited from Models::Base
#css_with_single_check, from_path!, #parse_xml, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #sanitize_content!
Constructor Details
#initialize(node) ⇒ BaseInteraction
Returns a new instance of BaseInteraction.
12 13 14 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 12 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
6 7 8 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 6 def node @node end |
Class Method Details
.matches(node) ⇒ Object
8 9 10 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 8 def self.matches(node) false end |
Instance Method Details
#scoring_data_structs ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 20 def scoring_data_structs @scoring_data_structs ||= begin type = xpath_with_single_check('//xmlns:responseDeclaration/@baseType').content value_nodes = node.xpath('//xmlns:responseDeclaration/xmlns:correctResponse/xmlns:value') value_nodes.map { |value_node| Models::ScoringData.new(value_node.content, type) } end end |
#shuffled? ⇒ Boolean
16 17 18 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 16 def shuffled? @node.attributes['shuffle']&.value.try(:downcase) == 'true' end |
#xpath_with_single_check(xpath) ⇒ Object
28 29 30 31 32 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 28 def xpath_with_single_check(xpath) node_list = node.xpath(xpath) raise Qti::ParseError, 'Too many matches' if node_list.count > 1 node_list.first end |