def set_response(values, app)
      values = Array.wrap(values)
      if !object_name.blank? and !attribute_name.blank?
        # if eval("app." + object_name).present?
        object = object_name == 'application' ? app : eval("app." + object_name)
        unless object.present?
          if object_name.include?('.')
            objects = object_name.split('.')
            object = eval("app." + objects[0..-2].join('.') + ".create_" + objects.last)
            eval("app." + objects[0..-2].join('.')).reload
          end
        end
        unless responses(app) == values
          value = ActiveRecord::Base.connection.quote_string(values.first)
          if self.is_a?(DateField) && value.present?
            begin
              value = Date.strptime(value, (I18n.t 'date.formats.default'))
            rescue
              raise "invalid date - " + value.inspect
            end
          end
          object.update_attribute(attribute_name, value) 
        end
        # else
        #   raise object_name.inspect + ' == ' + attribute_name.inspect
        # end
      else
        @answers ||= []
        @mark_for_destroy ||= []
        # go through existing answers (in reverse order, as we delete)
        (@answers.length - 1).downto(0) do |index|
          # reject: skip over responses that are unchanged
          unless values.reject! {|value| value == @answers[index]}
            # remove any answers that don't match the posted values
            @mark_for_destroy << @answers[index]   # destroy from database later 
            @answers.delete_at(index)
          end
        end
      
        # insert any new answers
        for value in values
          if @mark_for_destroy.empty?
            answer = Answer.new(:question_id => self.id)
          else
            # re-use marked answers (an update vs. a delete+insert)
            answer = @mark_for_destroy.pop
          end
          answer.set(value)
          @answers << answer
        end
      end
    end
def set_response(values, app)
      values = Array.wrap(values)
      if !object_name.blank? and !attribute_name.blank?
        # if eval("app." + object_name).present?
        object = object_name == 'application' ? app : eval("app." + object_name)
        unless object.present?
          if object_name.include?('.')
            objects = object_name.split('.')
            object = eval("app." + objects[0..-2].join('.') + ".create_" + objects.last)
            eval("app." + objects[0..-2].join('.')).reload
          end
        end
        unless responses(app) == values
          value = ActiveRecord::Base.connection.quote_string(values.first)
          if self.is_a?(DateField) && value.present?
            begin
              value = Date.strptime(value, (I18n.t 'date.formats.default'))
            rescue
              raise "invalid date - " + value.inspect
            end
          end
          object.update_attribute(attribute_name, value) 
        end
        # else
        #   raise object_name.inspect + ' == ' + attribute_name.inspect
        # end
      else
        @answers ||= []
        @mark_for_destroy ||= []
        # go through existing answers (in reverse order, as we delete)
        (@answers.length - 1).downto(0) do |index|
          # reject: skip over responses that are unchanged
          unless values.reject! {|value| value == @answers[index]}
            # remove any answers that don't match the posted values
            @mark_for_destroy << @answers[index]   # destroy from database later 
            @answers.delete_at(index)
          end
        end
      
        # insert any new answers
        for value in values
          if @mark_for_destroy.empty?
            answer = Answer.new(:question_id => self.id)
          else
            # re-use marked answers (an update vs. a delete+insert)
            answer = @mark_for_destroy.pop
          end
          answer.set(value)
          @answers << answer
        end
      end
    end
set answers from posted response