Sha256: 68ee0fba22056dce6f13b569ca75f1cb3a3dce582e50c02d1a9a6bcf08b88a6b
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
class Response < ActiveRecord::Base # Extending surveyor include "#{self.name}Extensions".constantize if Surveyor::Config['extend'].include?(self.name.underscore) include ActionView::Helpers::SanitizeHelper # Associations belongs_to :response_set belongs_to :question belongs_to :answer # Validations validates_presence_of :response_set_id, :question_id, :answer_id acts_as_response # includes "as" instance method def selected !self.new_record? 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 if self.answer.response_class == "answer" and self.answer_id return self.answer.text else return "#{(self.string_value || self.text_value || self.integer_value || self.float_value || nil).to_s}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
surveyor-0.12.1 | app/models/response.rb |
surveyor-0.11.0 | app/models/response.rb |
surveyor-0.10.0 | app/models/response.rb |