module Qti::Models::ResourceGroup
Constants
- ASSESSMENT_CLASSES
- EMBEDDED_NON_ASSESSMENT_ID
- EMBEDDED_QTI_TYPES
- RESOURCE_QTI_TYPES
Public Instance Methods
assessment_identifiers(embedded_as_assessment = true)
click to toggle source
# File lib/qti/models/resource.rb, line 94 def assessment_identifiers(embedded_as_assessment = true) id_list = identifier_list('/assessment') return id_list + [EMBEDDED_NON_ASSESSMENT_ID] if embedded_as_assessment && embedded_non_assessment? id_list end
asset_resource_for(rsc)
click to toggle source
# File lib/qti/models/resource.rb, line 64 def asset_resource_for(rsc) asset_resource_for_canvas(rsc) || asset_resource_for_ims(rsc) end
asset_resource_for_canvas(rsc)
click to toggle source
# File lib/qti/models/resource.rb, line 68 def asset_resource_for_canvas(rsc) rsc.canvas_extra_file('.xml.qti') end
asset_resource_for_ims(rsc)
click to toggle source
# File lib/qti/models/resource.rb, line 72 def asset_resource_for_ims(rsc) rsc.href end
associated_content_list()
click to toggle source
# File lib/qti/models/resource.rb, line 100 def associated_content_list predicate = rtype_predicate('associatedcontent', 'learning-application-resource') xmlns_resource_list("[#{predicate}]").map { |r| r[:identifier] } end
identifier_list(rsc_type)
click to toggle source
# File lib/qti/models/resource.rb, line 82 def identifier_list(rsc_type) RESOURCE_QTI_TYPES.map do |v| xmlns_resource_list("[#{rtype_predicate(v, rsc_type)}]").map { |r| r[:identifier] } end.flatten end
item_resources_v2()
click to toggle source
# File lib/qti/models/resource.rb, line 122 def item_resources_v2 nodes = resources('[@type="imsqti_item_xmlv2p2"]') return nodes if nodes.count >= 1 resources('[@type="imsqti_item_xmlv2p1"]') end
load_asset_resource(rsc_path)
click to toggle source
# File lib/qti/models/resource.rb, line 76 def load_asset_resource(rsc_path) doc = Nokogiri.XML(File.read(rsc_path), rsc_path.to_s, &:noblanks) raise ArgumentError unless doc doc end
load_associated_content()
click to toggle source
# File lib/qti/models/resource.rb, line 105 def load_associated_content @_load_associated_content ||= associated_content_list.map do |ident| rsc = resource_for(ident) rsc_path = remap_href_path(asset_resource_for(rsc)) doc = load_asset_resource(rsc_path) # There are other types, but all we support right now are object banks... Qti::V1::Models::ObjectBank.from_path!(rsc_path, @package_root, rsc) unless doc.search('objectbank').empty? end.reject(&:nil?) end
objectbanks()
click to toggle source
# File lib/qti/models/resource.rb, line 116 def objectbanks load_associated_content.select do |c| c.class == Qti::V1::Models::ObjectBank end end
resource_for(identifier, qti_type = nil)
click to toggle source
# File lib/qti/models/resource.rb, line 88 def resource_for(identifier, qti_type = nil) qti_type = " and starts-with(@type, '#{qti_type}')" if qti_type base_xpath = "[@identifier='#{identifier}'#{qti_type}]" Resource.new(resource_node(base_xpath), self) end
resource_node(type)
click to toggle source
# File lib/qti/models/resource.rb, line 128 def resource_node(type) xpath_with_single_check(xpath_resource(type)) end
resources(type = '')
click to toggle source
# File lib/qti/models/resource.rb, line 60 def resources(type = '') @doc.xpath(xpath_resource(type)) end