Class: Qti::Models::Resource
Instance Attribute Summary
Attributes inherited from Base
#doc, #manifest, #package_root, #path, #resource
Instance Method Summary
collapse
#rtype_predicate, #xpath_endswith, #xpath_resource
#metadata_from_node!
Methods inherited from Base
#css_with_single_check, from_path!, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!, #xpath_with_single_check
Constructor Details
#initialize(node, parent) ⇒ Resource
14
15
16
17
18
19
20
|
# File 'lib/qti/models/resource.rb', line 14
def initialize(node, parent)
@node = node
@parent = parent
@resource_type = node.attr('type')
@identifier = node.attr('identifier')
copy_paths_from_item(parent)
end
|
Instance Method Details
37
38
39
40
41
42
43
|
# File 'lib/qti/models/resource.rb', line 37
def (filename)
dep_id = dependency_id
rsc = @parent.resource_node(
"[@identifier='#{dep_id}']/xmlns:file[#{xpath_endswith('@href', filename)}]/@href"
)
rsc&.content
end
|
30
31
32
33
34
35
|
# File 'lib/qti/models/resource.rb', line 30
def canvas_metadata
@canvas_meta_file ||= ('assessment_meta.xml')
return unless @canvas_meta_file
meta_file = File.join(@package_root, @canvas_meta_file)
@canvas_metadata ||= Qti::Models::AssessmentMeta.from_path!(meta_file) if @canvas_meta_file
end
|
#href ⇒ Object
22
23
24
|
# File 'lib/qti/models/resource.rb', line 22
def href
@href ||= @node.attr('href') || @node.xpath('xmlns:file/@href')&.first&.content
end
|
26
27
28
|
# File 'lib/qti/models/resource.rb', line 26
def metadata
@metadata = metadata_from_node!(@node)
end
|