Class: Qti::V2::Models::Interactions::MatchInteraction

Inherits:
BaseInteraction show all
Extended by:
Forwardable
Defined in:
lib/qti/v2/models/interactions/match_interaction.rb

Direct Known Subclasses

CategorizationInteraction

Constant Summary

Constants inherited from Base

Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS

Instance Attribute Summary collapse

Attributes inherited from BaseInteraction

#node

Attributes inherited from Models::Base

#doc, #manifest, #package_root, #path, #resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseInteraction

#canvas_item_feedback, #shuffled?, #xpath_with_single_check

Methods inherited from Base

#qti_version

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!, #xpath_with_single_check

Constructor Details

#initialize(node, parent, implementation) ⇒ MatchInteraction

Returns a new instance of MatchInteraction.



13
14
15
16
# File 'lib/qti/v2/models/interactions/match_interaction.rb', line 13

def initialize(node, parent, implementation)
  super(node, parent)
  @implementation = implementation.new(node, parent)
end

Instance Attribute Details

#implementationObject (readonly)

Returns the value of attribute implementation.



11
12
13
# File 'lib/qti/v2/models/interactions/match_interaction.rb', line 11

def implementation
  @implementation
end

Class Method Details

.matches(node, parent) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/qti/v2/models/interactions/match_interaction.rb', line 24

def self.matches(node, parent)
  implementation =
    if use_associate_interaction_implementation?(node)
      MatchItemTagProcessors::AssociateInteractionTagProcessor
    elsif use_match_interaction_implementation?(node)
      MatchItemTagProcessors::MatchInteractionTagProcessor
    end

  return false unless implementation.present?
  new(node, parent, implementation)
end

.use_associate_interaction_implementation?(node) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
# File 'lib/qti/v2/models/interactions/match_interaction.rb', line 36

def self.use_associate_interaction_implementation?(node)
  MatchItemTagProcessors::AssociateInteractionTagProcessor.associate_interaction_tag?(node) &&
    MatchItemTagProcessors::AssociateInteractionTagProcessor.number_of_questions_per_answer(node)
                                                            .all? { |n| n == 1 }
end

.use_match_interaction_implementation?(node) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
# File 'lib/qti/v2/models/interactions/match_interaction.rb', line 42

def self.use_match_interaction_implementation?(node)
  MatchItemTagProcessors::MatchInteractionTagProcessor.match_interaction_tag?(node) &&
    MatchItemTagProcessors::MatchInteractionTagProcessor.number_of_questions_per_answer(node)
                                                        .all? { |n| n == 1 }
end

Instance Method Details

#scoring_data_structsObject



20
21
22
# File 'lib/qti/v2/models/interactions/match_interaction.rb', line 20

def scoring_data_structs
  implementation.scoring_data_structs
end