From d19223c873e25347e79d8312c981618d098b4bf4 Mon Sep 17 00:00:00 2001 From: Bernie Chiu Date: Tue, 21 Jan 2014 16:19:16 +0800 Subject: [PATCH] Fix duplicate options --- .../survey/back_end/surveys_controller.rb | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb b/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb index 7b315146..8a7fd5b2 100644 --- a/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb +++ b/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb @@ -199,6 +199,7 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController end end end + @survey.survey_questions.all.each do |question| new_question = @new_survey.survey_questions.new question.attributes.each do |key, value| @@ -210,30 +211,32 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController end end end - question.survey_question_options.all.each do |option| - new_option = new_question.survey_question_options.new - option.attributes.each do |key, value| - unless ['_id', 'survey_question_id'].include? key - if option.respond_to?(key + '_translations') - new_option.send(key + '_translations=', value) - else - new_option.write_attribute(key, value) - end - end - end - end - question.survey_question_radiogroups.all.each do |radiogroup| - new_radiogroup = new_question.survey_question_radiogroups.new - radiogroup.attributes.each do |key, value| - unless ['_id', 'survey_question_id'].include? key - if radiogroup.respond_to?(key + '_translations') - new_radiogroup.send(key + '_translations=', value) - else - new_radiogroup.write_attribute(key, value) - end - end - end - end + + # question.survey_question_options.all.each do |option| + # new_option = new_question.survey_question_options.new + # option.attributes.each do |key, value| + # unless ['_id', 'survey_question_id'].include? key + # if option.respond_to?(key + '_translations') + # new_option.name_translations = value + # else + # new_option.write_attribute(key, value) + # end + # end + # end + # end + + # question.survey_question_radiogroups.all.each do |radiogroup| + # new_radiogroup = new_question.survey_question_radiogroups.new + # radiogroup.attributes.each do |key, value| + # unless ['_id', 'survey_question_id'].include? key + # if radiogroup.respond_to?(key + '_translations') + # new_option.name_translations = value + # else + # new_radiogroup.write_attribute(key, value) + # end + # end + # end + # end end @new_survey.create_user_id = current_user.id