Module: Qti::V2::Models::Interactions

Defined in:
lib/qti/v2/models/interactions.rb,
lib/qti/v2/models/interactions/choice_interaction.rb

Defined Under Namespace

Classes: ChoiceInteraction

Class Method Summary collapse

Class Method Details

.interaction_model(node) ⇒ Object

This one finds the correct parsing model based on the provided xml node

Raises:

  • (V2::UnsupportedSchema)


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/qti/v2/models/interactions.rb', line 9

def self.interaction_model(node)
  subclasses = constants.map { |c| const_get(c) }

  # Check for matches
  matches = subclasses.each_with_object([]) do |interaction_class, result|
    match = interaction_class.matches(node)
    result << match if match
  end

  raise V2::UnsupportedSchema if matches.size > 1

  matches.first
end