socialforge/app/views/poll/show.html.erb

232 lines
9.8 KiB
Plaintext
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>问卷调查_问卷页面</title>
<%= stylesheet_link_tag 'polls', :media => 'all' %>
2015-01-15 18:22:30 +08:00
<style type="text/css">
2015-01-15 18:35:27 +08:00
.alert_box{width:480px;height:180px;position:fixed;z-index:100;left:55%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.commit{
height: 28px;
display: block;
width: 80px;
color: #fff !important;
background: #15bccf;
text-align: center;
padding-top: 4px;
margin-left: 130px;
margin-top: 4px;
margin-right: 10px;
}
2015-01-15 18:22:30 +08:00
</style>
2015-01-15 17:36:30 +08:00
<script type="text/javascript">
function hidden_atert_form(cur_page,cur_type)
{
hideModal($("#popbox"));
}
</script>
</head>
<body>
<div class="polls_content polls_box" id="polls">
<div class="ur_page_head" >
<h1 class="ur_page_title">
<%= @poll.polls_name%>
</h1>
<p class="ur_prefix_content">
<%= @poll.polls_description %>
</p>
</div>
<div class="ur_card">
<ol class="ur_questions">
2015-01-14 11:50:59 +08:00
<% @poll_questions.each do |pq| %>
<% if pq.question_type == 1 %>
<!-- 单选题 -->
<li class="ur_question_item radio">
<div class="ur_title">
<span class="title_index">第<%= pq.question_number %>题:</span>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="必答">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 11:54:30 +08:00
<form>
2015-01-14 11:50:59 +08:00
<table class="ur_table" >
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label >
2015-01-15 09:41:19 +08:00
<script>
2015-01-15 10:11:52 +08:00
function click_<%= pa.id %>(obj)
2015-01-15 09:41:19 +08:00
{
$.ajax({
2015-01-15 10:11:52 +08:00
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_answer_id: <%= pa.id %>,
poll_question_id: <%= pq.id %>
},
2015-01-15 09:41:19 +08:00
success: function (data) {
2015-01-15 10:11:52 +08:00
obj.checked = true;
2015-01-15 09:41:19 +08:00
}
});
}
</script>
2015-01-15 11:54:30 +08:00
<%= radio_button "poll_vote","poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"click_#{pa.id}(this);return false;",:checked => answer_be_selected?(pa,User.current) %>
2015-01-15 09:41:19 +08:00
<%= pa.answer_text %>
2015-01-14 11:50:59 +08:00
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
2015-01-15 11:54:30 +08:00
</form>
2015-01-14 11:50:59 +08:00
</div>
</li>
<% elsif pq.question_type == 2 %>
<!-- 多选题 -->
<li class="ur_question_item checkbox">
<div class="ur_title">
<span class="title_index">第<%= pq.question_number %>题:</span>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="必答">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 11:54:30 +08:00
<form>
<table class="ur_table" >
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label >
<script>
function click_<%= pa.id %>(obj)
{
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_answer_id: <%= pa.id %>,
poll_question_id: <%= pq.id %>
},
success: function (data) {
if(data == "true")
{
obj.checked = true;
}
else
{
obj.checked = false;
}
}
});
}
</script>
<input class="ur_checkbox" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa,User.current) ? "checked":"" %>>
<%= pa.answer_text %>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</form>
2015-01-14 11:50:59 +08:00
</div>
</li>
<% elsif pq.question_type == 3 %>
<!-- 单行文字-->
<li class="ur_question_item text">
<div class="ur_title">
<span class="title_index">第<%= pq.question_number %>题:</span>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="必答">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 17:36:30 +08:00
<script>
function onblur_<%= pq.id %>(obj)
{
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %> ,
vote_text: obj.value
},
success: function (data) {
// obj.value = data;
}
});
}
</script>
<input class="ur_text ur_textbox" type="text" size="" maxlength="" value="<%= get_anwser_vote_text(pq.id,User.current.id) %>" onblur="onblur_<%= pq.id %>(this);">
2015-01-14 11:50:59 +08:00
</div>
2015-01-15 17:36:30 +08:00
</li><!--单行输入 end-->
2015-01-14 11:50:59 +08:00
<% elsif pq.question_type == 4 %>
<!-- 多行文字-->
<li class="ur_question_item textarea">
<div class="ur_preview">
<div class="ur_title">
<span class="title_index">第<%= pq.question_number %>题:</span>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="必答">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
2015-01-15 17:36:30 +08:00
<script>
function onblur_<%= pq.id %>(obj)
{
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %> ,
vote_text: obj.innerHTML
},
success: function (data) {
// obj.value = data;
}
});
}
</script>
<div contenteditable='true' class="ur_textbox" style="min-height: 150px;width: 100%" onblur="onblur_<%= pq.id %>(this);"><%= get_anwser_vote_text(pq.id,User.current.id) %></div>
2015-01-14 11:50:59 +08:00
</div>
</div>
</li><!--多行输入 end-->
<% else %>
<!-- 未知题型 -->
<% end %>
<% end %>
</ol>
2015-01-14 11:50:59 +08:00
<ul class="wlist">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
<div class="ur_buttons" style="width: 100px;">
2015-01-15 17:36:30 +08:00
<%= link_to "提交",commit_poll_poll_path(@poll), :method => :post,:class => "ur_button",:format => 'js',:remote=>true %>
</div>
<div class="cl"></div>
<div class="ur_progress_text">答题已完成 <strong class="ur_progress_number">0%</strong> </div>
</div>
</div><!--问卷内容end-->
</body>
</html>