Class: Qti::V2::Models::NonAssessmentTest

Inherits:
AssessmentTest show all
Includes:
Models::ResourceGroup
Defined in:
lib/qti/v2/models/non_assessment_test.rb

Constant Summary collapse

QTIV2_TITLE_PATHS =
[
  "//*[local-name()='title' and namespace-uri()='http://ltsc.ieee.org/xsd/LOM']/*[local-name()='string']/text()"
].freeze

Constants included from Models::ResourceGroup

Models::ResourceGroup::ASSESSMENT_CLASSES, Models::ResourceGroup::EMBEDDED_NON_ASSESSMENT_ID, Models::ResourceGroup::EMBEDDED_QTI_TYPES, Models::ResourceGroup::RESOURCE_QTI_TYPES

Constants inherited from Base

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

Instance Attribute Summary

Attributes inherited from Models::Base

#doc, #manifest, #package_root, #path, #resource

Instance Method Summary collapse

Methods included from Models::ResourceGroup

#assessment_identifiers, #asset_resource_for, #asset_resource_for_canvas, #asset_resource_for_ims, #associated_content_list, #identifier_list, #item_resources_v2, #load_asset_resource, #load_associated_content, #objectbanks, #resource_for, #resource_node, #resources

Methods inherited from AssessmentTest

#assessment_sections, #create_assessment_item, #create_bank_entry_item, #create_stimulus, #identifier, #test_parts

Methods included from XPathHelpers

#rtype_predicate, #xpath_endswith, #xpath_resource

Methods included from Models::AssessmentMetaBase

#canvas_meta_data

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::Models::Base

Instance Method Details

#assessment_itemsObject



11
12
13
14
15
16
17
18
19
# File 'lib/qti/v2/models/non_assessment_test.rb', line 11

def assessment_items
  # Return the xml files we should be parsing
  @assessment_items ||= begin
    item_resources_v2.map do |node|
      rsc = Qti::Models::Resource.new(node, self)
      { path: remap_href_path(rsc.href), resource: rsc }
    end
  end
end

#stimulus_ref(assessment_item_ref) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/qti/v2/models/non_assessment_test.rb', line 21

def stimulus_ref(assessment_item_ref)
  ref = assessment_item_ref[:path].sub(@package_root, '')
  dependencies = @doc.xpath("//xmlns:resource[@href='#{ref}']/xmlns:dependency/@identifierref")
  return unless dependencies&.count == 1
  href = xpath_with_single_check("//xmlns:resource[@identifier='#{dependencies.first}']/@href")
  remap_href_path(href)
end

#titleObject



29
30
31
32
33
34
35
# File 'lib/qti/v2/models/non_assessment_test.rb', line 29

def title
  @title ||= begin
    QTIV2_TITLE_PATHS.map do |path|
      @doc.xpath(path).first&.content
    end.compact.first
  end || super
end