Class: Senkyoshi::EitherOr

Inherits:
Question show all
Defined in:
lib/senkyoshi/models/questions/either_or.rb

Constant Summary collapse

EITHER_OR =
{
  "yes_no.true" => "Yes",
  "yes_no.false" => "No",
  "agree_disagree.true" => "Agree",
  "agree_disagree.false" => "Disagree",
  "right_wrong.true" => "Right",
  "right_wrong.false" => "Wrong",
  "true_false.true" => "True",
  "true_false.false" => "False",
}.freeze

Constants inherited from Question

Question::ITEM_FUNCTION, Question::QUESTION_TYPE

Instance Attribute Summary

Attributes inherited from Question

#answers

Instance Method Summary collapse

Methods inherited from Question

#canvas_conversion, 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

#initializeEitherOr

Returns a new instance of EitherOr.



31
32
33
34
# File 'lib/senkyoshi/models/questions/either_or.rb', line 31

def initialize
  super
  @original_text = ""
end

Instance Method Details

#iterate_xml(data) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/senkyoshi/models/questions/either_or.rb', line 36

def iterate_xml(data)
  super
  set_answers(data.at("resprocessing"))
  data.at("flow_label").children.each do |response|
    answer_text = response.at("mattext").text
    answer = Answer.new(EITHER_OR[answer_text])
    answer.fraction = get_fraction(answer_text)
    @answers.push(answer)
  end
  self
end