|
|
@ -468,13 +468,16 @@ private |
|
|
|
enabled_answer_options = enabled_question_ids.include?(question.id) ? enabled_questions.find { |q| q.id == question.id }.answer_options : {} |
|
|
|
enabled_answer_options = enabled_question_ids.include?(question.id) ? enabled_questions.find { |q| q.id == question.id }.answer_options : {} |
|
|
|
current_answer_option_valid = enabled_answer_options.present? ? enabled_answer_options.key?(public_send(question.id).to_s) : false |
|
|
|
current_answer_option_valid = enabled_answer_options.present? ? enabled_answer_options.key?(public_send(question.id).to_s) : false |
|
|
|
if !current_answer_option_valid && respond_to?(question.id.to_s) |
|
|
|
if !current_answer_option_valid && respond_to?(question.id.to_s) |
|
|
|
|
|
|
|
Rails.logger.debug("Cleared #{question.id} value") |
|
|
|
public_send("#{question.id}=", nil) |
|
|
|
public_send("#{question.id}=", nil) |
|
|
|
else |
|
|
|
else |
|
|
|
(question.answer_options.keys - enabled_answer_options.keys).map do |invalid_answer_option| |
|
|
|
(question.answer_options.keys - enabled_answer_options.keys).map do |invalid_answer_option| |
|
|
|
|
|
|
|
Rails.logger.debug("Cleared #{invalid_answer_option} value") |
|
|
|
public_send("#{invalid_answer_option}=", nil) if respond_to?(invalid_answer_option) |
|
|
|
public_send("#{invalid_answer_option}=", nil) if respond_to?(invalid_answer_option) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
Rails.logger.debug("Cleared #{question.id} value") |
|
|
|
public_send("#{question.id}=", nil) unless enabled_question_ids.include?(question.id) |
|
|
|
public_send("#{question.id}=", nil) unless enabled_question_ids.include?(question.id) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
@ -490,6 +493,7 @@ private |
|
|
|
condition_key = conditions.first[:key] |
|
|
|
condition_key = conditions.first[:key] |
|
|
|
condition_value = conditions.first[:value] |
|
|
|
condition_value = conditions.first[:value] |
|
|
|
if public_send("#{condition_key}_changed?") && condition_value == public_send(condition_key) && !public_send("#{dependent}_changed?") |
|
|
|
if public_send("#{condition_key}_changed?") && condition_value == public_send(condition_key) && !public_send("#{dependent}_changed?") |
|
|
|
|
|
|
|
Rails.logger.debug("Cleared derived #{dependent} value") |
|
|
|
self[dependent] = nil |
|
|
|
self[dependent] = nil |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|