Browse Source

extract enabled_questions outside of the invalidated_page_questions loop (#635)

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

5
app/models/case_log.rb

@ -448,9 +448,10 @@ private
end
def reset_not_routed_questions
enabled_questions = form.enabled_page_questions(self)
enabled_question_ids = enabled_questions.map(&:id)
form.invalidated_page_questions(self).each do |question|
enabled_questions = form.enabled_page_questions(self)
enabled_question_ids = enabled_questions.map(&:id)
if %w[radio checkbox].include?(question.type)
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

Loading…
Cancel
Save