class Qti::V1::Models::AssessmentItem

Attributes

doc[R]
resource[R]

Public Class Methods

new(item, package_root = nil, resource = nil) click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 9
def initialize(item, package_root = nil, resource = nil)
  @doc = item
  @path = item.document.url
  @resource = resource
  self.package_root = package_root
end

Public Instance Methods

answer_feedback() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 89
def answer_feedback
  @answer_feedback ||= interaction_model.answer_feedback
end
decvar_maxvalue() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 66
def decvar_maxvalue
  @doc.at_xpath('.//xmlns:decvar/@maxvalue')&.value&.to_i ||
    @doc.at_xpath('.//xmlns:decvar/@defaultval')&.value&.to_i || 0
end
feedback() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 85
def feedback
  @feedback ||= interaction_model.canvas_item_feedback
end
has_points_possible_qti_metadata?() click to toggle source

@deprecated Please use {#points_possible_qti_metadata?} instead

# File lib/qti/v1/models/assessment_item.rb, line 48
def has_points_possible_qti_metadata? # rubocop:disable Naming/PredicateName
  warn "DEPRECATED: '#{__method__}' is renamed to 'points_possible_qti_metadata?'."
  points_possible_qti_metadata?
end
identifier() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 26
def identifier
  @identifier ||= @doc.attribute('ident').value
end
interaction_model() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 75
def interaction_model
  @interaction_model ||= begin
    V1::Models::Interactions.interaction_model(@doc, self)
  end
end
item_body() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 16
def item_body
  @item_body ||= begin
    node = @doc.dup
    presentation = node.at_xpath('.//xmlns:presentation')
    mattext = presentation.at_xpath('.//xmlns:mattext')
    prompt = return_inner_content!(mattext)
    sanitize_content!(prompt)
  end
end
points_possible() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 53
def points_possible
  @points_possible ||= begin
    if points_possible_qti_metadata?
      points_possible_label = qti_metadata_children.children.find do |node|
        node.text == 'points_possible'
      end
      points_possible_label.next.text
    else
      1
    end
  end
end
points_possible_qti_metadata?() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 38
def points_possible_qti_metadata?
  if @doc.at_xpath('.//xmlns:qtimetadata').present?
    points_possible_label = qti_metadata_children.children.find { |node| node.text == 'points_possible' }
    points_possible_label.present?
  else
    false
  end
end
qti_metadata_children() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 34
def qti_metadata_children
  @doc.at_xpath('.//xmlns:qtimetadata')&.children
end
rcardinality() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 71
def rcardinality
  @rcardinality ||= @doc.at_xpath('.//xmlns:response_lid/@rcardinality').value
end
scoring_data_structs() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 81
def scoring_data_structs
  @scoring_data_structs ||= interaction_model.scoring_data_structs
end
title() click to toggle source
# File lib/qti/v1/models/assessment_item.rb, line 30
def title
  @title ||= @doc.attribute('title')&.value
end