diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 3de4e8339..3b4bf3694 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -86,7 +86,7 @@ class PollController < ApplicationController def statistics_result @poll = Poll.find(params[:id]) poll_questions = @poll.poll_questions - @poll_questions = paginateHelper poll_questions,3 #分页 + @poll_questions = paginateHelper poll_questions, 5 respond_to do |format| format.html{render :layout => 'base_courses'} end diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 7816d8e37..1a8fabae3 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -27,7 +27,7 @@ module PollHelper false end end - + #获取文本题答案 def get_anwser_vote_text(question_id,user_id) pv = PollVote.find_by_poll_question_id_and_user_id(question_id,user_id) @@ -47,4 +47,20 @@ module PollHelper true end end + + #统计答题百分比 + def statistics_result_percentage(e, t) + return e*100/t + end + + def options_show p + case p + when 1 + "单选题" + when 2 + "多选题" + else + "问答题" + end + end end \ No newline at end of file diff --git a/app/views/poll/_choice_show.html.erb b/app/views/poll/_choice_show.html.erb index aa425e748..16971d5ad 100644 --- a/app/views/poll/_choice_show.html.erb +++ b/app/views/poll/_choice_show.html.erb @@ -1,25 +1,28 @@ -
选项 | -小计 | -比例 | -
<%= poll_answer.answer_text %> | -<% poll_answer.poll_votes.count %> | - 75% |
-
本题有效填写人次 | -<%= poll_question.poll_votes.count %> | -- |
<%= l(:label_poll_options) %> | +<%= l(:label_poll_subtotal) %> | +<%= l(:label_poll_proportion) %> | +
<%= poll_answer.answer_text %> | +<%= poll_answer.poll_votes.count %> | +
+
+
+
+ <%= statistics_result_percentage(poll_answer.poll_votes.count, @poll.users.count) %>% |
+
<%= l(:label_poll_valid_commit) %> | +<%= poll_question.poll_votes.count %> | ++ |