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

Inherits:
Base show all
Includes:
Models::AssessmentMetaBase, XPathHelpers
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, #resource

Instance Method Summary collapse

Methods included from XPathHelpers

#rtype_predicate, #xpath_endswith, #xpath_resource

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, #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

#assessment_itemsObject



20
21
22
23
24
25
26
27
# File 'lib/qti/v2/models/assessment_test.rb', line 20

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

#assessment_sectionsObject



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

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

#create_assessment_item(ref) ⇒ Object



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

def create_assessment_item(ref)
  item = Qti::V2::Models::AssessmentItem.from_path!(ref[:path], package_root: @package_root,
                                                                resource: ref[:resource])
  item.manifest = manifest
  item
end

#create_bank_entry_item(_bank_entry_item_ref = nil) ⇒ Object



52
53
54
# File 'lib/qti/v2/models/assessment_test.rb', line 52

def create_bank_entry_item(_bank_entry_item_ref = nil)
  nil # we don't support this in QTI V2 yet
end

#create_stimulus(stimulus_ref) ⇒ Object



48
49
50
# File 'lib/qti/v2/models/assessment_test.rb', line 48

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

#external_assignment_idObject



16
17
18
# File 'lib/qti/v2/models/assessment_test.rb', line 16

def external_assignment_id
  nil
end

#identifierObject



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

def identifier
  @identifier ||= xpath_with_single_check('//xmlns:assessmentTest/@identifier')&.content
end

#stimulus_ref(_ref) ⇒ Object



44
45
46
# File 'lib/qti/v2/models/assessment_test.rb', line 44

def stimulus_ref(_ref)
  nil
end

#test_partsObject



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

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

#titleObject



12
13
14
# File 'lib/qti/v2/models/assessment_test.rb', line 12

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