Class: Qti::V1::Models::Interactions::FillBlankInteraction
Constant Summary
Constants inherited
from Models::Base
Models::Base::ELEMENTS_REMAP
Instance Attribute Summary
#node
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path
Class Method Summary
collapse
Instance Method Summary
collapse
#canvas_blank_id, #canvas_stem_items, #stem_blank, #stem_text
#answer_feedback, #canvas_item_feedback, canvas_multiple_fib?, #initialize, #shuffled?
Methods inherited from Base
#qti_version, #return_inner_content!
#css_with_single_check, from_path!, #initialize, #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
Class Method Details
.matches(node, parent) ⇒ Object
This will know if a class matches
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 7
def self.matches(node, parent)
return false if node.at_xpath('.//xmlns:respcondition[@continue!="Yes"]/*/xmlns:other').present?
match = if BaseInteraction.canvas_multiple_fib?(node)
node.at_xpath('.//xmlns:response_lid')
else
node.at_xpath('.//xmlns:render_fib')
end
return false if match.blank? ||
match.attributes['fibtype']&.value == 'Decimal'
new(node, parent)
end
|
Instance Method Details
#answers ⇒ Object
66
67
68
69
70
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 66
def answers
@answers ||= answer_nodes.map do |node|
V1::Models::Choices::FillBlankChoice.new(node, self)
end
end
|
#blanks ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 46
def blanks
if node.at_xpath('.//xmlns:render_choice').present?
canvas_blanks
else
qti_standard_blanks
end
end
|
#canvas_blanks ⇒ Object
54
55
56
57
58
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 54
def canvas_blanks
node.xpath('.//xmlns:response_label').map do |blank|
{ id: blank.attributes['ident']&.value }
end
end
|
#canvas_multiple_fib? ⇒ Boolean
#qti_standard_blanks ⇒ Object
60
61
62
63
64
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 60
def qti_standard_blanks
node.xpath('.//xmlns:response_str').map do |blank|
{ id: blank.attributes['ident']&.value }
end
end
|
#qti_stem_items ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 31
def qti_stem_items
stem_item_nodes = node.xpath('.//xmlns:presentation').children
stem_item_nodes.map.with_index do |stem_item, index|
if stem_item.xpath('./xmlns:render_fib').present?
stem_blank(index, stem_item.attributes['ident'].value)
else
stem_text(index, stem_item.children.text)
end
end
end
|
#scoring_data_structs ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 72
def scoring_data_structs
answer_nodes.map do |value_node|
ScoringData.new(
value_node.content,
rcardinality,
id: scoring_data_id(value_node),
case: scoring_data_case(value_node),
parent_identifier: value_node.parent.parent.attributes['ident']&.value
)
end
end
|
#single_fill_in_blank? ⇒ Boolean
42
43
44
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 42
def single_fill_in_blank?
blanks.count == 1
end
|
#stem_items ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/qti/v1/models/interactions/fill_blank_interaction.rb', line 23
def stem_items
if canvas_multiple_fib?
canvas_stem_items(node.at_xpath('.//xmlns:mattext').text)
else
qti_stem_items
end
end
|