lib/modules/section_branch_methods.rb
def count_descendants_questions user, loop_item, loop_sources_items, info_holder
        info_holder[:available_questions] += self.questions.size
        self.children.each do |child|
          if !child.depends_on_question.present?
            #if children is of looping type
            if child.looping?
              #get the items through which it is going to loop on
              items = child.next_loop_items loop_item, loop_sources_items
              #for each of the items"
              items.each do |item|
                #check if the section is available for the user
                if child.available_for? user, item
                  #update the loop_sources history.
                  loop_sources_items[child.loop_source.id.to_s] = item
                  #call the function for the children, sending the necessary items.
                  child.count_descendants_questions user, item, loop_sources_items, info_holder
                end
              end
            else
              #if it is not a looping item just call the function and send the same items...
              child.count_descendants_questions user, loop_item, loop_sources_items, info_holder
            end
          end
        end
      end
#go through the descendants, and through the loop items available for a user.
go through the descendants, and through the loop items available for a user.
go through the descendants and through the loop items available for a user .
def count_descendants_questions user, loop_item, loop_sources_items, info_holder
        info_holder[:available_questions] += self.questions.size
        self.children.each do |child|
          if !child.depends_on_question.present?
            if child.looping?
              items = child.next_loop_items loop_item, loop_sources_items
              items.each do |item|
                if child.available_for? user, item
                  loop_sources_items[child.loop_source.id.to_s] = item
                  child.count_descendants_questions user, item, loop_sources_items, info_holder
                end
              end
            else
              child.count_descendants_questions user, loop_item, loop_sources_items, info_holder
            end
          end
        end
      end
def count_descendants_questions user , loop_item , loop_sources_items , info_holder info_holder [ :available_questions ] += self . questions . size self . children . each do | child | if ! child . depends_on_question . present? if child . looping? items = child . next_loop_items loop_item , loop_sources_items items . each do | item | if child . available_for? user , item loop_sources_items [ child . loop_source . id . to_s ] = item child . count_descendants_questions user , item , loop_sources_items , info_holder end end else child . count_descendants_questions user , loop_item , loop_sources_items , info_holder end end end end
go through the descendants, and through the loop items available for a user.
go through the descendants and through the loop items available for a user .
#if children is of looping type #get the items through which it is going to loop on #for each of the items" #check if the section is available for the user #update the loop_sources history. #call the function for the children, sending the necessary items. #if it is not a looping item just call the function and send the same items...
user
loop_item
loop_sources_items
info_holder