From 59c21d81e9c3244e86555740939be3ce78ad150a Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 16 Jan 2015 16:48:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E5=88=86=E6=AF=8D?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E4=B8=BA0=E7=9A=84bug=20=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E7=B2=BE=E7=A1=AE=E5=88=B0=E4=B8=A4=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/poll_helper.rb | 4 +- app/views/poll/statistics_result.html.erb | 65 +++++++++++------------ 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 1a8fabae3..55418faf2 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -50,7 +50,9 @@ module PollHelper #统计答题百分比 def statistics_result_percentage(e, t) - return e*100/t + e = e.to_f + t = t.to_f + t == 0 ? 0 : format("%.2f", e*100/t) end def options_show p diff --git a/app/views/poll/statistics_result.html.erb b/app/views/poll/statistics_result.html.erb index dea18f8d8..057314a9c 100644 --- a/app/views/poll/statistics_result.html.erb +++ b/app/views/poll/statistics_result.html.erb @@ -1,38 +1,33 @@ - - - <%= l(:label_poll_result) %> - <%= stylesheet_link_tag 'polls', :media => 'all' %> - - - -
-
-

<%= @poll.polls_name %> <%= l(:label_poll) %>

-
- -<% @poll_questions.each do |poll_question| %> -
-
    -
  1. -
    - 第<%= poll_question.question_number %>题:<%= poll_question.question_title %> - [<%= options_show(poll_question.question_type) %>] -
    - <%= render :partial =>'choice_show', :locals =>{ :poll_question => poll_question } %> -
  2. -
- <% end %> -
    - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> -
-
-
-
-
-
- -
- + + + <%= l(:label_poll_result) %> + <%= stylesheet_link_tag 'polls', :media => 'all' %> + + +
+
+

<%= @poll.polls_name %> <%= l(:label_poll) %>

+
+ <% @poll_questions.each do |poll_question| %> +
+
    +
  1. +
    + 第<%= poll_question.question_number %>题:<%= poll_question.question_title %> [<%= options_show(poll_question.question_type) %>] +
    + <%= render :partial =>'choice_show', :locals =>{ :poll_question => poll_question } %> +
  2. +
+ <% end %> +
    + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> +
+
+
+
+
+
+