import 'check' and 'select' question success
This commit is contained in:
parent
1266cd1384
commit
5156701094
|
@ -101,7 +101,7 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
|||
else raise "Unknown file type: #{file.original_filename}"
|
||||
end
|
||||
|
||||
@current_row = 2
|
||||
@start_row = 2
|
||||
@header = @spreadsheet.row(1)
|
||||
|
||||
# (2..@spreadsheet.last_row).each do |i|
|
||||
|
@ -109,17 +109,24 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
|||
# end
|
||||
|
||||
@survey.survey_answers.destroy
|
||||
@survey_questions.each_with_index do |question,column|
|
||||
@survey_questions.each_with_index do |question,index|
|
||||
case question.type
|
||||
when ::SurveyQuestion::Radio, ::SurveyQuestion::Select
|
||||
(@current_row..(@current_row + question.survey_question_options.count - 1)).each do |row|
|
||||
(1..@spreadsheet.row(row)[column + 1].to_i).each do
|
||||
(@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)[column]
|
||||
@answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2]
|
||||
@answer_model.save!
|
||||
end
|
||||
end
|
||||
@current_row = @current_row + question.survey_question_options.count - 1
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue