Class: Qti::V2::Models::Interactions::ChoiceInteraction

Inherits:
BaseInteraction show all
Defined in:
lib/qti/v2/models/interactions/choice_interaction.rb

Direct Known Subclasses

OrderingInteraction

Constant Summary

Constants inherited from Base

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

Instance Attribute Summary

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, #initialize, #scoring_data_structs, #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::BaseInteraction

Class Method Details

.matches(node, parent) ⇒ Object



6
7
8
9
10
11
12
# 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

Instance Method Details

#answersObject



14
15
16
17
18
# 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_countObject



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

def max_choices_count
  @node.attributes['maxChoices']&.value&.to_i
end

#min_choices_countObject



24
25
26
# File 'lib/qti/v2/models/interactions/choice_interaction.rb', line 24

def min_choices_count
  @node.attributes['minChoices']&.value&.to_i
end