diff --git a/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb b/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb index 72b91e822..b262116d5 100644 --- a/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb +++ b/vendor/built_in_modules/survey/app/controllers/panel/survey/back_end/surveys_controller.rb @@ -114,11 +114,6 @@ class Panel::Survey::BackEnd::SurveysController < OrbitBackendController end end - def chart - @survey = ::Survey.find(params[:id]) - @chart_data, @survey_questions, @survey_answers = @survey.generate_chart_data - end - def set_answers @survey = ::Survey.find(params[:id]) end diff --git a/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb b/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb index 25e2c9a71..5d83101e7 100644 --- a/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb +++ b/vendor/built_in_modules/survey/app/controllers/panel/survey/front_end/surveys_controller.rb @@ -85,6 +85,7 @@ class Panel::Survey::FrontEnd::SurveysController < OrbitWidgetController def result redirect_standalone result_panel_survey_front_end_survey_path(params[:id], :standalone => 'true') do @survey = ::Survey.find params[:id] + @survey.result_type = ::Survey::ResultChart if params[:force_chart] case @survey.result_type when ::Survey::ResultChart @chart_data, @survey_questions, @survey_answers = @survey.generate_chart_data diff --git a/vendor/built_in_modules/survey/app/models/survey.rb b/vendor/built_in_modules/survey/app/models/survey.rb index 2491a4b5c..295658c9b 100644 --- a/vendor/built_in_modules/survey/app/models/survey.rb +++ b/vendor/built_in_modules/survey/app/models/survey.rb @@ -75,6 +75,17 @@ class Survey end end end + when ::SurveyQuestion::Radiogroup + chart_data[qid] = {} + answers = survey_answers.each do |answer| + if answer[qid] + answer[qid].each do |option, group| + chart_data[qid][option] ||= {} + chart_data[qid][option][group] ||= 0 + chart_data[qid][option][group] += 1 + end + end + end end end diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb index 09dde95a5..762b7fc9b 100644 --- a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb +++ b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/_survey.html.erb @@ -15,7 +15,7 @@
  • <%= link_to t('survey.set_answers'), set_answers_panel_survey_back_end_survey_path(survey, :page => params[:page]) %>
  • <%= link_to t('survey.answers_list'), panel_survey_back_end_survey_answers_path(survey, :page => params[:page]) %>
  • <%= link_to t('survey.export_csv'), export_panel_survey_back_end_survey_path(survey, :format => :csv), :target => '_blank' %>
  • -
  • <%= link_to t('survey.chart'), chart_panel_survey_back_end_survey_path(survey, :page => params[:page]) %>
  • +
  • <%= link_to t('survey.chart'), result_panel_survey_front_end_survey_path(survey, :force_chart => true, :standalone => true), :target => '_blank' %>
  • <%= link_to t(:delete_), panel_survey_back_end_survey_path(survey), :confirm => t('sure?'), :method => :delete, :remote => true %>
  • <% end -%> diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/chart.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/chart.html.erb deleted file mode 100644 index 6356b183d..000000000 --- a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys/chart.html.erb +++ /dev/null @@ -1,40 +0,0 @@ -

    <%= @survey.title %> <%= t('survey.chart') %>

    - -<% @survey_questions.each do |question| %> - -

    <%= question.title %>

    - <% case question.type %> - <% when ::SurveyQuestion::Radio, ::SurveyQuestion::Check, ::SurveyQuestion::Select %> -
    - <% else %> -

    <%= t('survey_question.have_not_chart') %>

    - <% end %> - -<% end %> - -
    - <%= link_to t('back'), get_go_back, :class=>"btn" %> -
    - -<% content_for :page_specific_javascript do %> - - -<% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys_answers/_answer.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys_answers/_answer.html.erb index b70c5db3c..94a5e94e1 100644 --- a/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys_answers/_answer.html.erb +++ b/vendor/built_in_modules/survey/app/views/panel/survey/back_end/surveys_answers/_answer.html.erb @@ -7,9 +7,10 @@ <% qid = question.id %> <% case question.type %> <% when ::SurveyQuestion::Check %> - <%= answer[qid].join(', ') %> + <%= ( answer[qid] || [] ).join(', ') %> <% when ::SurveyQuestion::Radiogroup %> - <%= answer[qid].map{|key, value| key + ': ' + value}.join('; ') unless answer[qid].blank? %> + <% options = Hash[question.survey_question_options.collect{|o| [ o.id.to_s, o.name ] }] %> + <%= ( answer[qid] || {} ).map{|key, value| ( options[key] || key ) + ': ' + value}.join('; ') unless answer[qid].blank? %> <% else %> <%= answer[qid] %> <% end %> diff --git a/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb index b0aefc2f9..6db8b0c55 100644 --- a/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb +++ b/vendor/built_in_modules/survey/app/views/panel/survey/front_end/surveys/result.html.erb @@ -2,16 +2,32 @@ <% when ::Survey::ResultChart %>

    <%= @survey.title %> <%= t('survey.chart') %>

    -
    - <% @survey_questions.each do |question| %> +
    +
    +
    +
    + <%= t 'survey.results_count' %>: <%= @survey_questions.count %> +
    +
      + <% @survey_questions.each do |question| %> + <% case question.type %> + <% when ::SurveyQuestion::Radio, ::SurveyQuestion::Check, ::SurveyQuestion::Select %> +
    1. +
      +
    2. + <% when ::SurveyQuestion::Radiogroup %> + <% question.survey_question_options.each do |option| %> +
    3. +
      +
    4. + <% end %> + <% end %> - <% case question.type %> - <% when ::SurveyQuestion::Radio, ::SurveyQuestion::Check, ::SurveyQuestion::Select %> -
      - <% end %> - - <% end %> -
    + <% end %> + +
    +
    +