Class: Qti::V1::Models::Interactions::CanvasMultipleDropdownInteraction
- Inherits:
-
BaseFillBlankInteraction
- Object
- Models::Base
- Base
- BaseInteraction
- BaseFillBlankInteraction
- Qti::V1::Models::Interactions::CanvasMultipleDropdownInteraction
- Defined in:
- lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb
Instance Attribute Summary
Attributes inherited from BaseInteraction
Attributes inherited from Models::Base
#doc, #manifest, #package_root, #path, #resource
Class Method Summary collapse
-
.matches(node, parent) ⇒ Object
This will know if a class matches.
Instance Method Summary collapse
- #answers ⇒ Object
- #blanks ⇒ Object
- #position_for_entry(entry_id) ⇒ Object
- #scoring_data_structs ⇒ Object
- #stem_items ⇒ Object
- #text_for_entry(entry_id) ⇒ Object
Methods inherited from BaseFillBlankInteraction
#canvas_blank_id, #canvas_stem_items, #stem_blank, #stem_text
Methods inherited from BaseInteraction
#answer_feedback, #canvas_item_feedback, canvas_multiple_fib?, #initialize, maybe_question_type, question_type, #rcardinality, #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
Class Method Details
.matches(node, parent) ⇒ Object
This will know if a class matches
7 8 9 10 11 |
# 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 |
Instance Method Details
#answers ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb', line 54 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 |
#blanks ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb', line 17 def blanks @blanks = node.xpath('.//xmlns:response_lid').map do |resp| index = 0 { id: resp[:ident], choices: resp.xpath('.//xmlns:response_label').map do |bnode| blank_choice(bnode, index += 1) end } end end |
#position_for_entry(entry_id) ⇒ Object
49 50 51 52 |
# File 'lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb', line 49 def position_for_entry(entry_id) blanks @blank_choices[entry_id][:position] end |
#scoring_data_structs ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb', line 30 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 ⇒ Object
13 14 15 |
# 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) ⇒ Object
44 45 46 47 |
# File 'lib/qti/v1/models/interactions/canvas_multiple_dropdown.rb', line 44 def text_for_entry(entry_id) blanks @blank_choices[entry_id][:item_body] end |