fix import-csv column error
This commit is contained in:
parent
f3f4dc842c
commit
1266cd1384
|
@ -103,23 +103,23 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
||||||
|
|
||||||
@current_row = 2
|
@current_row = 2
|
||||||
@header = @spreadsheet.row(1)
|
@header = @spreadsheet.row(1)
|
||||||
|
|
||||||
# (2..@spreadsheet.last_row).each do |i|
|
# (2..@spreadsheet.last_row).each do |i|
|
||||||
# parse each row here
|
# parse each row here
|
||||||
# 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
|
||||||
@current_row = @current_row + question.survey_question_options.count - 1
|
@current_row = @current_row + question.survey_question_options.count - 1
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue