lib/modules/section_dependencies.rb
#check if the section/generated_section dependency is met (If the current_user's answers include the necessary answers for the
#section to be visible!
check if the section/generated_section dependency is met (If the current_user's answers include the necessary answers for the
section to be visible!
check if the section / generated_section dependency is met ( If the current_user ' s answers include the necessary answers for the section to be visible!
def dependency_condition_met?(user, looping_identifier=nil)
        question = self.depends_on_question
        user_answers = user.answers.find(:all, :conditions => {:question_id => question.id, :looping_identifier => looping_identifier}, :include => [:answer_parts])
        return false if !user_answers.any?
        user_answers.each do |answer|
          if self.depends_on_option_value?
            if !answer.answer_parts.find_by_field_type_id(self.depends_on_option_id)
              return false
            end
          else
            if answer.answer_parts.find_by_field_type_id(self.depends_on_option_id)
              return false
            end
          end
        end
        return true
      end
def dependency_condition_met? ( user , looping_identifier = nil ) question = self . depends_on_question user_answers = user . answers . find ( :all , :conditions => { :question_id => question . id , :looping_identifier => looping_identifier } , :include => [ :answer_parts ] ) return false if ! user_answers . any? user_answers . each do | answer | if self . depends_on_option_value? if ! answer . answer_parts . find_by_field_type_id ( self . depends_on_option_id ) return false end else if answer . answer_parts . find_by_field_type_id ( self . depends_on_option_id ) return false end end end return true end
check if the section/generated_section dependency is met (If the current_user's answers include the necessary answers for the
section to be visible!
check if the section / generated_section dependency is met ( If the current_user ' s answers include the necessary answers for the section to be visible!
#A Question can correspond to more than one generated question # so it is necessary to check if the condition is met for all the generated_questions' answers #if not answer.loop_item.present? or question.section.available_for?(user, answer.loop_item) #if the option is present then the condition is not met, when the depends_on_option_value is false! #end
user
looping_identifier