Class: Qti::V1::Models::Interactions::BaseFillBlankInteraction
- Inherits:
-
BaseInteraction
- Object
- Models::Base
- Base
- BaseInteraction
- Qti::V1::Models::Interactions::BaseFillBlankInteraction
- Defined in:
- lib/qti/v1/models/interactions/base_fill_blank_interaction.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BaseInteraction
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path, #resource
Instance Method Summary collapse
- #canvas_blank_id(stem_item) ⇒ Object
- #canvas_stem_items(item_prompt) ⇒ Object
- #stem_blank(index, value) ⇒ Object
- #stem_text(index, value) ⇒ Object
Methods inherited from BaseInteraction
#answer_feedback, #canvas_item_feedback, canvas_multiple_fib?, #initialize, matches, maybe_question_type, question_type, #rcardinality, #scoring_data_structs, #shuffled?
Methods inherited from Base
#qti_version, #return_inner_content!
Methods inherited from Models::Base
#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
Constructor Details
This class inherits a constructor from Qti::V1::Models::Interactions::BaseInteraction
Instance Method Details
#canvas_blank_id(stem_item) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# 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_stem_items(item_prompt) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# 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 stem_item.match CANVAS_REGEX # 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) ⇒ Object
19 20 21 22 23 24 25 26 |
# 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) ⇒ Object
28 29 30 31 32 33 34 35 |
# 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 |