Class: Qti::V1::Models::AssessmentItem

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

Constant Summary

Constants inherited from Models::Base

Models::Base::ELEMENTS_REMAP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#qti_version

Methods inherited from Models::Base

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

Constructor Details

#initialize(item) ⇒ AssessmentItem

Returns a new instance of AssessmentItem.



10
11
12
# File 'lib/qti/v1/models/assessment_item.rb', line 10

def initialize(item)
  @doc = item
end

Instance Attribute Details

#docObject (readonly)

Returns the value of attribute doc.



8
9
10
# File 'lib/qti/v1/models/assessment_item.rb', line 8

def doc
  @doc
end

Instance Method Details

#identifierObject



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

def identifier
  @identifier ||= @doc.attribute('ident').value
end

#interaction_modelObject



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

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

#item_bodyObject



14
15
16
17
18
19
20
21
# File 'lib/qti/v1/models/assessment_item.rb', line 14

def item_body
  @item_body ||= begin
    node = @doc.dup
    presentation = node.at_xpath('.//xmlns:presentation')
    prompt = presentation.at_xpath('.//xmlns:mattext').content
    sanitize_content!(prompt)
  end
end

#points_possibleObject



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

def points_possible
  @points_possible ||= begin
    @doc.at_xpath('.//xmlns:decvar/@maxvalue')&.value || @doc.at_xpath('.//xmlns:decvar/@defaultval')&.value
  end
end

#rcardinalityObject



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

def rcardinality
  @rcardinality ||= @doc.at_xpath('.//xmlns:response_lid/@rcardinality').value
end

#scoring_data_structsObject



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

def scoring_data_structs
  @scoring_data_structs ||= interaction_model.scoring_data_structs
end

#titleObject



27
28
29
# File 'lib/qti/v1/models/assessment_item.rb', line 27

def title
  @title ||= @doc.attribute('title').value
end