class Qti::V1::Models::Interactions::CanvasMultipleDropdownInteraction
Public Class Methods
matches(node, parent)
click to toggle source
This will know if a class matches
# File lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb, line 7 def self.matches(node, parent) field_entry = node.xpath('.//xmlns:fieldentry')[0] return false unless field_entry&.text == 'multiple_dropdowns_question' new(node, parent) end
Public Instance Methods
answers()
click to toggle source
# File lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb, line 41 def answers @node.xpath('.//xmlns:respcondition/xmlns:setvar[@varname="SCORE"]').map do |points| entry = points.at_xpath('preceding-sibling::xmlns:conditionvar/xmlns:varequal') { value: entry[:respident], entry_id: entry.text, blank_text: text_for_entry(entry.text), action: points[:action], point_value: points.text } end end
position_for_entry(entry_id)
click to toggle source
# File lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb, line 36 def position_for_entry(entry_id) canvas_fib_responses @blank_choices[entry_id][:position] end
scoring_data_structs()
click to toggle source
# File lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb, line 17 def scoring_data_structs answers.map do |answer| ScoringData.new( { id: answer[:entry_id], position: position_for_entry(answer[:entry_id]), item_body: answer[:blank_text] }, rcardinality, id: answer[:value] ) end end
stem_items()
click to toggle source
# File lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb, line 13 def stem_items canvas_stem_items(node.at_xpath('.//xmlns:presentation/xmlns:material/xmlns:mattext').text) end
text_for_entry(entry_id)
click to toggle source
# File lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb, line 31 def text_for_entry(entry_id) canvas_fib_responses @blank_choices[entry_id][:item_body] end