From 7e0657d983299c0bb2daaa92f162963678c0c8c6 Mon Sep 17 00:00:00 2001 From: Spen Date: Tue, 15 Oct 2013 11:13:15 +0800 Subject: [PATCH] fix survey_b result and export value ( float ) --- .../panel/survey_b/back_end/survey_b/export.html.erb | 6 +++--- .../panel/survey_b/back_end/survey_b/result.html.erb | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/export.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/export.html.erb index 4fa718ac7..ded30d657 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/export.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/export.html.erb @@ -184,7 +184,7 @@ <%= t('survey_b.no_data') %> <% @tcount = @tcount + @results[i_key]['count'] %> <% else %> - <%= ( ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ).round(2) %> + <%= sprintf("%.2f", ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %> <% @tcount = @tcount + (( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %> <% end %> <% end %> @@ -198,7 +198,7 @@ <%= t('survey_b.no_data') %> <% @tcount = @tcount + @results[i_key]['count'] %> <% else %> - <%= ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ).round(2) %> + <%= sprintf("%.2f", ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %> <% @tcount = @tcount + ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %> <% end %> <% end %> @@ -223,7 +223,7 @@ <%= t('survey_b.no_data') %> <% @tcount = @tcount + @results[i_key]['count'] %> <% else %> - <%= ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ).round(2) %> + <%= sprintf("%.2f", ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f )) %> <% @tcount = @tcount + ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ) %> <% end %> <% end %> diff --git a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb index 2e7c2769c..19d27a11e 100644 --- a/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb +++ b/vendor/built_in_modules/survey_b/app/views/panel/survey_b/back_end/survey_b/result.html.erb @@ -30,14 +30,16 @@ <% if @results[i_key]['count'] == 0 %> <%= t('survey_b.no_data') %> <% else %> - <%= ( ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ).round(2) %> + <%= sprintf("%.2f", ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ) %> + <%#= ( ( @results[i_key]['sum'].to_f / t('survey_b.questions').count.to_f ) / @results[i_key]['count'].to_f ).round(2) %> <% end %> <% if @results[i_key]['count'] == 0 %> <%= t('survey_b.no_data') %> <% else %> - <%= ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ).round(2) %> + <%= sprintf("%.2f", ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ) %> + <%#= ( ( @results[i_key]['sum7'].to_f / 7.0 ) / @results[i_key]['count'].to_f ).round(2) %> <% end %> @@ -48,7 +50,8 @@ <% if @results[i_key]['count'] == 0 %> <%= t('survey_b.no_data') %> <% else %> - <%= ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ).round(2) %> + <%= sprintf("%.2f", ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f )) %> + <%#= ( @results[i_key][q_key].to_f / @results[i_key]['count'].to_f ).round(2) %> <% end %> <% end %> @@ -92,7 +95,6 @@ //bar - var data_bar_<%= item %> = google.visualization.arrayToDataTable([ ['<%= t("survey_b.#{item}_label") %>', '%'], <% @results[item].each do |institution, count| %>