Class: Qti::V1::Models::Assessment

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

Direct Known Subclasses

ObjectBank

Constant Summary collapse

GROUP_ID =
'xmlns:section/xmlns:selection_ordering'.freeze

Instance Attribute Summary

Attributes inherited from Models::Base

#doc, #manifest, #package_root, #path, #resource

Instance Method Summary collapse

Methods included from Models::AssessmentMetaBase

#canvas_meta_data

Methods inherited from Base

#qti_version, #return_inner_content!, #sanitize_attributes, #sanitize_attributes_by_node

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



21
22
23
24
# File 'lib/qti/v1/models/assessment.rb', line 21

def assessment_items
  @doc.xpath("//*[self::#{GROUP_ID} or self::xmlns:item[not(ancestor::#{GROUP_ID})]" \
    ' or self::xmlns:bankentry_item]')
end

#create_assessment_item(assessment_item) ⇒ Object



26
27
28
29
30
31
# File 'lib/qti/v1/models/assessment.rb', line 26

def create_assessment_item(assessment_item)
  return nil if sub_section?(assessment_item) || bank_entry_item?(assessment_item)
  item = Qti::V1::Models::AssessmentItem.new(assessment_item, @package_root, self)
  item.manifest = manifest
  item
end

#create_bank_entry_item(bank_entry_item_ref) ⇒ Object



47
48
49
50
# File 'lib/qti/v1/models/assessment.rb', line 47

def create_bank_entry_item(bank_entry_item_ref)
  return nil unless bank_entry_item?(bank_entry_item_ref)
  Qti::V1::Models::BankEntryItem.new(bank_entry_item_ref)
end

#create_question_group(group_ref) ⇒ Object



42
43
44
45
# File 'lib/qti/v1/models/assessment.rb', line 42

def create_question_group(group_ref)
  return nil unless question_group?(group_ref)
  Qti::V1::Models::QuestionGroup.new(group_ref)
end

#create_stimulus(stimulus_ref) ⇒ Object



37
38
39
40
# File 'lib/qti/v1/models/assessment.rb', line 37

def create_stimulus(stimulus_ref)
  return nil unless stimulus?(stimulus_ref)
  Qti::V1::Models::StimulusItem.new(stimulus_ref)
end

#external_assignment_idObject



17
18
19
# File 'lib/qti/v1/models/assessment.rb', line 17

def external_assignment_id
  @external_assignment_id ||= xpath_with_single_check('.//xmlns:assessment/@external_assignment_id')&.content
end

#identifierObject



9
10
11
# File 'lib/qti/v1/models/assessment.rb', line 9

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

#stimulus_ref(assessment_item_ref) ⇒ Object



33
34
35
# File 'lib/qti/v1/models/assessment.rb', line 33

def stimulus_ref(assessment_item_ref)
  assessment_item_ref
end

#titleObject



13
14
15
# File 'lib/qti/v1/models/assessment.rb', line 13

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