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



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

def feedback
  @feedback ||= interaction_model.canvas_item_feedback
end

#identifierObject

Not used yet



19
20
21
# File 'lib/qti/v2/models/assessment_item.rb', line 19

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

#interaction_modelObject



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

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

#item_bodyObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/qti/v2/models/assessment_item.rb', line 7

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&.dup) if prompt&.parent && prompt.parent != node
    sanitize_content!(node.to_html)
  end
end

#parent_stimulus_item_identObject



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

def parent_stimulus_item_ident
  nil
end

#points_possibleObject



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

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



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

def scoring_data_structs
  @scoring_data_structs ||= interaction_model.scoring_data_structs
end

#titleObject



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

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