From 6bba6b2b76e73ecefbe25077844cb7d1c7c62e5b Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 17 Jan 2015 14:04:20 +0800 Subject: [PATCH 1/2] weiwan --- app/helpers/poll_helper.rb | 4 ++++ app/views/poll/_choice_show.html.erb | 2 +- config/locales/zh.yml | 2 +- public/stylesheets/polls.css | 6 +++--- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 7497e4d79..da49219be 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -55,6 +55,10 @@ module PollHelper t == 0 ? 0 : format("%.2f", e*100/t) end + # def total_answer + # poll_question.poll_votes(distinct a.ID + # end +# #页面体型显示 def options_show pq case pq diff --git a/app/views/poll/_choice_show.html.erb b/app/views/poll/_choice_show.html.erb index 4ccc5b938..16971d5ad 100644 --- a/app/views/poll/_choice_show.html.erb +++ b/app/views/poll/_choice_show.html.erb @@ -19,7 +19,7 @@ <% end %> <%= l(:label_poll_valid_commit) %> - <%= @poll.users.count %> + <%= poll_question.poll_votes.count %>   diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7f7d00ba3..ac7c52fe2 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2262,7 +2262,7 @@ zh: label_poll_proportion: 比例 label_poll_valid_commit: 本题有效填写人次 label_poll_result: 问卷调查_问卷统计 - label_answer: 答案 + label_answer: 答案: label_poll_answer_valid_result: 以上为有效问答题答案! label_answer_total: 总计: diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 3f66f7311..8289cc1d2 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -65,10 +65,10 @@ a:hover.ur_button{ background:#0fa9bb; text-decoration:none;} .ur_table_result{ color:#5d5d5d;border-right:1px solid #cbcbcb;border-bottom:1px solid #cbcbcb;} .ur_table_result tr td{ border-left:1px solid #cbcbcb;border-top:1px solid #cbcbcb; height:20px;} .table_bluebg{ background:#d7e5ee; color:#2f3a40; height:24px;} -.td327{ width:601px; padding-left:5px;} +.td327{ width:601px; padding-left:5px; word-break:break-all; word-wrap:break-word; } .td42{ width:42px; text-align:center;} -.td287{ width:259px;padding-left:5px; } -.td111{ width:601px;padding-left:5px; word-break:break-all; word-wrap:break-word } +.td287{ width:259px;padding-left:5px; text-align:center; } +.td111{ width:601px;padding-left:5px; word-break:break-all; word-wrap:break-word; } .Bar{ position: relative; width: 120px; border: 1px solid #cbcbcb; float:left; height:10px; margin-top:5px; margin-right:3px; } .Bar span{ display: block; position: relative;background:#64badb;/* 进度条背景颜色 */ color: #333333;height: 10px; /* 高度 */ line-height: 20px; } .ur_progress_text{ color:#3a3a3a;} From e8cca08f40b3df68a76c512f72e9541a2764b136 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 17 Jan 2015 14:54:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=9A=E9=80=89=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=8E=BB=E9=87=8D=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/poll_helper.rb | 9 +++++---- app/views/poll/_choice_show.html.erb | 6 +++--- public/stylesheets/polls.css | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index da49219be..17ef02a36 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -55,10 +55,11 @@ module PollHelper t == 0 ? 0 : format("%.2f", e*100/t) end - # def total_answer - # poll_question.poll_votes(distinct a.ID - # end -# + #多选的时候查询去重 + def total_answer id + total = PollVote.find_by_sql("SELECT distinct(user_id) FROM `poll_votes` where poll_question_id = #{id}").count + end + #页面体型显示 def options_show pq case pq diff --git a/app/views/poll/_choice_show.html.erb b/app/views/poll/_choice_show.html.erb index 16971d5ad..d541386d3 100644 --- a/app/views/poll/_choice_show.html.erb +++ b/app/views/poll/_choice_show.html.erb @@ -12,14 +12,14 @@ <%= poll_answer.poll_votes.count %>
- +
- <%= statistics_result_percentage(poll_answer.poll_votes.count, @poll.users.count) %>% + <%= statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)) %>% <% end %> <%= l(:label_poll_valid_commit) %> - <%= poll_question.poll_votes.count %> + <%= total_answer(poll_question.id) %>   diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 157eb8388..c4925eda2 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -42,7 +42,7 @@ ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;} /*问卷页面*/ .polls_box{ border:1px solid #dcdcdc; padding:15px 30px;} -.ur_page_title{ font-size:16px; text-align:center; color:#353535;word-break: break-all; word-wrap: break-word;} +.ur_page_title{ font-size:16px; text-align:center; color:#353535; word-break:break-all; word-wrap:break-word;} .ur_prefix_content{ color:#656565; text-indent:30px; margin-top:10px; } .ur_card{border-top:1px solid #dcdcdc;margin-top:20px; color:#3a3a3a;} .ur_title{ padding:20px 0px ; float:left; width:604px; word-break: break-all; word-wrap: break-word;} @@ -60,8 +60,8 @@ a:hover.ur_button{ background:#0fa9bb; text-decoration:none;} .ur_progress_text{ text-align:center; font-size:14px;} /*问卷结果*/ -.title_index{ color:#62bcd7;} -.ur_title_result{ padding-top:20px;} +.title_index{ color:#62bcd7; } +.ur_title_result{ padding-top:20px; word-break:break-all; word-wrap:break-word;} .ur_table_result{ color:#5d5d5d;border-right:1px solid #cbcbcb;border-bottom:1px solid #cbcbcb;} .ur_table_result tr td{ border-left:1px solid #cbcbcb;border-top:1px solid #cbcbcb; height:20px;} .table_bluebg{ background:#d7e5ee; color:#2f3a40; height:24px;}