Class: Qti::V2::Models::Interactions::MatchItemTagProcessors::MatchInteractionTagProcessor
- Inherits:
-
BaseInteraction
show all
- Defined in:
- lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb
Constant Summary
Constants inherited
from Base
Base::BODY_ELEMENTS_CSS, Base::CHOICE_ELEMENTS_CSS, Base::INTERACTION_ELEMENTS_CSS
Instance Attribute Summary
#node
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path, #resource
Class Method Summary
collapse
Instance Method Summary
collapse
#canvas_item_feedback, #initialize, matches, #xpath_with_single_check
Methods inherited from Base
#qti_version
#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
Class Method Details
.match_interaction_tag?(node) ⇒ Boolean
7
8
9
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 7
def self.match_interaction_tag?(node)
node.xpath('//xmlns:matchInteraction').count == 1
end
|
.number_of_questions_per_answer(node) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 11
def self.number_of_questions_per_answer(node)
correct_categories = node.xpath('.//xmlns:correctResponse//xmlns:value')
.map { |value| value.content.split.last }
correct_categories.each_with_object(Hash.new(0)) { |category_id, counts| counts[category_id] += 1 }.values
end
|
Instance Method Details
#answers ⇒ Object
26
27
28
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 26
def answers
answer_nodes.map { |node| Choices::SimpleAssociableChoice.new(node, self) }
end
|
#choices ⇒ Object
37
38
39
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 37
def choices
node.xpath('.//xmlns:simpleAssociableChoice')
end
|
#question_response_pairs ⇒ Object
41
42
43
44
45
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 41
def question_response_pairs
node.xpath('.//xmlns:correctResponse//xmlns:value').map do |value|
value.content.split
end
end
|
#questions ⇒ Object
18
19
20
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 18
def questions
questions_ids.map { |id| { id: id, itemBody: choices_by_identifier[id].content } }
end
|
#scoring_data_structs ⇒ Object
30
31
32
33
34
35
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 30
def scoring_data_structs
question_response_pairs.map do |question_id, answer_id|
content = choices_by_identifier[answer_id].content
ScoringData.new(content, 'Pair', id: answer_id, question_id: question_id)
end
end
|
#shuffled? ⇒ Boolean
22
23
24
|
# File 'lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb', line 22
def shuffled?
node.at_xpath('.//xmlns:matchInteraction').attributes['shuffle']&.value.try(:downcase) == 'true'
end
|