From 1266cd1384991909cf8bfa2150b52260169fd953 Mon Sep 17 00:00:00 2001 From: thomaschen <99703040@nccu.edu.tw> Date: Mon, 21 Oct 2013 17:01:44 +0800 Subject: [PATCH] fix import-csv column error --- .../panel/survey/back_end/surveys_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 908e85cdd..b68805f62 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 @@ -103,23 +103,23 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController @current_row = 2 @header = @spreadsheet.row(1) - + # (2..@spreadsheet.last_row).each do |i| # parse each row here # end @survey.survey_answers.destroy - @survey_questions.each do |question| + @survey_questions.each_with_index do |question,column| case question.type when ::SurveyQuestion::Radio, ::SurveyQuestion::Select - (@current_row..(@current_row + question.survey_question_options.count - 1)).each do |i| - (1..@spreadsheet.row(i)[1].to_i).each do + (@current_row..(@current_row + question.survey_question_options.count - 1)).each do |row| + (1..@spreadsheet.row(row)[column + 1].to_i).each do @answer_model = @survey.survey_answers.new - @answer_model[question.id.to_s] = @spreadsheet.row(i)[0] + @answer_model[question.id.to_s] = @spreadsheet.row(row)[column] @answer_model.save! end end - @current_row = @current_row + question.survey_question_options.count - 1 + @current_row = @current_row + question.survey_question_options.count - 1 else end end