ques: fix submit
This commit is contained in:
parent
adc15951bb
commit
515185d87c
|
@ -97,8 +97,13 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
|||
@survey.survey_answers.each do |answer|
|
||||
row = []
|
||||
@survey_questions.each do |question|
|
||||
if question.type == ::SurveyQuestion::Radiogroup
|
||||
options = Hash[question.survey_question_options.collect{|o| [ o.id.to_s, o.name ] }]
|
||||
row << Hash[answer[question.id.to_s].map {|o, g| [options[o], g]}]
|
||||
else
|
||||
row << answer[question.id.to_s]
|
||||
end
|
||||
end
|
||||
csv << row
|
||||
end
|
||||
|
||||
|
@ -143,14 +148,38 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController
|
|||
@survey.survey_questions.all.each do |question|
|
||||
new_question = @new_survey.survey_questions.new
|
||||
question.attributes.each do |key, value|
|
||||
unless ['_id', 'created_at', 'updated_at'].include? key
|
||||
if @survey.respond_to?(key + '_translations')
|
||||
unless ['_id', 'survey_id'].include? key
|
||||
if question.respond_to?(key + '_translations')
|
||||
new_question.send(key + '_translations=', value)
|
||||
else
|
||||
new_question.write_attribute(key, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
question.survey_question_options.all.each do |option|
|
||||
new_option = new_question.survey_question_options.new
|
||||
option.attributes.each do |key, value|
|
||||
unless ['_id', 'survey_question_id'].include? key
|
||||
if option.respond_to?(key + '_translations')
|
||||
new_option.send(key + '_translations=', value)
|
||||
else
|
||||
new_option.write_attribute(key, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
question.survey_question_radiogroups.all.each do |radiogroup|
|
||||
new_radiogroup = new_question.survey_question_radiogroups.new
|
||||
radiogroup.attributes.each do |key, value|
|
||||
unless ['_id', 'survey_question_id'].include? key
|
||||
if radiogroup.respond_to?(key + '_translations')
|
||||
new_radiogroup.send(key + '_translations=', value)
|
||||
else
|
||||
new_radiogroup.write_attribute(key, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@new_survey.create_user_id = current_user.id
|
||||
|
|
|
@ -60,7 +60,7 @@ class Panel::Survey::FrontEnd::SurveysController < OrbitWidgetController
|
|||
if answer[qid]
|
||||
answer[qid].each do |oid, value|
|
||||
unless value.blank?
|
||||
@answer_model[qid][options[oid]] = radiogroups[value]
|
||||
@answer_model[qid][oid] = radiogroups[value]
|
||||
else
|
||||
if question.is_required
|
||||
@answer_model.errors.add question.title, t('survey_question.required_error')
|
||||
|
|
|
@ -8,7 +8,6 @@ class SurveyQuestion
|
|||
Radiogroup = 5
|
||||
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :title, :localize => true
|
||||
field :description, :localize => true
|
||||
|
|
Loading…
Reference in New Issue