lib/surveyor/models/response_methods.rb in surveyor-0.18.2 vs lib/surveyor/models/response_methods.rb in surveyor-0.19.0

- old
+ new

@@ -4,33 +4,23 @@ def self.included(base) # Associations base.send :belongs_to, :response_set base.send :belongs_to, :question base.send :belongs_to, :answer - @@validations_already_included ||= nil unless @@validations_already_included # Validations base.send :validates_presence_of, :response_set_id, :question_id, :answer_id @@validations_already_included = true end - base.send :include, Surveyor::ActsAsResponse # includes "as" instance method - end # Instance Methods - def selected - !self.new_record? + def answer_id=(val) + write_attribute :answer_id, (val.is_a?(Array) ? val.detect{|x| !x.to_s.blank?} : val) end - - alias_method :selected?, :selected - - def selected=(value) - true - end - def correct? question.correct_answer_id.nil? or self.answer.response_class != "answer" or (question.correct_answer_id.to_i == answer_id.to_i) end def to_s # used in dependency_explanation_helper \ No newline at end of file