fix error

This commit is contained in:
thomaschen 2013-10-25 15:35:48 +08:00
parent 3a721c653b
commit a25a82dc89
1 changed files with 13 additions and 11 deletions

View File

@ -113,26 +113,28 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
@survey.survey_answers.destroy @survey.survey_answers.destroy
# End of speadsheet
@end_row = @spreadsheet.count
# Modify multiline options if changed # Modify multiline options if changed
@survey_questions.each_with_index do |question, index| @survey_questions.each_with_index do |question, index|
case question.type case question.type
when ::SurveyQuestion::Radio, ::SurveyQuestion::Select when ::SurveyQuestion::Radio, ::SurveyQuestion::Select
(2..(question.survey_question_options.count + 1)).each do |row| ((question.survey_question_options.count + 2)..@end_row).each do |row|
(1..@spreadsheet.row(row)[index*2 + 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(row)[index*2] if !@spreadsheet.row(row)[index*2].nil? && @spreadsheet.row(row)[index*2] != " "
@answer_model.save! @answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2]
end @answer_model.save!
end
end end
when ::SurveyQuestion::Check when ::SurveyQuestion::Check
(2..(question.survey_question_options.count + 1)).each do |row| ((question.survey_question_options.count + 2)..@end_row).each do |row|
(1..@spreadsheet.row(row)[index*2 + 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(row)[index*2] ] if !@spreadsheet.row(row)[index*2].nil?
@answer_model.save! @answer_model[question.id.to_s] = @spreadsheet.row(row)[index*2].split("\"").select.each_with_index { |str, i| i.odd? }
end @answer_model.save!
end
end end
when ::SurveyQuestion::Radiogroup when ::SurveyQuestion::Radiogroup