Class: Qti::V1::Models::Interactions::ChoiceInteraction
- Inherits:
-
BaseInteraction
- Object
- Models::Base
- Base
- BaseInteraction
- Qti::V1::Models::Interactions::ChoiceInteraction
- Defined in:
- lib/qti/v1/models/interactions/choice_interaction.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Models::Base
Instance Attribute Summary
Attributes inherited from BaseInteraction
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path
Class Method Summary collapse
-
.matches(node, parent) ⇒ Object
This will know if a class matches.
Instance Method Summary collapse
Methods inherited from BaseInteraction
canvas_multiple_fib?, #initialize, #rcardinality, #shuffled?
Methods inherited from Base
#qti_version, #return_inner_content!
Methods inherited from Models::Base
#css_with_single_check, from_path!, #initialize, #object_tag_transformer, #parse_html, #parse_xml, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #sanitize_content!, #xpath_with_single_check
Constructor Details
This class inherits a constructor from Qti::V1::Models::Interactions::BaseInteraction
Class Method Details
.matches(node, parent) ⇒ Object
This will know if a class matches
7 8 9 10 11 12 13 |
# File 'lib/qti/v1/models/interactions/choice_interaction.rb', line 7 def self.matches(node, parent) matches = node.xpath('.//xmlns:response_lid') return false if matches.count > 1 || matches.empty? rcardinality = matches.first.attributes['rcardinality']&.value || 'Single' return false if rcardinality == 'Ordered' new(node, parent) end |
Instance Method Details
#answers ⇒ Object
15 16 17 18 19 |
# File 'lib/qti/v1/models/interactions/choice_interaction.rb', line 15 def answers @answers ||= answer_nodes.map do |node| V1::Models::Choices::LogicalIdentifierChoice.new(node, self) end end |
#scoring_data_structs ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/qti/v1/models/interactions/choice_interaction.rb', line 21 def scoring_data_structs choice_nodes = node.xpath('.//xmlns:respcondition') if choice_nodes.at_xpath('.//xmlns:and').present? scoring_data_condition(choice_nodes) else scoring_data(choice_nodes) end end |