问卷统计最终效果
This commit is contained in:
parent
b53686dfd7
commit
7177303eeb
|
@ -86,7 +86,7 @@ class PollController < ApplicationController
|
||||||
def statistics_result
|
def statistics_result
|
||||||
@poll = Poll.find(params[:id])
|
@poll = Poll.find(params[:id])
|
||||||
poll_questions = @poll.poll_questions
|
poll_questions = @poll.poll_questions
|
||||||
@poll_questions = paginateHelper poll_questions,3 #分页
|
@poll_questions = paginateHelper poll_questions, 5
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html{render :layout => 'base_courses'}
|
format.html{render :layout => 'base_courses'}
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,4 +47,20 @@ module PollHelper
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
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
|
end
|
|
@ -1,25 +1,28 @@
|
||||||
|
|
||||||
<div class="ur_table_result">
|
<div class="ur_table_result">
|
||||||
<table border="0" cellspacing="0" cellpadding="0" >
|
<table border="0" cellspacing="0" cellpadding="0" >
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="table_bluebg">
|
<tr class="table_bluebg">
|
||||||
<td class="td327">选项 </td>
|
<td class="td327"><%= l(:label_poll_options) %> </td>
|
||||||
<td class="td42">小计 </td>
|
<td class="td42"><%= l(:label_poll_subtotal) %> </td>
|
||||||
<td class="td287">比例 </td>
|
<td class="td287"><%= l(:label_poll_proportion) %> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<% poll_question.poll_answers.each do |poll_answer| %>
|
<% poll_question.poll_answers.each do |poll_answer| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="td327"><%= poll_answer.answer_text %> </td>
|
<td class="td327"><%= poll_answer.answer_text %> </td>
|
||||||
<td class="td42"><% poll_answer.poll_votes.count %> </td>
|
<td class="td42"><%= poll_answer.poll_votes.count %> </td>
|
||||||
<td class="td287"><div class="Bar"><span style="width:75%;"></span></div> 75% </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>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr class="table_bluebg">
|
<tr class="table_bluebg">
|
||||||
<td class="td327">本题有效填写人次 </td>
|
<td class="td327"><%= l(:label_poll_valid_commit) %> </td>
|
||||||
<td class="td42"><%= poll_question.poll_votes.count %></td>
|
<td class="td42"><%= poll_question.poll_votes.count %></td>
|
||||||
<td class="td287"> </td>
|
<td class="td287"> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<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' %>
|
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="polls_content polls_box" id="polls">
|
<div class="polls_content polls_box" id="polls">
|
||||||
<div class="ur_page_head" >
|
<div class="ur_page_head" >
|
||||||
<h1 class="ur_page_title">某问卷统计</h1>
|
<h1 class="ur_page_title"><%= @poll.polls_name %> <%= l(:label_poll) %></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% @poll_questions.each do |poll_question| %>
|
<% @poll_questions.each do |poll_question| %>
|
||||||
|
@ -17,7 +17,8 @@
|
||||||
<ol>
|
<ol>
|
||||||
<li class="ur_question_item">
|
<li class="ur_question_item">
|
||||||
<div class="ur_title_result">
|
<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>
|
</div>
|
||||||
<%= render :partial =>'choice_show', :locals =>{ :poll_question => poll_question } %>
|
<%= render :partial =>'choice_show', :locals =>{ :poll_question => poll_question } %>
|
||||||
</li>
|
</li>
|
||||||
|
@ -28,11 +29,8 @@
|
||||||
</ul>
|
</ul>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="ur_buttons">
|
<div class="ur_buttons">
|
||||||
<!--<a href="#" class=" ur_button" >上一页</a>-->
|
|
||||||
<!--<a href="#" class="ur_button" >下一页</a>-->
|
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="ur_progress_text">答题已完成 <strong class="ur_progress_number">0%</strong> </div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div><!--问卷内容end-->
|
</div><!--问卷内容end-->
|
||||||
|
|
|
@ -2253,5 +2253,10 @@ zh:
|
||||||
label_new_answer: 新建选项
|
label_new_answer: 新建选项
|
||||||
label_poll_title: 问卷标题
|
label_poll_title: 问卷标题
|
||||||
label_poll_description: 问卷描述
|
label_poll_description: 问卷描述
|
||||||
|
label_poll_options: 选项
|
||||||
|
label_poll_subtotal: 小计
|
||||||
|
label_poll_proportion: 比例
|
||||||
|
label_poll_valid_commit: 本题有效填写人次
|
||||||
|
label_poll_result: 问卷调查_问卷统计
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue