问卷统计最终效果

This commit is contained in:
huang 2015-01-16 15:49:22 +08:00
parent b53686dfd7
commit 7177303eeb
5 changed files with 53 additions and 31 deletions

View File

@ -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

View File

@ -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

View File

@ -1,25 +1,28 @@
<div class="ur_table_result">
<table border="0" cellspacing="0" cellpadding="0" >
<tbody>
<tr class="table_bluebg">
<td class="td327">选项 </td>
<td class="td42">小计 </td>
<td class="td287">比例 </td>
</tr>
<% poll_question.poll_answers.each do |poll_answer| %>
<tr>
<td class="td327"><%= poll_answer.answer_text %> </td>
<td class="td42"><% poll_answer.poll_votes.count %> </td>
<td class="td287"><div class="Bar"><span style="width:75%;"></span></div> 75% </td>
</tr>
<% end %>
<tr class="table_bluebg">
<td class="td327">本题有效填写人次 </td>
<td class="td42"><%= poll_question.poll_votes.count %></td>
<td class="td287">&nbsp; </td>
</tr>
</tbody>
</table>
</div>
<table border="0" cellspacing="0" cellpadding="0" >
<tbody>
<tr class="table_bluebg">
<td class="td327"><%= l(:label_poll_options) %> </td>
<td class="td42"><%= l(:label_poll_subtotal) %> </td>
<td class="td287"><%= l(:label_poll_proportion) %> </td>
</tr>
<% poll_question.poll_answers.each do |poll_answer| %>
<tr>
<td class="td327"><%= poll_answer.answer_text %> </td>
<td class="td42"><%= poll_answer.poll_votes.count %> </td>
<td class="td287">
<div class="Bar">
<span style="width:<%= statistics_result_percentage(poll_answer.poll_votes.count, @poll.users.count) %>%;" id="choice_percentage_<%= poll_answer.id %>"></span>
</div>
<%= statistics_result_percentage(poll_answer.poll_votes.count, @poll.users.count) %>%</td>
</tr>
<% end %>
<tr class="table_bluebg">
<td class="td327"><%= l(:label_poll_valid_commit) %> </td>
<td class="td42"><%= poll_question.poll_votes.count %></td>
<td class="td287">&nbsp; </td>
</tr>
</tbody>
</table>
</div>

View File

@ -2,14 +2,14 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>问卷调查_问卷结果</title>
<title><%= l(:label_poll_result) %></title>
<%= stylesheet_link_tag 'polls', :media => 'all' %>
</head>
<body>
<div class="polls_content polls_box" id="polls">
<div class="ur_page_head" >
<h1 class="ur_page_title">某问卷统计</h1>
<h1 class="ur_page_title"><%= @poll.polls_name %> <%= l(:label_poll) %></h1>
</div>
<% @poll_questions.each do |poll_question| %>
@ -17,7 +17,8 @@
<ol>
<li class="ur_question_item">
<div class="ur_title_result">
<span class="title_index">第<%= poll_question.question_number %>题:</span><%= poll_question.question_title %> <span class="title_index">[单选题]<% poll_question.poll_answers %></span>
<span class="title_index">第<%= poll_question.question_number %>题:</span><%= poll_question.question_title %>
<span class="title_index">[<%= options_show(poll_question.question_type) %>]</span>
</div>
<%= render :partial =>'choice_show', :locals =>{ :poll_question => poll_question } %>
</li>
@ -28,11 +29,8 @@
</ul>
<div class="cl"></div>
<div class="ur_buttons">
<!--<a href="#" class=" ur_button" >上一页</a>-->
<!--<a href="#" class="ur_button" >下一页</a>-->
</div>
<div class="cl"></div>
<div class="ur_progress_text">答题已完成 <strong class="ur_progress_number">0%</strong> </div>
</div>
</div><!--问卷内容end-->

View File

@ -2253,5 +2253,10 @@ zh:
label_new_answer: 新建选项
label_poll_title: 问卷标题
label_poll_description: 问卷描述
label_poll_options: 选项
label_poll_subtotal: 小计
label_poll_proportion: 比例
label_poll_valid_commit: 本题有效填写人次
label_poll_result: 问卷调查_问卷统计