Class: Qti::V2::Models::AssessmentTest

Inherits:
Base show all
Includes:
Models::AssessmentMetaBase
Defined in:
lib/qti/v2/models/assessment_test.rb

Direct Known Subclasses

NonAssessmentTest

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

Instance Method Summary collapse

Methods included from Models::AssessmentMetaBase

#canvas_meta_data

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, #remap_href_path, #sanitize_content!, #xpath_with_single_check

Constructor Details

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

Instance Method Details

#assessment_itemsObject



13
14
15
16
17
18
19
20
# File 'lib/qti/v2/models/assessment_test.rb', line 13

def assessment_items
  # Return the xml files we should be parsing
  @assessment_item_reference_hrefs ||= begin
    @doc.xpath('//xmlns:assessmentItemRef/@href').map(&:content).map do |href|
      remap_href_path(href)
    end
  end
end

#assessment_sectionsObject



26
27
28
# File 'lib/qti/v2/models/assessment_test.rb', line 26

def assessment_sections
  @assessment_sections ||= test_parts.first.xpath('//xmlns:assessmentSection')
end

#create_assessment_item(assessment_item_ref) ⇒ Object



30
31
32
33
34
# File 'lib/qti/v2/models/assessment_test.rb', line 30

def create_assessment_item(assessment_item_ref)
  item = Qti::V2::Models::AssessmentItem.from_path!(assessment_item_ref, @package_root)
  item.manifest = manifest
  item
end

#create_stimulus(stimulus_ref) ⇒ Object



40
41
42
# File 'lib/qti/v2/models/assessment_test.rb', line 40

def create_stimulus(stimulus_ref)
  Qti::V2::Models::StimulusItem.new(path: stimulus_ref, package_root: @package_root, html: true)
end

#stimulus_ref(_ref) ⇒ Object



36
37
38
# File 'lib/qti/v2/models/assessment_test.rb', line 36

def stimulus_ref(_ref)
  nil
end

#test_partsObject



22
23
24
# File 'lib/qti/v2/models/assessment_test.rb', line 22

def test_parts
  @test_parts ||= @doc.xpath('//xmlns:testPart')
end

#titleObject



9
10
11
# File 'lib/qti/v2/models/assessment_test.rb', line 9

def title
  @title ||= xpath_with_single_check('//xmlns:assessmentTest/@title')&.content || File.basename(@path, '.xml')
end