From 5ea0c5bd5c935659b3d25cc5638297c2207c9704 Mon Sep 17 00:00:00 2001 From: iCross Date: Tue, 4 Jun 2013 21:47:25 +0800 Subject: [PATCH] survey module: result chart display only other Conflicts: config/environments/production.rb --- config/environments/production.rb | 13 +++++++++++++ .../survey/app/models/survey.rb | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 3138ea3c..72cb30a4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -59,4 +59,17 @@ Orbit::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify + + + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + :enable_starttls_auto => true, + :address => "smtp.gmail.com", + :port => '587', + :domain => "smtp.gmail.com", + :authentication => "plain", + :user_name => "redmine@rulingcom.com", + :password => "rulingredmine" + } + end diff --git a/vendor/built_in_modules/survey/app/models/survey.rb b/vendor/built_in_modules/survey/app/models/survey.rb index 0ca9c6c7..4f271eee 100644 --- a/vendor/built_in_modules/survey/app/models/survey.rb +++ b/vendor/built_in_modules/survey/app/models/survey.rb @@ -73,13 +73,18 @@ class Survey survey_questions.each do |question| qid = question.id.to_s + options = question.survey_question_options.map(&:name) case question.type when ::SurveyQuestion::Radio, ::SurveyQuestion::Select chart_data[qid] = {} answers = survey_answers.each do |answer| if answer[qid] - chart_data[qid][answer[qid]] ||= 0 - chart_data[qid][answer[qid]] += 1 + this_answer = answer[qid] + unless options.include? this_answer + this_answer = I18n.t('survey_question.use_custom_option') + end + chart_data[qid][this_answer] ||= 0 + chart_data[qid][this_answer] += 1 end end when ::SurveyQuestion::Check @@ -87,8 +92,12 @@ class Survey answers = survey_answers.each do |answer| if answer[qid] answer[qid].each do |option| - chart_data[qid][option] ||= 0 - chart_data[qid][option] += 1 + this_answer = option + unless options.include? this_answer + this_answer = I18n.t('survey_question.use_custom_option') + end + chart_data[qid][this_answer] ||= 0 + chart_data[qid][this_answer] += 1 end end end