Class: Fe::ReferenceQuestion

Inherits:
Question show all
Defined in:
app/models/fe/reference_question.rb

Instance Attribute Summary

Attributes inherited from Question

#answers

Attributes inherited from Element

#old_id

Instance Method Summary collapse

Methods inherited from Question

#check_answer_sheet_matches_set_response_answer_sheet, #default_label?, #delete_file, #locked?, #responses, #save_file, #save_response, #set_response, #validation_class

Methods inherited from Element

#all_elements, #conditional_answers, #conditional_match, #content, create_from_import, #css_classes, #duplicate, #export_hash, #export_to_yaml, #hidden?, #hidden_by_choice_field?, #hidden_by_conditional?, #label, #limit, #matches_filter, max_label_length, #page_id, #pages_on, #position, #previous_element, #question?, #required?, #reuseable?, #set_conditional_element, #set_position, #tooltip, #update_any_previous_conditional_elements, #update_page_all_element_ids, #visibility_affecting_element_ids, #visibility_affecting_questions, #visible?

Instance Method Details

#display_response(app = nil, humanize = false) ⇒ Object



25
26
27
# File 'app/models/fe/reference_question.rb', line 25

def display_response(app = nil, humanize = false)
  response(app).to_s
end

#has_response?(app = nil) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
# File 'app/models/fe/reference_question.rb', line 16

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

#ptemplateObject

which view to render this element?



30
31
32
# File 'app/models/fe/reference_question.rb', line 30

def ptemplate
  "fe/reference_#{style}"
end

#response(app = nil) ⇒ Object



9
10
11
12
13
14
# File 'app/models/fe/reference_question.rb', line 9

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

#update_references_question_sheet_idsObject



34
35
36
# File 'app/models/fe/reference_question.rb', line 34

def update_references_question_sheet_ids
  reference_sheets.where(status: :created).update_all(question_sheet_id: related_question_sheet_id, updated_at: Time.now)
end