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
Constant Summary
Constants inherited from Models::Base
Instance Attribute Summary
Attributes inherited from BaseInteraction
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path
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, #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, #object_tag_transformer, #parse_html, #parse_xml, #preprocess_xml_doc, #remap_href_path, #remap_unknown_tags_transformer, #sanitize_config, #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
36 37 38 39 40 41 42 43 44 |
# File 'lib/qti/v1/models/interactions/base_fill_blank_interaction.rb', line 36 def canvas_blank_id(stem_item) blank_id = nil node.xpath('.//xmlns:response_lid').children.map do |response_lid_node| if stem_item.include?(response_lid_node.text) blank_id = response_lid_node.parent.attributes['ident']&.value end end blank_id end |
#canvas_stem_items(item_prompt) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# 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 stem_blank(index, canvas_blank_id(stem_item)) else stem_text(index, stem_item) end end end |
#stem_blank(index, value) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/qti/v1/models/interactions/base_fill_blank_interaction.rb', line 18 def stem_blank(index, value) { id: "stem_#{index}", position: index + 1, type: 'blank', blank_id: value } end |
#stem_text(index, value) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/qti/v1/models/interactions/base_fill_blank_interaction.rb', line 27 def stem_text(index, value) { id: "stem_#{index}", position: index + 1, type: 'text', value: value } end |