class Qti::Models::Manifest
Public Instance Methods
assessment_test(resource_id = nil)
click to toggle source
# File lib/qti/models/manifest.rb, line 7 def assessment_test(resource_id = nil) resource_id ||= assessment_identifiers.first test = assessment_from_identifier(resource_id) test.manifest = self test end
Private Instance Methods
assessment_from(version, identifier)
click to toggle source
# File lib/qti/models/manifest.rb, line 23 def assessment_from(version, identifier) builder = ASSESSMENT_CLASSES[version.split('/').first] raise_unsupported unless builder rsc = resource_for(identifier, version) assessment = builder.from_path!(remap_href_path(asset_resource_for(rsc)), @package_root, rsc) assessment.canvas_meta_data(rsc.canvas_metadata) assessment end
assessment_from_identifier(identifier)
click to toggle source
# File lib/qti/models/manifest.rb, line 16 def assessment_from_identifier(identifier) return embedded_non_assessment if identifier == EMBEDDED_NON_ASSESSMENT_ID rsc_ver = xpath_with_single_check(xpath_resource("[@identifier='#{identifier}']"))&.[](:type) raise_unsupported unless rsc_ver assessment_from(rsc_ver, identifier) end
embedded_non_assessment()
click to toggle source
# File lib/qti/models/manifest.rb, line 48 def embedded_non_assessment Qti::V2::Models::NonAssessmentTest.from_path!(@path, @package_root) end
embedded_non_assessment?()
click to toggle source
# File lib/qti/models/manifest.rb, line 44 def embedded_non_assessment? EMBEDDED_QTI_TYPES.map { |typ| xmlns_resource_count("[@type='#{typ}']/@href") }.flatten.sum.positive? end
xmlns_resource(type)
click to toggle source
# File lib/qti/models/manifest.rb, line 32 def xmlns_resource(type) xpath_with_single_check(xpath_resource(type)) end
xmlns_resource_count(type)
click to toggle source
# File lib/qti/models/manifest.rb, line 40 def xmlns_resource_count(type) xmlns_resource_list(type).count end
xmlns_resource_list(type)
click to toggle source
# File lib/qti/models/manifest.rb, line 36 def xmlns_resource_list(type) @doc.xpath(xpath_resource(type)) end