Class: Qti::V2::Models::AssessmentItem

Inherits:
Base show all
Defined in:
lib/qti/v2/models/assessment_item.rb

Defined Under Namespace

Classes: ScoringData

Constant Summary

Constants inherited from Base

Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS

Constants inherited from Models::Base

Models::Base::ELEMENTS_REMAP

Instance Attribute Summary

Attributes inherited from Models::Base

#doc

Instance Method Summary collapse

Methods inherited from Base

#qti_version

Methods inherited from Models::Base

#css_with_single_check, from_path!, #initialize, #parse_xml, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #sanitize_content!, #xpath_with_single_check

Constructor Details

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

Instance Method Details

#identifierObject

Not used yet



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

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

#interaction_modelObject



40
41
42
43
44
# File 'lib/qti/v2/models/assessment_item.rb', line 40

def interaction_model
  @interaction_model ||= begin
    V2::Models::Interactions.interaction_model(@doc)
  end
end

#item_bodyObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/qti/v2/models/assessment_item.rb', line 10

def item_body
  @item_body ||= begin
    node = item_body_node.dup
    # ensure a prompt is carried into the html
    prompt = node.at_xpath('//xmlns:prompt')

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

    node.add_child(prompt) if prompt&.parent && prompt.parent != node
    sanitize_content!(node.to_html)
  end
end

#points_possibleObject



33
34
35
36
37
38
# File 'lib/qti/v2/models/assessment_item.rb', line 33

def points_possible
  @points_possible ||= begin
    xpath_with_single_check("//xmlns:outcomeDeclaration[@identifier='SCORE']/@normalMaximum")&.content ||
    xpath_with_single_check("//xmlns:outcomeDeclaration[@identifier='MAXSCORE']//xmlns:value")&.content
  end
end

#scoring_data_structsObject



46
47
48
# File 'lib/qti/v2/models/assessment_item.rb', line 46

def scoring_data_structs
  @scoring_data_structs ||= interaction_model.scoring_data_structs
end

#titleObject



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

def title
  @title ||= xpath_with_single_check('//xmlns:assessmentItem/@title').content
end