class Senkyoshi::MultipleChoice

Public Instance Methods

get_fraction(answer_text) click to toggle source
# 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) click to toggle source
Calls superclass method Senkyoshi::Question#iterate_xml
# 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