2015-03-24 16:26:54 +08:00
|
|
|
<%= stylesheet_link_tag 'polls', :media => 'all' %>
|
2016-07-22 15:32:37 +08:00
|
|
|
<div class="courseRSide fl">
|
2015-01-13 15:59:02 +08:00
|
|
|
<div class="polls_content polls_box" id="polls">
|
|
|
|
<div class="ur_page_head" >
|
|
|
|
<h1 class="ur_page_title">
|
|
|
|
<%= @poll.polls_name%>
|
|
|
|
</h1>
|
2015-03-27 16:11:56 +08:00
|
|
|
<%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%>
|
2015-01-13 15:59:02 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="ur_card">
|
|
|
|
<ol class="ur_questions">
|
2015-01-14 11:50:59 +08:00
|
|
|
<% @poll_questions.each do |pq| %>
|
2015-03-24 16:26:54 +08:00
|
|
|
<% if pq.question_type == 1 %>
|
|
|
|
<!-- 单选题 -->
|
2015-01-14 11:50:59 +08:00
|
|
|
<li class="ur_question_item radio">
|
|
|
|
<div class="ur_title">
|
2015-01-16 16:13:03 +08:00
|
|
|
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<%= pq.question_title %>
|
2015-01-17 14:18:45 +08:00
|
|
|
<span class="title_index">[单选题]</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% if pq.is_necessary == 1 %>
|
2015-03-24 16:26:54 +08:00
|
|
|
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
<div class="ur_inputs">
|
2015-01-15 11:54:30 +08:00
|
|
|
<form>
|
2015-03-24 16:26:54 +08:00
|
|
|
<table class="ur_table" >
|
|
|
|
<tbody>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% pq.poll_answers.each do |pa| %>
|
2015-03-24 16:26:54 +08:00
|
|
|
<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) {
|
|
|
|
var dataObj = eval(data);
|
|
|
|
obj.checked = true;
|
|
|
|
var span = $('#percent');
|
|
|
|
span.html(dataObj.percent);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<%= 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),:disabled => !@can_edit_poll %>
|
|
|
|
<%= pa.answer_text %>
|
|
|
|
</label>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% end %>
|
2015-03-24 16:26:54 +08:00
|
|
|
</tbody>
|
|
|
|
</table>
|
2015-01-15 11:54:30 +08:00
|
|
|
</form>
|
2015-01-14 11:50:59 +08:00
|
|
|
</div>
|
|
|
|
</li>
|
2015-03-24 16:26:54 +08:00
|
|
|
<% elsif pq.question_type == 2 %>
|
|
|
|
<!-- 多选题 -->
|
2015-01-14 11:50:59 +08:00
|
|
|
<li class="ur_question_item checkbox">
|
|
|
|
<div class="ur_title">
|
2015-01-16 16:13:03 +08:00
|
|
|
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<%= pq.question_title %>
|
2015-01-17 14:18:45 +08:00
|
|
|
<span class="title_index">[多选题]</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% if pq.is_necessary == 1 %>
|
2015-01-16 16:13:03 +08:00
|
|
|
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% end %>
|
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
|
|
|
<div class="ur_inputs">
|
2015-01-15 11:54:30 +08:00
|
|
|
<form>
|
|
|
|
<table class="ur_table" >
|
|
|
|
<tbody>
|
2015-03-24 16:26:54 +08:00
|
|
|
<% pq.poll_answers.each do |pa| %>
|
2015-01-15 11:54:30 +08:00
|
|
|
<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) {
|
2015-01-16 15:32:09 +08:00
|
|
|
var dataObj = eval(data);
|
|
|
|
if(dataObj.text == "true")
|
2015-01-15 11:54:30 +08:00
|
|
|
{
|
|
|
|
obj.checked = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
obj.checked = false;
|
|
|
|
}
|
2015-01-16 15:32:09 +08:00
|
|
|
var span = $('#percent');
|
|
|
|
span.html(dataObj.percent);
|
2015-01-15 11:54:30 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2015-01-16 10:19:38 +08:00
|
|
|
<input class="ur_checkbox" type="checkbox" onclick="click_<%= pa.id %>(this);return false;" <%= answer_be_selected?(pa,User.current) ? "checked":"" %> <%= @can_edit_poll?"":"disabled=disabled" %> >
|
2015-01-15 11:54:30 +08:00
|
|
|
<%= pa.answer_text %>
|
|
|
|
</label>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2015-03-24 16:26:54 +08:00
|
|
|
<% end %>
|
2015-01-15 11:54:30 +08:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</form>
|
2015-01-14 11:50:59 +08:00
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
<% elsif pq.question_type == 3 %>
|
2015-03-24 16:26:54 +08:00
|
|
|
<!-- 单行文字-->
|
2015-01-14 11:50:59 +08:00
|
|
|
<li class="ur_question_item text">
|
|
|
|
<div class="ur_title">
|
2015-01-16 16:13:03 +08:00
|
|
|
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<%= pq.question_title %>
|
2015-01-17 14:18:45 +08:00
|
|
|
<span class="title_index">[单行主观]</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% if pq.is_necessary == 1 %>
|
2015-01-16 16:13:03 +08:00
|
|
|
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% 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) {
|
2015-01-16 15:32:09 +08:00
|
|
|
var dataObj = eval(data);
|
|
|
|
var span = $('#percent');
|
|
|
|
span.html(dataObj.percent);
|
2015-01-15 17:36:30 +08:00
|
|
|
// obj.value = data;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
2015-01-17 11:51:59 +08:00
|
|
|
<input class="ur_text ur_textbox" type="text" size="" maxlength="" style="width: 100%" value="<%= get_anwser_vote_text(pq.id,User.current.id).html_safe %>" onblur="onblur_<%= pq.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>
|
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 %>
|
2015-03-24 16:26:54 +08:00
|
|
|
<!-- 多行文字-->
|
2015-01-14 11:50:59 +08:00
|
|
|
<li class="ur_question_item textarea">
|
|
|
|
<div class="ur_preview">
|
|
|
|
<div class="ur_title">
|
2015-01-16 16:13:03 +08:00
|
|
|
<span class="title_index"><%= l(:label_question_number,:question_number => pq.question_number) %></span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<%= pq.question_title %>
|
2015-01-17 14:18:45 +08:00
|
|
|
<span class="title_index">[多行主观]</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% if pq.is_necessary == 1 %>
|
2015-01-16 16:13:03 +08:00
|
|
|
<span class="ur_required" title="<%= l(:label_must_answer) %>">*</span>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% 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) {
|
2015-01-16 15:32:09 +08:00
|
|
|
var dataObj = eval(data);
|
|
|
|
if(dataObj.text != 'failure')
|
|
|
|
{
|
2015-03-24 16:26:54 +08:00
|
|
|
var span = $('#percent');
|
|
|
|
span.html(dataObj.percent);
|
2015-01-16 15:32:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
alert("error");
|
|
|
|
}
|
|
|
|
|
2015-01-15 17:36:30 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2015-01-17 11:02:09 +08:00
|
|
|
<div contenteditable='<%= @can_edit_poll %>' class="ur_textbox" style="min-height: 150px;width: 100%;<%= @can_edit_poll?"":"background-color:#DCDCDC;" %>" onblur="onblur_<%= pq.id %>(this);"><%= get_anwser_vote_text(pq.id,User.current.id).html_safe %></div>
|
2015-01-14 11:50:59 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li><!--多行输入 end-->
|
|
|
|
<% else %>
|
2015-03-24 16:26:54 +08:00
|
|
|
<!-- 未知题型 -->
|
|
|
|
<% end %>
|
2015-01-14 11:50:59 +08:00
|
|
|
<% end %>
|
2015-01-13 15:59:02 +08:00
|
|
|
</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-16 10:59:25 +08:00
|
|
|
<% if @poll.polls_status == 2 %>
|
2015-03-24 16:26:54 +08:00
|
|
|
<%= link_to l(:button_submit),commit_poll_poll_path(@poll), :method => :post,:class => "ur_button",:format => 'js',:remote=>true %>
|
2015-01-16 10:59:25 +08:00
|
|
|
<% end %>
|
2015-01-13 15:59:02 +08:00
|
|
|
</div>
|
|
|
|
<div class="cl"></div>
|
2015-03-24 16:26:54 +08:00
|
|
|
<div class="ur_progress_text">
|
|
|
|
<%= l(:label_complete_question) %>
|
|
|
|
<strong class="ur_progress_number">
|
|
|
|
<span id="percent"><%= format "%.2f" ,@percent %></span>%
|
|
|
|
</strong>
|
|
|
|
</div>
|
2015-01-13 15:59:02 +08:00
|
|
|
</div>
|
|
|
|
</div><!--问卷内容end-->
|
2016-07-22 15:32:37 +08:00
|
|
|
</div>
|