Class: TrueFalse
Instance Attribute Summary
Attributes inherited from Question
#answers, #name, #points, #question_comment, #question_group, #question_tags, #question_text, #randomize, #uid
Instance Method Summary collapse
- #explanation ⇒ Object
- #incorrect_answer ⇒ Object
-
#initialize(text, correct_answer, opts = nil) ⇒ TrueFalse
constructor
A new instance of TrueFalse.
- #multiple ⇒ Object
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
#explanation ⇒ Object
15 |
# File 'lib/ruql/true_false.rb', line 15 def explanation ; incorrect_answer.explanation ; end |
#incorrect_answer ⇒ Object
14 |
# File 'lib/ruql/true_false.rb', line 14 def incorrect_answer ; self.answers.reject(&:correct).first ; end |
#multiple ⇒ Object
13 |
# File 'lib/ruql/true_false.rb', line 13 def multiple ; false ; end |