Class: Qti::V1::Models::Interactions::HotSpotInteraction
- Inherits:
-
BaseInteraction
- Object
- Models::Base
- Base
- BaseInteraction
- Qti::V1::Models::Interactions::HotSpotInteraction
- Defined in:
- lib/qti/v1/models/interactions/hot_spot_interaction.rb
Instance Attribute Summary
Attributes inherited from BaseInteraction
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path, #resource
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from BaseInteraction
#answer_feedback, canvas_custom_fitb?, #canvas_item_feedback, canvas_multiple_fib?, #initialize, #locked_choices, maybe_question_type, new_quizzes_fib?, question_type, #rcardinality, #scoring_data_structs, #shuffled?
Methods inherited from Base
#qti_version, #return_inner_content!, #sanitize_attributes, #sanitize_attributes_by_node
Methods inherited from Models::Base
#css_with_single_check, from_path!, #initialize, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #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
6 7 8 9 10 11 12 |
# File 'lib/qti/v1/models/interactions/hot_spot_interaction.rb', line 6 def self.matches(node, parent) presentation = node.at_xpath('.//xmlns:presentation') return false unless presentation xy_responses = presentation.xpath('.//xmlns:response_xy') return false unless xy_responses.count.positive? new(node, parent) end |
Instance Method Details
#coordinates ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/qti/v1/models/interactions/hot_spot_interaction.rb', line 37 def coordinates @coordinates ||= begin raw_coordinates_array = raw_coordinates.split(',') return [] unless (raw_coordinates_array.length % 2).zero? raw_coordinates_array.each_slice(2).map do |point| { x: point[0].to_f, y: point[1].to_f } end end end |
#image_url ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/qti/v1/models/interactions/hot_spot_interaction.rb', line 24 def image_url @image_url ||= begin node = @node.dup presentation = node.at_xpath('.//xmlns:presentation') matimage = presentation.at_xpath('.//xmlns:matimage') matimage&.attributes&.[]('uri')&.value end end |
#item_body ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/qti/v1/models/interactions/hot_spot_interaction.rb', line 14 def item_body @item_body ||= begin node = @node.dup presentation = node.at_xpath('.//xmlns:presentation') mattext = presentation.at_xpath('.//xmlns:mattext') inner_content = return_inner_content!(mattext) sanitize_content!(inner_content) end end |
#shape_type ⇒ Object
33 34 35 |
# File 'lib/qti/v1/models/interactions/hot_spot_interaction.rb', line 33 def shape_type @shape_type ||= response_label&.attributes&.[]('rarea')&.value end |