diff --git a/app/models/dataset.rb b/app/models/dataset.rb index c1c275c..33316ea 100644 --- a/app/models/dataset.rb +++ b/app/models/dataset.rb @@ -30,8 +30,18 @@ eql?(plan.datasets.where(order: 1).first) end - def has_common_answers?(section) - !Section.find(section[:id]).questions.flat_map(&:answers).select(&:is_common?).empty? + # Return main dataset + def get_main + plan.datasets.first + end + + def has_common_answers?(section_id) + self.answers.each do |answer| + if answer.question_id.in?(Section.find(section_id).questions.pluck(:id)) && answer.is_common + return true + end + end + return false end ## diff --git a/app/views/branded/phases/_edit_plan_answers_datasets.html.erb b/app/views/branded/phases/_edit_plan_answers_datasets.html.erb index 12c5f54..ae9b045 100644 --- a/app/views/branded/phases/_edit_plan_answers_datasets.html.erb +++ b/app/views/branded/phases/_edit_plan_answers_datasets.html.erb @@ -44,11 +44,12 @@