Browse Source

check if answer options are present (#326)

pull/328/head
kosiakkatrina 3 years ago committed by GitHub
parent
commit
abdae7f86c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/models/case_log.rb

3
app/models/case_log.rb

@ -216,7 +216,8 @@ private
def reset_not_routed_questions
form.invalidated_page_questions(self).each do |question|
enabled = form.enabled_page_questions(self)
contains_selected_answer_option = enabled.map(&:id).include?(question.id) && enabled.find { |q| q.id == question.id }.answer_options.values.map { |x| x["value"] }.include?(public_send(question.id))
answer_options = enabled.map(&:id).include?(question.id) ? enabled.find { |q| q.id == question.id }.answer_options : []
contains_selected_answer_option = answer_options.present? ? answer_options.values.map { |x| x["value"] }.include?(public_send(question.id)) : false
if !contains_selected_answer_option && respond_to?(question.id.to_s)
public_send("#{question.id}=", nil)
end

Loading…
Cancel
Save