278 lines
14 KiB
Plaintext
278 lines
14 KiB
Plaintext
<%= 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>
|
|
|
|
<% 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 %>
|
|
</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;
|
|
}
|
|
else
|
|
{
|
|
obj.checked = false;
|
|
}
|
|
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).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"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 %>
|
|
</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;
|
|
}
|
|
else
|
|
{
|
|
obj.checked = false;
|
|
}
|
|
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).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"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 %>
|
|
</div>
|
|
<div class="cl"></div>
|
|
<div>
|
|
<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) {
|
|
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>
|
|
<% end %>
|
|
</div>
|
|
<div class="testStatus" id="single_question_list" style="display: <%=single_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 %>
|
|
</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');
|
|
$.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>
|
|
<% 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-->
|
|
</div> |