From 3a721c653beb3d9511d53973c8a94a0a30d223de Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Fri, 25 Oct 2013 10:28:29 +0800 Subject: [PATCH] merge --- .../survey/back_end/surveys_controller.rb | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 b72558d16..13fc426ca 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 @@ -110,11 +110,31 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController @survey_questions.each_with_index do |question, index| question.update_attributes(title: titles[index]) end + + @survey.survey_answers.destroy # Modify multiline options if changed @survey_questions.each_with_index do |question, index| - case question.type + + when ::SurveyQuestion::Radio, ::SurveyQuestion::Select + (2..(question.survey_question_options.count + 1)).each do |row| + (1..@spreadsheet.row(row)[index*2 + 1].to_i).each do + @answer_model = @survey.survey_answers.new + @answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2] + @answer_model.save! + end + end + + when ::SurveyQuestion::Check + (2..(question.survey_question_options.count + 1)).each do |row| + (1..@spreadsheet.row(row)[index*2 + 1].to_i).each do + @answer_model = @survey.survey_answers.new + @answer_model[question.id.to_s] = [ @spreadsheet.row(row)[index*2] ] + @answer_model.save! + end + end + when ::SurveyQuestion::Radiogroup radio_groups = [] spreadsheet_radiogroups_lines =