fix import-csv column error

This commit is contained in:
thomaschen 2013-10-21 17:01:44 +08:00 committed by Manson Wang
parent f3f4dc842c
commit 1266cd1384
1 changed files with 6 additions and 6 deletions

View File

@ -109,13 +109,13 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
# end # end
@survey.survey_answers.destroy @survey.survey_answers.destroy
@survey_questions.each do |question| @survey_questions.each_with_index do |question,column|
case question.type case question.type
when ::SurveyQuestion::Radio, ::SurveyQuestion::Select when ::SurveyQuestion::Radio, ::SurveyQuestion::Select
(@current_row..(@current_row + question.survey_question_options.count - 1)).each do |i| (@current_row..(@current_row + question.survey_question_options.count - 1)).each do |row|
(1..@spreadsheet.row(i)[1].to_i).each do (1..@spreadsheet.row(row)[column + 1].to_i).each do
@answer_model = @survey.survey_answers.new @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! @answer_model.save!
end end
end end