app/models/section.rb
#check the answered status for a specific question for a user
check the answered status for a specific question for a user
check the answered status for a specific question for a user
def questions_answered_status(user, looping_identifier=nil) 
    return 4 if (self.depends_on_question && !self.dependency_condition_met?(user, looping_identifier)) || !self.questions.any?
    mandatory_unanswered = false
    some_unanswered = false
    at_least_one_answered = false
    self.questions.each do |question|
      if question.answered_status(user, looping_identifier)
        at_least_one_answered = true
      else
        if question.is_mandatory
          mandatory_unanswered = true
          break
        else
          some_unanswered = true
        end
      end
    end
    if mandatory_unanswered 
      return 1
    elsif !at_least_one_answered 
      return 0
    elsif !mandatory_unanswered && !some_unanswered 
      return 3
    end
    2 
  end
def questions_answered_status ( user , looping_identifier = nil ) return 4 if ( self . depends_on_question && ! self . dependency_condition_met? ( user , looping_identifier ) ) || ! self . questions . any? mandatory_unanswered = false some_unanswered = false at_least_one_answered = false self . questions . each do | question | if question . answered_status ( user , looping_identifier ) at_least_one_answered = true else if question . is_mandatory mandatory_unanswered = true break else some_unanswered = true end end end if mandatory_unanswered return 1 elsif ! at_least_one_answered return 0 elsif ! mandatory_unanswered && ! some_unanswered return 3 end 2 end
check the answered status for a specific question for a user
check the answered status for a specific question for a user
# 0 = none answered, 1 = mandatory unanswered, 2 = mandatory answered, 3 = all answered, #return 4 if self.questions.count == 0 #if the section has no questions, treat it as a brand new #if the section is not visible, because the dependency conditions for it are not met # treat as a brand new  section. #mandatory not answered #none answered #All Answered #some answered, but not all mandatory
user
looping_identifier