|
|
@ -28,12 +28,25 @@ module CheckAnswersHelper |
|
|
|
def filter_conditional_questions(questions, case_log) |
|
|
|
def filter_conditional_questions(questions, case_log) |
|
|
|
applicable_questions = questions |
|
|
|
applicable_questions = questions |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# puts applicable_questions.count |
|
|
|
questions.each do |k, question| |
|
|
|
questions.each do |k, question| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# if k == "default_next_page" |
|
|
|
|
|
|
|
# applicable_questions = applicable_questions.reject { |z| z == "default_next_page" } |
|
|
|
|
|
|
|
# else |
|
|
|
|
|
|
|
# question.fetch("conditional_for", []).each do |conditional_question_key, condition| |
|
|
|
|
|
|
|
# if condition_not_met(case_log, k, question, condition) |
|
|
|
|
|
|
|
# applicable_questions = applicable_questions.reject { |z| z == conditional_question_key } |
|
|
|
|
|
|
|
# end |
|
|
|
|
|
|
|
# end |
|
|
|
|
|
|
|
# end |
|
|
|
|
|
|
|
|
|
|
|
question.fetch("conditional_for", []).each do |conditional_question_key, condition| |
|
|
|
question.fetch("conditional_for", []).each do |conditional_question_key, condition| |
|
|
|
if condition_not_met(case_log, k, question, condition) |
|
|
|
if condition_not_met(case_log, k, question, condition) |
|
|
|
applicable_questions = applicable_questions.reject { |z| z == conditional_question_key } |
|
|
|
applicable_questions = applicable_questions.reject { |z| z == conditional_question_key } |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
applicable_questions |
|
|
|
applicable_questions |
|
|
|
end |
|
|
|
end |
|
|
@ -56,13 +69,14 @@ module CheckAnswersHelper |
|
|
|
operator = condition[/[<>=]+/].to_sym |
|
|
|
operator = condition[/[<>=]+/].to_sym |
|
|
|
operand = condition[/\d+/].to_i |
|
|
|
operand = condition[/\d+/].to_i |
|
|
|
case_log[question_key].blank? || !case_log[question_key].send(operator, operand) |
|
|
|
case_log[question_key].blank? || !case_log[question_key].send(operator, operand) |
|
|
|
|
|
|
|
when "text" |
|
|
|
|
|
|
|
case_log[question_key].blank? || !condition.include?(case_log[question_key]) |
|
|
|
when "radio" |
|
|
|
when "radio" |
|
|
|
case_log[question_key].blank? || !condition.include?(case_log[question_key]) |
|
|
|
case_log[question_key].blank? || !condition.include?(case_log[question_key]) |
|
|
|
when "select" |
|
|
|
when "select" |
|
|
|
case_log[question_key].blank? || !condition.include?(case_log[question_key]) |
|
|
|
case_log[question_key].blank? || !condition.include?(case_log[question_key]) |
|
|
|
else |
|
|
|
else |
|
|
|
raise "Not implemented yet" |
|
|
|
raise "Not implemented yet" end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def create_update_answer_link(case_log_answer, case_log_id, page) |
|
|
|
def create_update_answer_link(case_log_answer, case_log_id, page) |
|
|
|