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
Attributes inherited from Models::Base
#manifest, #package_root, #path
Instance Method Summary
collapse
Methods inherited from Base
#qti_version, #return_inner_content!
#css_with_single_check, from_path!, #object_tag_transformer, #parse_html, #parse_xml, #preprocess_xml_doc, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #sanitize_content!, #xpath_with_single_check
Constructor Details
#initialize(item, package_root = nil) ⇒ AssessmentItem
Returns a new instance of AssessmentItem.
10
11
12
13
14
|
# File 'lib/qti/v1/models/assessment_item.rb', line 10
def initialize(item, package_root = nil)
@doc = item
@path = item.document.url
self.package_root = package_root
end
|
Instance Attribute Details
#doc ⇒ Object
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
#decvar_maxvalue ⇒ Object
66
67
68
69
|
# File 'lib/qti/v1/models/assessment_item.rb', line 66
def decvar_maxvalue
@doc.at_xpath('.//xmlns:decvar/@maxvalue')&.value&.to_i ||
@doc.at_xpath('.//xmlns:decvar/@defaultval')&.value&.to_i || 0
end
|
#feedback ⇒ Object
85
86
87
|
# File 'lib/qti/v1/models/assessment_item.rb', line 85
def feedback
@feedback ||= interaction_model.canvas_item_feedback
end
|
48
49
50
51
|
# File 'lib/qti/v1/models/assessment_item.rb', line 48
def has_points_possible_qti_metadata? warn "DEPRECATED: '#{__method__}' is renamed to 'points_possible_qti_metadata?'."
points_possible_qti_metadata?
end
|
#identifier ⇒ Object
26
27
28
|
# File 'lib/qti/v1/models/assessment_item.rb', line 26
def identifier
@identifier ||= @doc.attribute('ident').value
end
|
#interaction_model ⇒ Object
#item_body ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/qti/v1/models/assessment_item.rb', line 16
def item_body
@item_body ||= begin
node = @doc.dup
presentation = node.at_xpath('.//xmlns:presentation')
mattext = presentation.at_xpath('.//xmlns:mattext')
prompt = return_inner_content!(mattext)
sanitize_content!(prompt)
end
end
|
#points_possible ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/qti/v1/models/assessment_item.rb', line 53
def points_possible
@points_possible ||= begin
if points_possible_qti_metadata?
points_possible_label = qti_metadata_children.children.find do |node|
node.text == 'points_possible'
end
points_possible_label.next.text
else
1
end
end
end
|
38
39
40
41
42
43
44
45
|
# File 'lib/qti/v1/models/assessment_item.rb', line 38
def points_possible_qti_metadata?
if @doc.at_xpath('.//xmlns:qtimetadata').present?
points_possible_label = qti_metadata_children.children.find { |node| node.text == 'points_possible' }
points_possible_label.present?
else
false
end
end
|
34
35
36
|
# File 'lib/qti/v1/models/assessment_item.rb', line 34
def qti_metadata_children
@doc.at_xpath('.//xmlns:qtimetadata')&.children
end
|
#rcardinality ⇒ Object
71
72
73
|
# File 'lib/qti/v1/models/assessment_item.rb', line 71
def rcardinality
@rcardinality ||= @doc.at_xpath('.//xmlns:response_lid/@rcardinality').value
end
|
#scoring_data_structs ⇒ Object
81
82
83
|
# File 'lib/qti/v1/models/assessment_item.rb', line 81
def scoring_data_structs
@scoring_data_structs ||= interaction_model.scoring_data_structs
end
|
#title ⇒ Object
30
31
32
|
# File 'lib/qti/v1/models/assessment_item.rb', line 30
def title
@title ||= @doc.attribute('title').value
end
|