Class: Senkyoshi::Ordering
- Defined in:
- lib/senkyoshi/models/questions/ordering.rb
Constant Summary
Constants inherited from Question
Question::ITEM_FUNCTION, Question::QUESTION_TYPE
Instance Attribute Summary
Attributes inherited from Question
Instance Method Summary collapse
- #canvas_conversion(assessment, _resources = nil) ⇒ Object
-
#initialize ⇒ Ordering
constructor
A new instance of Ordering.
- #iterate_xml(data) ⇒ Object
- #set_order_answers(resprocessing) ⇒ Object
Methods inherited from Question
from, #get_fraction, #iterate_item, #set_answers, #set_correct_answers, #set_feedback, #set_incorrect_answers, #set_material, #set_max_score
Methods inherited from Resource
#_find_directories, #_fix_path, #_matches_directory_xid?, #_search_and_replace, #cleanup, #fix_html, get_pre_data, #matches_xid?, #strip_xid
Constructor Details
#initialize ⇒ Ordering
Returns a new instance of Ordering.
20 21 22 23 24 |
# File 'lib/senkyoshi/models/questions/ordering.rb', line 20 def initialize super @matches = [] @order_answers = {} end |
Instance Method Details
#canvas_conversion(assessment, _resources = nil) ⇒ Object
42 43 44 45 |
# File 'lib/senkyoshi/models/questions/ordering.rb', line 42 def canvas_conversion(assessment, _resources = nil) @question.matches = @matches super end |
#iterate_xml(data) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/senkyoshi/models/questions/ordering.rb', line 26 def iterate_xml(data) super resprocessing = data.at("resprocessing") @order_answers = set_order_answers(resprocessing) if response_block = data.at("flow[@class=RESPONSE_BLOCK]") response_block.at("render_choice").children.each do |choice| id = choice.at("response_label").attributes["ident"].value question = @order_answers[id].to_s answer = choice.at("mat_formattedtext").text @matches << { id: id, question_text: question, answer_text: answer } end @matches = @matches.sort_by { |hsh| hsh[:question_text] } end self end |
#set_order_answers(resprocessing) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/senkyoshi/models/questions/ordering.rb', line 47 def set_order_answers(resprocessing) order_answers = {} correct = resprocessing.at("respcondition[title=correct]") if correct correct.at("and").children.each_with_index do |varequal, index| id = varequal.text order_answers[id] = index + 1 end end order_answers end |