问卷调查显示页面的调整

This commit is contained in:
cxt 2016-10-27 10:55:12 +08:00
parent f3d67dc26a
commit 5d7af65bac
4 changed files with 326 additions and 352 deletions

View File

@ -7,8 +7,8 @@
<%= render :partial => 'show_MCQ', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%>
<%= render :partial => 'show_single', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 4%>
<%#= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 4%>
<%= render :partial => 'show_mulit', :locals => {:poll_question => poll_question} %>
<% end%>
</div>
<div id="edit_poll_questions_<%= poll_question.id %>" style="display: none;">
@ -18,8 +18,8 @@
<%= render :partial => 'edit_MCQ', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 3%>
<%= render :partial => 'edit_single', :locals => {:poll_question => poll_question} %>
<%# elsif poll_question.question_type == 4%>
<%#= render :partial => 'edit_mulit', :locals => {:poll_question => poll_question} %>
<% elsif poll_question.question_type == 4%>
<%= render :partial => 'edit_mulit', :locals => {:poll_question => poll_question} %>
<% end%>
</div>
</div>

View File

@ -1,22 +1,38 @@
<div>
<div class="testEditTitle">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
<%if poll_question.is_necessary == 1%>
<span class="ur_required questionLabel ml5" title="必答">*</span>
<%end%>
<div class="poll-container">
<div class="pool-tool-bar">
<p class="mt10 mb10">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<%if poll_question.is_necessary == 1%>
<span class="c_red questionLabel ml5" title="必答">*</span>
<%end%>
</p>
<a class="poll-up mb8" title="上移"></a>
<a class="poll-down mb8" title="下移"></a>
<a href="javascript:void(0);" class="poll-add pr mb8">
<ul class="poll-add-menu fontGrey3">
<li><a href="javascript:void(0);" onclick=" dismiss('mulit',<%=poll_question.id%>);insert_MC('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);">单选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mulit',<%=poll_question.id%>);insert_MCQ('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);">多选题</a></li>
<li><a href="javascript:void(0);" onclick=" dismiss('mulit',<%=poll_question.id%>);insert_SINGLE('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);">主观题</a></li>
</ul>
</a>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "poll-delete", :title => "删除") %>
</div>
<div class="poll-content">
<div class="testEditTitle">
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
<span class="fontBlue">[多行主观题]</span>
</div>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<div class="cl"></div>
<% poll_question.poll_answers.reorder("answer_position").each_with_index do |poll_answer, i| %>
<div class="ml40 mb10">
<p class="mb10"><%= i + 1 %>.<%= poll_answer.answer_text%></p>
<input type="text" class="questionnaire-input" name="<%= poll_question %>" style="width:652px;" />
</div>
<% end %>
</div>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_mulit_<%=poll_question.id%>" onclick="dismiss('mulit',<%=poll_question.id%>);insert_MULIT('mulit',<%=poll_question.question_number%>,<%=poll_question.id%>);"></a>
<div class="cl"></div>
<% poll_question.poll_answers.reorder("answer_position").each_with_index do |poll_answer, i| %>
<div class="ml40 mb10">
<p class="mb10"><%= i + 1 %>.<%= poll_answer.answer_text%></p>
<input type="text" class="questionnaire-input" name="<%= poll_question %>" style="width:652px;" />
</div>
<% end %>
</div><!--多行展示 end-->
<!-- 新增问题 -->
<div id="insert_new_poll_question_mulit_<%=poll_question.id%>">

View File

@ -27,46 +27,9 @@
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:647px;">
<tbody>
<% poll_question.poll_answers.reorder("answer_position").each do |poll_answer| %>
<tr>
<td>
<% if poll_answer.answer_text != '' %>
<label>
<input class="ur_radio" type="radio" name="<%= poll_question %>" value="<%= poll_answer.answer_text%>" >
<%= poll_answer.answer_text%>
</label>
<% else %>
<label>
<input class="ur_radio" name="<%= poll_question %>" value="" type="radio">
</label>
<input placeholder="其它" readonly="readonly" class="disabled questionnaire-input w300" type="text">
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<input class="questionnaire-input" type="text" size="" maxlength="" value="" style="width:692px;">
</div>
</div>
</div><!--单选题显示 end-->
<div>
<div class="testEditTitle">
<span class="questionLabel">第<%= poll_question.question_number%>题:</span>
<span class="formatContainer m_w500"><%= poll_question.question_title %></span>
<%if poll_question.is_necessary == 1%>
<span class="ur_required questionLabel ml5" title="必答">*</span>
<%end%>
</div>
<%= link_to("", delete_poll_question_poll_index_path(:poll_question => poll_question.id),
method: :delete, :confirm => l(:text_are_you_sure), :remote => true, :class => "ur_icon_de") %>
<a class="ur_icon_edit" title="编辑" onclick="pollQuestionEdit(<%= poll_question.id%>);"></a>
<a class='ur_icon_add' title='向下插入' id="add_single_<%=poll_question.id%>" onclick="dismiss('single',<%=poll_question.id%>);insert_SINGLE('single',<%=poll_question.question_number%>,<%=poll_question.id%>);"></a>
<div class="cl"></div>
<div class="ur_inputs">
<input class="questionnaire-input" type="text" size="" maxlength="" value="" style="width:692px;">
</div>
</div><!--单行文字展示 end-->
<!-- 新增问题 -->
<div id="insert_new_poll_question_single_<%=poll_question.id%>">

View File

@ -1,307 +1,302 @@
<%= stylesheet_link_tag 'polls', :media => 'all' %>
<%= stylesheet_link_tag 'polls', :media => 'all' %>
<div class="homepageRight mt0 ml10">
<div class="resources" id="polls">
<div class="testStatus" >
<h1 class="ur_page_title">
<%= @poll.polls_name%>
</h1>
<div class="testDesEdit mt5"><%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%></div>
</div>
<div class="testStatus">
<h1 class="ur_page_title">
<%= @poll.polls_name %>
</h1>
<% mc_question_list = @poll.poll_questions.where("question_type=1") %>
<% mcq_question_list = @poll.poll_questions.where("question_type=2") %>
<% single_question_list = @poll.poll_questions.where("question_type=3") %>
<% multi_question_list = @poll.poll_questions.where("question_type=4") %>
<div class="testStatus" id="mc_question_list" style="display: <%=mc_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单选题</h3>
<% mc_question_list.each_with_index do |pq, list_index| %>
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label>
<script>
function onblur_<%= pa.id %>(obj)
{
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %>,
poll_answer_id: <%= pa.id %>,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
//document.getElementById("poll_vote_<%#=pq.id %>poll_answer_id_<%#=pa.id %>").checked = true;
//var span = $('#percent');
//span.html(dataObj.percent);
}
});
}
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) {
var dataObj = eval(data);
if(dataObj.text == "ok")
{
obj.checked = true;
$(obj).parent().parent().parent().parent().find("input[type='text']").attr("disabled", "disabled");
$(obj).next('input').removeAttr("disabled");
}
else
{
obj.checked = false;
$(obj).next('input').attr("disabled", "disabled");
}
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
</script>
<%= radio_button "poll_vote",pq.id.to_s+"poll_answer_id",pa.id,:class=>"ur_radio",:onclick =>"click_#{pa.id}(this);return false;",:checked => answer_be_selected?(pa,User.current),:disabled => !@can_edit_poll %>
<% if pa.answer_text == "" %>
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= (@can_edit_poll && answer_be_selected?(pa,User.current))?"":"disabled=disabled" %> placeholder="其他">
<% else %>
<%= pa.answer_text %>
<% end %>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="testStatus" id="mcq_question_list" style="display: <%=mcq_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">多选题</h3>
<% mcq_question_list.each do |pq| %>
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label>
<script>
function onblur_<%= pa.id %>(obj)
{
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %>,
poll_answer_id: <%= pa.id %>,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
//document.getElementById("poll_vote_<%#=pq.id %>poll_answer_id_<%#=pa.id %>").checked = true;
//var span = $('#percent');
//span.html(dataObj.percent);
}
});
}
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) {
var dataObj = eval(data);
if(dataObj.text == "ok")
{
obj.checked = true;
$(obj).next('input').removeAttr("disabled");
}
else
{
obj.checked = false;
$(obj).next('input').attr("disabled", "disabled");
}
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
</script>
<input class="ur_radio" id="poll_vote_<%=pq.id %>poll_answer_id_<%=pa.id %>" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa,User.current) ? "checked":"" %> <%= @can_edit_poll?"":"disabled=disabled" %> >
<% if pa.answer_text == "" %>
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= (@can_edit_poll && answer_be_selected?(pa,User.current))?"":"disabled=disabled" %> placeholder="其他">
<% else %>
<%= pa.answer_text %>
<% end %>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div><!--多选题显示 end-->
</div>
</div>
<% end %>
</div>
<div class="testStatus" id="single_question_list" style="display: <%=single_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">单行主观题</h3>
<% single_question_list.each do |pq| %>
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="testDesEdit mt5"><%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe %></div>
</div>
<% @poll_questions.each do |pq| %>
<% if pq.question_type == 1 %>
<!-- 单选题 -->
<div class="testStatus">
<div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<script>
function onblur_<%= pq.id %>(obj)
{
$(window).unbind('beforeunload');
var val = $(obj).val().trim();
if(val != "") {
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %> ,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
}
</script>
<input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(pq.id,User.current.id).html_safe %>" onblur="onblur_<%= pq.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>
<div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %>
<span class="fontBlue">[单选题]</span>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label>
<script>
function onblur_<%= pa.id %>(obj) {
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %>,
poll_answer_id: <%= pa.id %>,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
//document.getElementById("poll_vote_<%#=pq.id %>poll_answer_id_<%#=pa.id %>").checked = true;
//var span = $('#percent');
//span.html(dataObj.percent);
}
});
}
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) {
var dataObj = eval(data);
if (dataObj.text == "ok") {
obj.checked = true;
$(obj).parent().parent().parent().parent().find("input[type='text']").attr("disabled", "disabled");
$(obj).next('input').removeAttr("disabled");
}
else {
obj.checked = false;
$(obj).next('input').attr("disabled", "disabled");
}
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
</script>
<%= radio_button "poll_vote", pq.id.to_s+"poll_answer_id", pa.id, :class => "ur_radio", :onclick => "click_#{pa.id}(this);return false;", :checked => answer_be_selected?(pa, User.current), :disabled => !@can_edit_poll %>
<% if pa.answer_text == "" %>
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id, User.current.id, pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= (@can_edit_poll && answer_be_selected?(pa, User.current)) ? "" : "disabled=disabled" %> placeholder="其他">
<% else %>
<%= pa.answer_text %>
<% end %>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<% end %>
</div>
<div class="testStatus" id="multi_question_list" style="display: <%=multi_question_list.count > 0 ? "" : "none" %>">
<h3 class="fontGrey3">多行主观题</h3>
<% multi_question_list.each do |pq| %>
<div id="poll_questions_<%= pq.id%>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<div class="testEditTitle">
<%= l(:label_question_number,:question_number => pq.question_number) %>
<%= pq.question_title %>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% elsif pq.question_type == 2 %>
<!-- 多选题 -->
<div class="testStatus">
<div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %>
<span class="fontBlue">[多选题]</span>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
<table class="ur_table" style="width:675px;">
<tbody>
<% pq.poll_answers.each do |pa| %>
<tr>
<td>
<label>
<script>
function onblur_<%= pa.id %>(obj) {
$(window).unbind('beforeunload');
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %>,
poll_answer_id: <%= pa.id %>,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
//document.getElementById("poll_vote_<%#=pq.id %>poll_answer_id_<%#=pa.id %>").checked = true;
//var span = $('#percent');
//span.html(dataObj.percent);
}
});
}
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) {
var dataObj = eval(data);
if (dataObj.text == "ok") {
obj.checked = true;
$(obj).next('input').removeAttr("disabled");
}
else {
obj.checked = false;
$(obj).next('input').attr("disabled", "disabled");
}
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
</script>
<input class="ur_radio" id="poll_vote_<%= pq.id %>poll_answer_id_<%= pa.id %>" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa, User.current) ? "checked" : "" %> <%= @can_edit_poll ? "" : "disabled=disabled" %> >
<% if pa.answer_text == "" %>
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 93%" value="<%= get_anwser_vote_text(pq.id, User.current.id, pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= (@can_edit_poll && answer_be_selected?(pa, User.current)) ? "" : "disabled=disabled" %> placeholder="其他">
<% else %>
<%= pa.answer_text %>
<% end %>
</label>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<!--多选题显示 end-->
</div>
</div>
</div>
<% elsif pq.question_type == 3 %>
<!-- 单行文字-->
<div class="testStatus">
<div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %>
<span class="fontBlue">[主观题]</span>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div>
<div class="cl"></div>
<div>
<script>
function onblur_<%= pq.id %>(obj) {
$(window).unbind('beforeunload');
var val = $(obj).val().trim();
if (val != "") {
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %>,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
}
</script>
<input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(pq.id, User.current.id).html_safe %>" onblur="onblur_<%= pq.id %>(this);" <%= @can_edit_poll ? "" : "disabled=disabled" %>>
</div>
</div>
</div>
</div>
</div>
<% elsif pq.question_type == 4 %>
<!-- 多行文字-->
<div class="testStatus">
<div id="poll_questions_<%= pq.id %>">
<div id="show_poll_questions_<%= pq.id %>">
<div>
<div class="testEditTitle">
<%= l(:label_question_number, :question_number => pq.question_number) %>
<%= pq.question_title %>
<span class="fontBlue">[多行主观题]</span>
<% if pq.is_necessary == 1 %>
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
<% end %>
</div>
<div class="cl"></div>
<% pq.poll_answers.each_with_index do |pa, i| %>
<div class="ml20 mb10">
<script>
function onblur_<%= pa.id %>(obj) {
$(window).unbind('beforeunload');
var val = $(obj).val().trim();
if (val != "") {
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %>,
poll_answer_id: <%= pa.id %>,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
}
</script>
<p class="mb10"><%= i + 1 %>.<%= pa.answer_text %></p>
<input class="questionnaire-input" placeholder="在此填入答案" style="width: 99%" type="text" value="<%= get_anwser_vote_text(pq.id, User.current.id, pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll ? "" : "disabled=disabled" %>>
</div>
<% end %>
</div>
<div class="cl"></div>
<% pq.poll_answers.each_with_index do |pa, i| %>
<div class="ml40 mb10">
<script>
function onblur_<%= pa.id %>(obj)
{
$(window).unbind('beforeunload');
var val = $(obj).val().trim();
if(val != "") {
$.ajax({
type: "post",
url: "<%= commit_answer_poll_path(@poll) %>",
data: {
poll_question_id: <%= pq.id %>,
poll_answer_id: <%= pa.id %>,
vote_text: obj.value
},
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
var span = $('#percent');
span.html(dataObj.percent);
},
error: function () {
alert("网络异常,答题失败,请确认网络正常连接后再答题。");
}
});
}
}
</script>
<p class="mb10"><%= i + 1 %>.<%= pa.answer_text%></p>
<input class="questionnaire-input" placeholder="在此填入答案" style="width: 93%" type="text" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>
</div>
<% end %>
</div>
</div>
</div>
<% else %>
<!-- 未知题型 -->
<% end %>
</div>
<div class="ur_buttons" style="width: 77px;">
<% if @poll.polls_status == 2 %>
<%= link_to l(:button_submit),commit_poll_poll_path(@poll), :method => :post,:class => "BlueCirBtn",:format => 'js',:remote=>true %>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_progress_text">
<%= l(:label_complete_question) %>
<strong class="ur_progress_number">
<span id="percent"><%= format "%.2f" ,@percent %></span>%
</strong>
</div>
</div><!--问卷内容end-->
<% end %>
<div class="ur_buttons" style="width: 77px;">
<% if @poll.polls_status == 2 %>
<%= link_to l(:button_submit), commit_poll_poll_path(@poll), :method => :post, :class => "BlueCirBtn", :format => 'js', :remote => true %>
<% end %>
</div>
<div class="cl"></div>
<div class="ur_progress_text">
<%= l(:label_complete_question) %>
<strong class="ur_progress_number">
<span id="percent"><%= format "%.2f", @percent %></span>%
</strong>
</div>
</div>
<!--问卷内容end-->
</div>