class Qti::V1::Models::Interactions::NumericInteraction

Public Class Methods

matches(node, parent) click to toggle source

This will know if a class matches

# File lib/qti/v1/models/interactions/numeric_interaction.rb, line 7
def self.matches(node, parent)
  first_match = node.at_xpath('.//xmlns:render_fib')
  return false unless first_match && first_match.attributes['fibtype']&.value == 'Decimal'
  return false if node.xpath('.//xmlns:render_fib').count > 1
  new(node, parent)
end

Public Instance Methods

item_body() click to toggle source
# File lib/qti/v1/models/interactions/numeric_interaction.rb, line 14
def item_body
  @item_body ||= begin
    node = @node.dup
    presentation = node.at_xpath('.//xmlns:presentation')
    mattext = presentation.at_xpath('.//xmlns:mattext')
    inner_content = return_inner_content!(mattext)
    sanitize_content!(inner_content)
  end
end
scoring_data_structs() click to toggle source
# File lib/qti/v1/models/interactions/numeric_interaction.rb, line 24
def scoring_data_structs
  answer_nodes.map do |value_node|
    V1::Models::Numerics::ScoringData.new(
      value_node
    ).scoring_data
  end
end

Private Instance Methods

answer_nodes() click to toggle source
# File lib/qti/v1/models/interactions/numeric_interaction.rb, line 34
def answer_nodes
  @node.xpath('.//xmlns:respcondition/xmlns:setvar[@varname="SCORE"]/..')
end