Class: Senkyoshi::MultipleChoice
- Defined in:
- lib/senkyoshi/models/questions/multiple_choice.rb
Constant Summary
Constants inherited from Question
Question::ITEM_FUNCTION, Question::QUESTION_TYPE
Instance Attribute Summary
Attributes inherited from Question
Instance Method Summary collapse
Methods inherited from Question
#canvas_conversion, from, #initialize, #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
This class inherits a constructor from Senkyoshi::Question
Instance Method Details
#get_fraction(answer_text) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/senkyoshi/models/questions/multiple_choice.rb', line 35 def get_fraction(answer_text) if @correct_answers && answer_text == @correct_answers["name"] if @correct_answers["fraction"].to_f == 0.0 1.0 else @correct_answers["fraction"].to_f end else @incorrect_answers["fraction"].to_f end end |
#iterate_xml(data) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/senkyoshi/models/questions/multiple_choice.rb', line 20 def iterate_xml(data) super if response_block = data.at("flow[@class=RESPONSE_BLOCK]") set_answers(data) response_block.at("render_choice").children.each do |choice| id = choice.at("response_label").attributes["ident"].value answer_text = choice.at("mat_formattedtext").text answer = Answer.new(answer_text, id) answer.fraction = get_fraction(id) @answers.push(answer) end end self end |