Class: Fe::ReferenceQuestion
- Defined in:
- app/models/fe/reference_question.rb
Instance Attribute Summary
Attributes inherited from Question
Instance Method Summary collapse
- #display_response(app = nil) ⇒ Object
- #has_response?(app = nil) ⇒ Boolean
-
#ptemplate ⇒ Object
which view to render this element?.
- #response(app = nil) ⇒ Object
Methods inherited from Question
#default_label?, #locked?, #required?, #responses, #save_file, #save_response, #set_response, #validation_class
Methods inherited from Element
#all_elements, #conditional_match, #duplicate, #limit, max_label_length, #page_id, #position, #previous_element, #question?, #required?, #reuseable?, #set_conditional_element, #set_position, #update_any_previous_conditional_elements
Instance Method Details
#display_response(app = nil) ⇒ Object
32 33 34 |
# File 'app/models/fe/reference_question.rb', line 32 def display_response(app=nil) response(app).to_s end |
#has_response?(app = nil) ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'app/models/fe/reference_question.rb', line 23 def has_response?(app = nil) if app reference = response(app) reference && reference.valid? else Fe::ReferenceSheet.where(:question_id => id).count > 0 end end |
#ptemplate ⇒ Object
which view to render this element?
37 38 39 |
# File 'app/models/fe/reference_question.rb', line 37 def ptemplate "fe/reference_#{style}" end |
#response(app = nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/fe/reference_question.rb', line 6 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) # if references.present? # reference = references.detect {|r| r.question_id == id } # # If they have another reference that matches this question id, don't go fishing for another one # unless reference # # If the question_id doesn't match, but the reference question is based on the same reference template (question sheet) # # update the reference with the new question_id # reference = references.detect {|r| r.question.related_question_sheet_id == related_question_sheet_id} # reference.update_attribute(:question_id, id) if reference # end # end reference || Fe::ReferenceSheet.create(:applicant_answer_sheet_id => app.id, :question_id => id) end |