From ab9214a4dbd0ff686c20afd5f63f4990dd4ac329 Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Fri, 25 Oct 2013 17:11:47 +0800 Subject: [PATCH] fix error --- .../survey/back_end/surveys_controller.rb | 39 ++++--------------- 1 file changed, 7 insertions(+), 32 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 8e156bb5d..c221df87f 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 @@ -141,14 +141,14 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController @answer_model[question.id.to_s] = @spreadsheet.row(row)[index * 2] when ::SurveyQuestion::Radio, ::SurveyQuestion::Select - if !@spreadsheet.row(row)[index*2].nil? && @spreadsheet.row(row)[index*2] != " " - @answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2] - end + if !@spreadsheet.row(row)[index*2].nil? && @spreadsheet.row(row)[index*2] != " " + @answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2] + end when ::SurveyQuestion::Check - if !@spreadsheet.row(row)[index*2].nil? - @answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2].split("\"").select.each_with_index { |str, i| i.odd? } - end + if !@spreadsheet.row(row)[index*2].nil? && @spreadsheet.row(row)[index*2] != " " + @answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2].split("\"").select.each_with_index { |str, i| i.odd? } + end when ::SurveyQuestion::Radiogroup radio_groups = [] @@ -218,37 +218,12 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController end end end - end end @answer_model.save! - end #end row - - # @start_row = 2 - # @survey.survey_answers.destroy - # @survey_questions.each_with_index do |question,index| - # case question.type - # when ::SurveyQuestion::Radio, ::SurveyQuestion::Select - # (@start_row..(@start_row + 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 - # (@start_row..(@start_row + 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 - # else - # end - # end + end #end row redirect_to panel_survey_back_end_surveys_url, :notice => :success end