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

Methods inherited from Models::Base

#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

Constructor Details

This class inherits a constructor from Qti::Models::Base

Instance Method Details

#bodyObject



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

    # Filter undesired interaction nodes out of the list (need to make this a deep traversal)
    node.children.filter(INTERACTION_ELEMENTS_CSS).map(&:unlink)
    sanitize_content!(node.to_html)
  end
end

#identifierObject

Not used yet



17
18
19
# File 'lib/qti/v2/models/stimulus_item.rb', line 17

def identifier
  @identifier ||= File.basename(path, '.html')
end

#instructionsObject



29
30
31
# File 'lib/qti/v2/models/stimulus_item.rb', line 29

def instructions
  nil
end

#orientationObject



37
38
39
# File 'lib/qti/v2/models/stimulus_item.rb', line 37

def orientation
  'left'
end

#source_urlObject



33
34
35
# File 'lib/qti/v2/models/stimulus_item.rb', line 33

def source_url
  nil
end

#stimulus_typeObject



25
26
27
# File 'lib/qti/v2/models/stimulus_item.rb', line 25

def stimulus_type
  'text'
end

#titleObject



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