From c366cc90e7c4453dcc35b73f27852d74f3bba806 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 29 Jan 2015 17:33:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E5=90=8E=E7=9B=B8=E5=85=B3BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 6 ++++++ app/views/poll/_poll_list.html.erb | 22 ++++++++++++++++++++++ app/views/poll/destroy.js.erb | 5 +---- app/views/poll/index.html.erb | 24 +----------------------- 4 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 app/views/poll/_poll_list.html.erb diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 394c52f13..1b2794034 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -83,6 +83,12 @@ class PollController < ApplicationController def destroy if @poll && @poll.destroy + if @is_teacher + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}") + else + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2") + end + @polls = paginateHelper polls,20 #分页 respond_to do |format| format.js end diff --git a/app/views/poll/_poll_list.html.erb b/app/views/poll/_poll_list.html.erb new file mode 100644 index 000000000..f57a4a5ff --- /dev/null +++ b/app/views/poll/_poll_list.html.erb @@ -0,0 +1,22 @@ +
+

所有问卷 + (<%= @obj_count%>) +

+ <% if @is_teacher%> + <%= link_to l(:label_new_poll), new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => "newbtn" %> + <% end%> +
+
+
+ <% @polls.each do |poll|%> + +
+ <% end%> + + +
+
\ No newline at end of file diff --git a/app/views/poll/destroy.js.erb b/app/views/poll/destroy.js.erb index cf94b5661..8bb67f20a 100644 --- a/app/views/poll/destroy.js.erb +++ b/app/views/poll/destroy.js.erb @@ -1,4 +1 @@ -<% if @poll%> - $("#polls_<%= @poll.id%>").remove(); -<%else%> -<% end %> \ No newline at end of file +$("#polls").html("<%= escape_javascript(render :partial => 'poll_list') %>"); \ No newline at end of file diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb index 3db4d7caa..0b780aa9e 100644 --- a/app/views/poll/index.html.erb +++ b/app/views/poll/index.html.erb @@ -82,27 +82,5 @@ }
-
-

所有问卷 - (<%= @obj_count%>) -

- <% if @is_teacher%> - <%= link_to l(:label_new_poll), new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => "newbtn" %> - <% end%> -
-
-
- <% @polls.each do |poll|%> - -
- <% end%> - - -
-
- + <%= render :partial => 'poll_list'%>
\ No newline at end of file