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 %> - -
-
-
-
-
- -
- + + + <%= 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 %> + +
+
+
+
+
+