class Qti::V2::Models::Interactions::ChoiceInteraction

Public Class Methods

matches(node, parent) click to toggle source
# File lib/qti/v2/models/interactions/choice_interaction.rb, line 6
def self.matches(node, parent)
  matches = node.xpath('.//xmlns:choiceInteraction')
  return false if matches.empty?

  raise Qti::UnsupportedSchema if matches.size > 1
  new(matches.first, parent)
end

Public Instance Methods

answers() click to toggle source
# File lib/qti/v2/models/interactions/choice_interaction.rb, line 14
def answers
  @answers ||= answer_nodes.map do |node|
    V2::Models::Choices::SimpleChoice.new(node, self)
  end
end
max_choices_count() click to toggle source
# File lib/qti/v2/models/interactions/choice_interaction.rb, line 20
def max_choices_count
  @node.attributes['maxChoices']&.value&.to_i
end
min_choices_count() click to toggle source
# File lib/qti/v2/models/interactions/choice_interaction.rb, line 24
def min_choices_count
  @node.attributes['minChoices']&.value&.to_i
end

Private Instance Methods

answer_nodes() click to toggle source
# File lib/qti/v2/models/interactions/choice_interaction.rb, line 30
def answer_nodes
  @node.xpath('.//xmlns:simpleChoice')
end