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

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

Constant Summary

Constants inherited from Base

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

Constants inherited from Models::Base

Models::Base::ELEMENTS_REMAP

Instance Attribute Summary

Attributes inherited from Models::Base

#doc, #manifest, #package_root, #path

Instance Method Summary collapse

Methods inherited from AssessmentTest

#assessment_sections, #create_assessment_item, #create_stimulus, #test_parts, #title

Methods inherited from Base

#qti_version

Methods inherited from Models::Base

#css_with_single_check, from_path!, #initialize, #object_tag_transformer, #parse_html, #parse_xml, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #sanitize_content!, #xpath_with_single_check

Constructor Details

This class inherits a constructor from Qti::Models::Base

Instance Method Details

#assessment_itemsObject



7
8
9
10
11
12
13
14
# File 'lib/qti/v2/models/non_assessment_test.rb', line 7

def assessment_items
  # Return the xml files we should be parsing
  @assessment_item_reference_hrefs ||= begin
    hrefs.map do |href|
      remap_href_path(href)
    end
  end
end

#hrefsObject



24
25
26
27
28
29
30
# File 'lib/qti/v2/models/non_assessment_test.rb', line 24

def hrefs
  if xpath_with_single_check("//xmlns:resource[@type='imsqti_item_xmlv2p1']/@href")&.value
    @doc.xpath("//xmlns:resource[@type='imsqti_item_xmlv2p1']/@href")
  else xpath_with_single_check("//xmlns:resource[@type='imsqti_item_xmlv2p2']/@href")&.value
    @doc.xpath("//xmlns:resource[@type='imsqti_item_xmlv2p2']/@href")
  end
end

#stimulus_ref(assessment_item_ref) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/qti/v2/models/non_assessment_test.rb', line 16

def stimulus_ref(assessment_item_ref)
  ref = assessment_item_ref.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