app/models/section.rb
# Provides a list of nested items that are only questions by flattening out
# any subsections. Works recursively
Provides a list of nested items that are only questions by flattening out
any subsections. Works recursively
Provides a list of nested items that are only questions by flattening out any subsections . Works recursively
def flatten_questions
    flat_questions = []
    section_nested_items.includes(:question, response_set: [:responses]).each do |sni|
      if sni.question.present?
        flat_questions << sni
      else
        flat_questions.concat(sni.nested_section.flatten_questions)
      end
    end
    flat_questions
  end
def flatten_questions flat_questions = [ ] section_nested_items . includes ( :question , response_set : [ :responses ] ) . each do | sni | if sni . question . present? flat_questions << sni else flat_questions . concat ( sni . nested_section . flatten_questions ) end end flat_questions end
Provides a list of nested items that are only questions by flattening out
any subsections.
Provides a list of nested items that are only questions by flattening out any subsections .