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:
		
							parent
							
								
									62e9acdbb8
								
							
						
					
					
						commit
						74b89f1fac
					
				| 
						 | 
					@ -145,6 +145,28 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
 | 
				
			||||||
          radio_groups << @spreadsheet.row(line)[index * 2]
 | 
					          radio_groups << @spreadsheet.row(line)[index * 2]
 | 
				
			||||||
        end
 | 
					        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
 | 
					        # Parse the needed info in the array
 | 
				
			||||||
        radio_titles = []
 | 
					        radio_titles = []
 | 
				
			||||||
        radio_options = []
 | 
					        radio_options = []
 | 
				
			||||||
| 
						 | 
					@ -179,7 +201,6 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
 | 
				
			||||||
        question.survey_question_radiogroups.each_with_index do |option, index|
 | 
					        question.survey_question_radiogroups.each_with_index do |option, index|
 | 
				
			||||||
          groups_of_radios.each do |radios|
 | 
					          groups_of_radios.each do |radios|
 | 
				
			||||||
            if radios[index] != option.name_translations["zh_tw"]
 | 
					            if radios[index] != option.name_translations["zh_tw"]
 | 
				
			||||||
              binding.pry
 | 
					 | 
				
			||||||
              option.update_attributes(name: radios[index])
 | 
					              option.update_attributes(name: radios[index])
 | 
				
			||||||
              break
 | 
					              break
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue