Skip to content

Commit

Permalink
Updated fix-for-conditional-question-removed-answers-not-being-deleted.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Pinto committed Sep 6, 2024
1 parent 98bdee4 commit eabc3cd
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions app/helpers/conditions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ module ConditionsHelper
# return a list of question ids to open/hide
def remove_list(object)
id_list = []
puts "object.is_a?(Hash): #{object.is_a?(Hash)}"
puts "object.answers.size: #{object.answers.size}"
plan_answers = object.answers if object.is_a?(Plan)
plan_answers = object[:answers] if object.is_a?(Hash)
return [] unless plan_answers.present?

puts "plan_answers: #{plan_answers.size}"
plan_answers.each do |answer|
id_list += answer_remove_list(answer)
puts "id_list (in plan_answers.each): #{id_list}"
end
puts "id_list: #{id_list}"
plan_answers.each { |answer| id_list += answer_remove_list(answer) }
id_list
end

Expand All @@ -31,14 +24,9 @@ def answer_remove_list(answer, user = nil)
return id_list unless answer.question.option_based?

answer.question.conditions.each do |cond|
puts "cond: #{cond.inspect}"

opts = cond.option_list.map(&:to_i).sort
action = cond.action_type
chosen = answer.question_option_ids.sort
puts "opts: #{opts}"
puts "action: #{action}"
puts "chosen: #{chosen}"
if !opts.empty? && !chosen.empty? && !(chosen & opts).empty?
if action == 'remove'
rems = cond.remove_data.map(&:to_i)
Expand Down

0 comments on commit eabc3cd

Please sign in to comment.