Skip to content

Commit

Permalink
Fix bug related to looping_identifier and affecting short pdf generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Levia committed Sep 12, 2018
1 parent bab8b6f commit dc3e324
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/models/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,14 @@ def build_all_looping_identifiers
end

def any_answers_from? user, loop_sources_items, loop_item, looping_identifier=nil
answers = Answer.find(:all, :conditions => {:question_id => self.questions.map(&:id), :user_id => user.id, :looping_identifier => looping_identifier})
answers = Answer.where(question_id: self.questions.map(&:id), user_id: user.id)
# Necessary because of what looks like a bug,
# which is assigning either 0 or nil for empty looping_identifiers
if looping_identifier.present?
answers = answers.where(looping_identifier: looping_identifier)
else
answers = answers.where("looping_identifier = '0' OR looping_identifier IS NULL")
end
return true if !answers.select(&:filled_answer?).empty?
self.children.each do |s|
next if s.depends_on_option && !s.dependency_condition_met?(user, looping_identifier)
Expand Down

0 comments on commit dc3e324

Please sign in to comment.