survey module: result chart display only other

Conflicts:

	config/environments/production.rb
This commit is contained in:
iCross 2013-06-04 21:47:25 +08:00
parent d2f131d160
commit 5ea0c5bd5c
2 changed files with 26 additions and 4 deletions
config/environments
vendor/built_in_modules/survey/app/models

View File

@ -59,4 +59,17 @@ Orbit::Application.configure do
# Send deprecation notices to registered listeners # Send deprecation notices to registered listeners
config.active_support.deprecation = :notify 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 end

View File

@ -73,13 +73,18 @@ class Survey
survey_questions.each do |question| survey_questions.each do |question|
qid = question.id.to_s qid = question.id.to_s
options = question.survey_question_options.map(&:name)
case question.type case question.type
when ::SurveyQuestion::Radio, ::SurveyQuestion::Select when ::SurveyQuestion::Radio, ::SurveyQuestion::Select
chart_data[qid] = {} chart_data[qid] = {}
answers = survey_answers.each do |answer| answers = survey_answers.each do |answer|
if answer[qid] if answer[qid]
chart_data[qid][answer[qid]] ||= 0 this_answer = answer[qid]
chart_data[qid][answer[qid]] += 1 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 end
when ::SurveyQuestion::Check when ::SurveyQuestion::Check
@ -87,8 +92,12 @@ class Survey
answers = survey_answers.each do |answer| answers = survey_answers.each do |answer|
if answer[qid] if answer[qid]
answer[qid].each do |option| answer[qid].each do |option|
chart_data[qid][option] ||= 0 this_answer = option
chart_data[qid][option] += 1 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 end
end end