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, MatchItemTagProcessors::AssociateInteractionTagProcessor, MatchItemTagProcessors::MatchInteractionTagProcessor, ShortTextInteraction
Constant Summary
Constants inherited from Base
Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path, #resource
Class Method Summary collapse
Instance Method Summary collapse
- #canvas_item_feedback ⇒ Object
-
#initialize(node, parent) ⇒ 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_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!
Constructor Details
#initialize(node, parent) ⇒ BaseInteraction
Returns a new instance of BaseInteraction.
12 13 14 15 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 12 def initialize(node, parent) @node = node copy_paths_from_item(parent) 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
#canvas_item_feedback ⇒ Object
29 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 29 def canvas_item_feedback; end |
#scoring_data_structs ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 21 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
17 18 19 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 17 def shuffled? @node.attributes['shuffle']&.value.try(:downcase) == 'true' end |
#xpath_with_single_check(xpath) ⇒ Object
31 32 33 34 35 |
# File 'lib/qti/v2/models/interactions/base_interaction.rb', line 31 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 |