Class: Qti::Models::Manifest

Inherits:
Base
  • Object
show all
Defined in:
lib/qti/models/manifest.rb

Constant Summary

Constants inherited from Base

Base::ELEMENTS_REMAP

Instance Attribute Summary

Attributes inherited from Base

#doc, #manifest, #package_root, #path

Instance Method Summary collapse

Methods inherited from 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_testObject



6
7
8
9
10
# File 'lib/qti/models/manifest.rb', line 6

def assessment_test
  test = qti_2_x_href || qti_1_href || qti_2_non_assessment_href || unknown_type
  test.manifest = self
  test
end

#qti_1_hrefObject



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

def qti_1_href
  test_path = xmlns_resource("[@type='imsqti_xmlv1p2']/@href") ||
              xmlns_resource("[@type='imsqti_xmlv1p2']/xmlns:file/@href")
  return unless test_path
  Qti::V1::Models::Assessment.from_path!(
    remap_href_path(test_path), @package_root
  )
end

#qti_2_non_assessment_hrefObject



30
31
32
33
34
# File 'lib/qti/models/manifest.rb', line 30

def qti_2_non_assessment_href
  item_path = @doc.at_xpath("//xmlns:resources/xmlns:resource[@type='imsqti_item_xmlv2p1']/@href")&.content ||
              @doc.at_xpath("//xmlns:resources/xmlns:resource[@type='imsqti_item_xmlv2p2']/@href")
  Qti::V2::Models::NonAssessmentTest.from_path!(@path, @package_root) if item_path
end

#qti_2_x_hrefObject



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

def qti_2_x_href
  test_path = xmlns_resource("[@type='imsqti_test_xmlv2p1']/@href") ||
              xmlns_resource("[@type='imsqti_test_xmlv2p2']/@href")
  return unless test_path
  Qti::V2::Models::AssessmentTest.from_path!(
    remap_href_path(test_path), @package_root
  )
end

#unknown_typeObject



36
37
38
# File 'lib/qti/models/manifest.rb', line 36

def unknown_type
  raise Qti::UnsupportedSchema, 'Unsupported QTI version'
end