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_tags, #question_text, #randomize, #raw

Instance Method Summary collapse

Methods inherited from Question

#answer, #answer_helper, #comment, #correct_answer, #correct_answers, #distractor, from_JSON, #raw?, #tags, #text, #to_JSON

Constructor Details

#initialize(text = '', correct_answer = false, 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=false, 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