Allow update answers on radio groups

Conflicts:

	vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb
This commit is contained in:
Bernie Chiu 2013-10-25 16:26:06 +08:00 committed by Manson Wang
parent d1d245d9ea
commit 7b6b7e2bed
1 changed files with 22 additions and 1 deletions

View File

@ -145,6 +145,28 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
radio_groups << @spreadsheet.row(line)[index * 2]
end
# Grab answers info
answers = []
(spreadsheet_radiogroups_lines..@spreadsheet.last_row).each do |line|
if not @spreadsheet.row(line)[index * 2].blank?
answers << eval(@spreadsheet.row(line)[index * 2])
end
end
# Save the answers
answers.each do |answer|
options = Hash[question.survey_question_options.collect { |o| [ o.id.to_s, o.name ] }]
@answer_model = @survey.survey_answers.new
@answer_model[question.id.to_s] = {}
answer.each do |option, value|
@answer_model[question.id.to_s][options.invert[option]] = value
end
@answer_model.save!
end
# Parse the needed info in the array
radio_titles = []
radio_options = []
@ -179,7 +201,6 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
question.survey_question_radiogroups.each_with_index do |option, index|
groups_of_radios.each do |radios|
if radios[index] != option.name_translations["zh_tw"]
binding.pry
option.update_attributes(name: radios[index])
break
end