Class: Qti::V1::Models::AssessmentItem
- Inherits:
-
Base
show all
- Defined in:
- lib/qti/v1/models/assessment_item.rb
Defined Under Namespace
Classes: ScoringData
Constant Summary
Constants inherited
from Models::Base
Models::Base::ELEMENTS_REMAP
Instance Method Summary
collapse
Methods inherited from Base
#qti_version
#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
Returns a new instance of AssessmentItem.
9
10
11
|
# File 'lib/qti/v1/models/assessment_item.rb', line 9
def initialize(item)
@doc = item
end
|
Instance Method Details
#identifier ⇒ Object
21
22
23
|
# File 'lib/qti/v1/models/assessment_item.rb', line 21
def identifier
@identifier ||= @doc.attribute('ident').value
end
|
#interaction_model ⇒ Object
#item_body ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/qti/v1/models/assessment_item.rb', line 13
def item_body
@item_body ||= begin
node = @doc.dup
prompt = node.at_xpath('./presentation/material/mattext').content
sanitize_content!(prompt)
end
end
|
#points_possible ⇒ Object
29
30
31
32
33
|
# File 'lib/qti/v1/models/assessment_item.rb', line 29
def points_possible
@points_possible ||= begin
@doc.at_xpath('.//decvar/@maxvalue')&.value || @doc.at_xpath('.//decvar/@defaultval')&.value
end
end
|
#rcardinality ⇒ Object
35
36
37
|
# File 'lib/qti/v1/models/assessment_item.rb', line 35
def rcardinality
@rcardinality ||= @doc.at_xpath('.//response_lid/@rcardinality').value
end
|
#scoring_data_structs ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/qti/v1/models/assessment_item.rb', line 43
def scoring_data_structs
@scoring_data_structs ||= begin
rcardinality = @doc.at_xpath('//response_lid/@rcardinality').value
choice_nodes = @doc.xpath('.//respcondition')
value_nodes = []
choice_nodes.each do |choice_node|
value_nodes << choice_node if choice_node.at_xpath('.//setvar').content.to_f.positive?
end
value_nodes.map { |value_node| ScoringData.new(value_node.at_xpath('//varequal').content, rcardinality) }
end
end
|
#title ⇒ Object
25
26
27
|
# File 'lib/qti/v1/models/assessment_item.rb', line 25
def title
@title ||= @doc.attribute('title').value
end
|