class Qti::V1::Models::Interactions::BaseFillBlankInteraction
Public Instance Methods
canvas_blank_id(stem_item)
click to toggle source
# File lib/qti/v1/models/interactions/base_fill_blank_interaction.rb, line 37 def canvas_blank_id(stem_item) blank_id = nil node.xpath('.//xmlns:response_lid/xmlns:material').children.map do |response_lid_node| if stem_item == response_lid_node.text blank_id = response_lid_node.ancestors('response_lid').first.attributes['ident']&.value end end blank_id end
canvas_fib_response_ids()
click to toggle source
# File lib/qti/v1/models/interactions/base_fill_blank_interaction.rb, line 61 def canvas_fib_response_ids @canvas_fib_response_ids ||= canvas_fib_responses.map { |b| "[#{b[:id].sub(/^response_/, '')}]" } end
canvas_fib_responses()
click to toggle source
# File lib/qti/v1/models/interactions/base_fill_blank_interaction.rb, line 47 def canvas_fib_responses @base_canvas_blanks ||= node.xpath('.//xmlns:response_lid').map do |resp| index = 0 { id: resp[:ident], choices: resp.xpath('.//xmlns:response_label').map do |bnode| canvas_blank_choice(bnode, index += 1) end } end @base_canvas_blanks end
canvas_stem_items(item_prompt)
click to toggle source
# File lib/qti/v1/models/interactions/base_fill_blank_interaction.rb, line 8 def canvas_stem_items(item_prompt) item_prompt.split(CANVAS_REGEX).map.with_index do |stem_item, index| if canvas_fib_response_ids.include?(stem_item) # Strip the brackets before searching stem_blank(index, canvas_blank_id(stem_item[1..-2])) else stem_text(index, stem_item) end end end
stem_blank(index, value)
click to toggle source
# File lib/qti/v1/models/interactions/base_fill_blank_interaction.rb, line 19 def stem_blank(index, value) { id: "stem_#{index}", position: index + 1, type: 'blank', blank_id: value } end
stem_text(index, value)
click to toggle source
# File lib/qti/v1/models/interactions/base_fill_blank_interaction.rb, line 28 def stem_text(index, value) { id: "stem_#{index}", position: index + 1, type: 'text', value: value } end
Private Instance Methods
canvas_blank_choice(bnode, index)
click to toggle source
# File lib/qti/v1/models/interactions/base_fill_blank_interaction.rb, line 67 def canvas_blank_choice(bnode, index) bnode_id = bnode[:ident] choice = { id: bnode_id, position: index + 1, item_body: bnode.at_xpath('.//xmlns:mattext').text } @blank_choices ||= {} @blank_choices[bnode_id] = choice choice end