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

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

#feedbackObject



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

def feedback
  @feedback ||= interaction_model.canvas_item_feedback
end

#identifierObject

Not used yet



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

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

#interaction_modelObject



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

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

#item_bodyObject



10
11
12
13
14
15
16
17
18
19
# 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_item_body(node)
    node.add_child(prompt) if prompt&.parent && prompt.parent != node
    sanitize_content!(node.to_html)
  end
end

#points_possibleObject



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

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



43
44
45
# File 'lib/qti/v2/models/assessment_item.rb', line 43

def scoring_data_structs
  @scoring_data_structs ||= interaction_model.scoring_data_structs
end

#titleObject



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

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