Class: TrueFalse

Inherits:
Question show all
Defined in:
lib/ruql/true_false.rb

Instance Attribute Summary

Attributes inherited from Question

#answers, #name, #points, #question_comment, #question_group, #question_tags, #question_text, #randomize, #uid

Instance Method Summary collapse

Methods inherited from Question

#answer, #as_json, #comment, #correct_answer, #correct_answers, #distractor, #group, #raw?, #tags, #text

Constructor Details

#initialize(text, correct_answer, opts = nil) ⇒ TrueFalse

Returns a new instance of TrueFalse.



3
4
5
6
7
8
9
10
11
# File 'lib/ruql/true_false.rb', line 3

def initialize(text, correct_answer, opts=nil)
  super
  opts ||= {}
  opts[:explanation] ||= ''
  correct_answer = !!correct_answer # ensure 'true' or 'false' only
  self.question_text = "True or False: #{text}"
  self.answer correct_answer.to_s.capitalize
  self.distractor (!correct_answer).to_s.capitalize, :explanation => opts[:explanation]
end

Instance Method Details

#explanationObject



15
# File 'lib/ruql/true_false.rb', line 15

def explanation ; incorrect_answer.explanation ; end

#incorrect_answerObject



14
# File 'lib/ruql/true_false.rb', line 14

def incorrect_answer ; self.answers.reject(&:correct).first ; end

#multipleObject



13
# File 'lib/ruql/true_false.rb', line 13

def multiple ; false ; end