2014-10-06 05:55:25 +00:00
|
|
|
Rails.application.routes.draw do
|
|
|
|
|
|
|
|
locales = Site.first.in_use_locales rescue I18n.available_locales
|
2021-09-12 12:20:03 +00:00
|
|
|
Thread.new do
|
|
|
|
surveys = QuestionnaireSurvey.where(:already_fix_data.in=>[nil,false]).to_a
|
|
|
|
surveys.each do |survey|
|
|
|
|
group_data = survey.survey_answers.asc(:updated_at).group_by(&:user)
|
|
|
|
group_data.each do |user_id,survey_answers|
|
|
|
|
answer_group = SurveyAnswerGroup.where(:questionnaire_survey_id=>survey.id,:user=>user_id).first
|
|
|
|
if answer_group.nil?
|
|
|
|
answer_group = SurveyAnswerGroup.new(:questionnaire_survey_id=>survey.id,:user=>user_id)
|
|
|
|
end
|
|
|
|
answer_group.last_modified = survey_answers.last.updated_at
|
|
|
|
answer_group.survey_answer_ids = survey_answers.map{|a| a.id}
|
|
|
|
answer_group.save
|
2021-09-12 12:34:09 +00:00
|
|
|
survey_answers.each{|a| a.updated_at = a.created_at;a.save}
|
2021-09-12 12:20:03 +00:00
|
|
|
end
|
|
|
|
survey.already_fix_data = true
|
|
|
|
survey.survey_questions.each do |q|
|
|
|
|
q.survey_question_options.where("name.zh_tw.zh_tw"=>//).destroy
|
|
|
|
q.survey_question_options.where("name.en.en"=>//).destroy
|
|
|
|
end
|
|
|
|
survey.save
|
|
|
|
end
|
|
|
|
end
|
2014-10-06 05:55:25 +00:00
|
|
|
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
|
|
|
namespace :admin do
|
2017-04-11 06:10:01 +00:00
|
|
|
get "surveys/checkforthread", to: "surveys#checkforthread"
|
2014-10-06 05:55:25 +00:00
|
|
|
resources :surveys do
|
|
|
|
collection do
|
|
|
|
get 'delete'
|
|
|
|
end
|
|
|
|
member do
|
|
|
|
get 'export'
|
|
|
|
get 'set_answers'
|
2018-01-03 08:36:00 +00:00
|
|
|
get 'set_sections'
|
|
|
|
get 'add_section'
|
2021-07-08 13:31:27 +00:00
|
|
|
get 'pagination_setting'
|
|
|
|
patch 'save_pagination_setting'
|
2018-01-03 08:36:00 +00:00
|
|
|
post 'create_section'
|
|
|
|
delete 'delete_section'
|
|
|
|
get 'edit_section'
|
|
|
|
patch 'update_section'
|
2014-10-06 05:55:25 +00:00
|
|
|
get 'jump'
|
|
|
|
get 'duplicate_it'
|
2015-11-27 11:55:47 +00:00
|
|
|
get 'answer_sets'
|
|
|
|
get 'answer_set'
|
2021-09-12 12:20:03 +00:00
|
|
|
get 'answer_list'
|
|
|
|
get 'export_answers'
|
2014-10-06 05:55:25 +00:00
|
|
|
end
|
|
|
|
resources :answers, :controller => :surveys_answers do
|
|
|
|
collection do
|
|
|
|
get 'delete'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
resources :surveys do
|
|
|
|
collection do
|
|
|
|
get ':slug_title-:uid', to: 'surveys#show'
|
|
|
|
end
|
|
|
|
member do
|
|
|
|
get 'result'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|