Sha256: 6d12d95c86ff2683a1f3cd5500eb074db7cf24a9a0fdfd188a7718c90e78789c

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

# ReferenceQuestion
# - a question that provides a fields to specify a reference
module Fe
  class ReferenceQuestion < Question

    def response(app=nil)
      return unless app
      # A reference is the same if the related_question_sheet corresponding to the question is the same
      reference = Fe::ReferenceSheet.find_by_applicant_answer_sheet_id_and_question_id(app.id, id)
      reference || Fe::ReferenceSheet.create(:applicant_answer_sheet_id => app.id, :question_id => id)
    end

    def has_response?(app = nil)
      if app
        reference = response(app)
        reference && reference.valid?
      else
        Fe::ReferenceSheet.where(:question_id => id).count > 0
      end
    end

    def display_response(app=nil)
      response(app).to_s
    end

    # which view to render this element?
    def ptemplate
      "fe/reference_#{style}"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fe-1.0.0 app/models/fe/reference_question.rb