Class: Qti::V2::Models::Interactions::CategorizationInteraction

Inherits:
MatchInteraction show all
Defined in:
lib/qti/v2/models/interactions/categorization_interaction.rb

Constant Summary

Constants inherited from Base

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

Instance Attribute Summary

Attributes inherited from MatchInteraction

#implementation

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 MatchInteraction

#initialize, use_associate_interaction_implementation?

Methods inherited from BaseInteraction

#canvas_item_feedback, #initialize, #shuffled?, #xpath_with_single_check

Methods inherited from Base

#qti_version

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::V2::Models::Interactions::MatchInteraction

Class Method Details

.matches(node, parent) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/qti/v2/models/interactions/categorization_interaction.rb', line 8

def self.matches(node, parent)
  if use_match_interaction_implementation?(node)
    new(node, parent, MatchItemTagProcessors::MatchInteractionTagProcessor)
  else
    false
  end
end

.use_match_interaction_implementation?(node) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/qti/v2/models/interactions/categorization_interaction.rb', line 16

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

Instance Method Details

#scoring_data_structsObject



22
23
24
25
26
27
28
# File 'lib/qti/v2/models/interactions/categorization_interaction.rb', line 22

def scoring_data_structs
  questions_categories_choices_hash.map do |category_choice, questions_choices|
    ScoringData.new(category_choice.text, 'directedPair',
      id: node_identifier(category_choice),
      questions_ids: questions_choices.map { |q| node_identifier(q) })
  end
end