class Qti::V2::Models::Interactions::MatchItemTagProcessors::MatchInteractionTagProcessor
Public Class Methods
match_interaction_tag?(node)
click to toggle source
# 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)
click to toggle source
# 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
Public Instance Methods
answers()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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()
click to toggle source
# 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?()
click to toggle source
# 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
Private Instance Methods
answer_nodes()
click to toggle source
# File lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb, line 59 def answer_nodes node.xpath('.//xmlns:matchInteraction//xmlns:simpleMatchSet[2]//xmlns:simpleAssociableChoice') end
choices_by_identifier()
click to toggle source
# File lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb, line 53 def choices_by_identifier @choices_by_identifier ||= choices.reduce({}) do |acc, choice| acc.update choice.attributes['identifier'].value => choice end end
questions_ids()
click to toggle source
# File lib/qti/v2/models/interactions/match_item_tag_processors/match_interaction_tag_processor.rb, line 49 def questions_ids @_questions_ids ||= question_response_pairs.map { |question_id, _| question_id } end