Class: Qti::V2::Models::StimulusItem
- Inherits:
-
Base
show all
- Defined in:
- lib/qti/v2/models/stimulus_item.rb
Constant Summary
Constants inherited
from Base
Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS
Instance Attribute Summary
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path, #resource
Instance Method Summary
collapse
Methods inherited from Base
#qti_version
#css_with_single_check, from_path!, #initialize, #parse_html, #parse_xml, #preprocess_xml_doc, #raise_unsupported, #remap_href_path, #sanitize_content!, #xpath_with_single_check
Instance Method Details
#body ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/qti/v2/models/stimulus_item.rb', line 5
def body
@body ||= begin
item_body_node = xpath_with_single_check('//html/body')
node = item_body_node.dup
node.children.filter(INTERACTION_ELEMENTS_CSS).map(&:unlink)
sanitize_content!(node.to_html)
end
end
|
#identifier ⇒ Object
17
18
19
|
# File 'lib/qti/v2/models/stimulus_item.rb', line 17
def identifier
@identifier ||= File.basename(path, '.html')
end
|
#instructions ⇒ Object
29
30
31
|
# File 'lib/qti/v2/models/stimulus_item.rb', line 29
def instructions
nil
end
|
#orientation ⇒ Object
37
38
39
|
# File 'lib/qti/v2/models/stimulus_item.rb', line 37
def orientation
'left'
end
|
#source_url ⇒ Object
33
34
35
|
# File 'lib/qti/v2/models/stimulus_item.rb', line 33
def source_url
nil
end
|
#stimulus_type ⇒ Object
25
26
27
|
# File 'lib/qti/v2/models/stimulus_item.rb', line 25
def stimulus_type
'text'
end
|
#title ⇒ Object
21
22
23
|
# File 'lib/qti/v2/models/stimulus_item.rb', line 21
def title
@title ||= xpath_with_single_check('//html/head/title')&.content
end
|