diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 2bc8612a4..89a5c195e 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,7 +1,7 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] include ExerciseHelper @@ -102,7 +102,17 @@ class ExerciseController < ApplicationController end def destroy - + if @exercise && @exercise.destroy + if @is_teacher + exercises = Exercise.where("course_id =?", @course.id) + else + exercises = Exercise.where("course_id =? and exercise_status =?", @course.id, 2) + end + @exercises = paginateHelper exercises,20 #分页 + respond_to do |format| + format.js + end + end end # 统计结果 diff --git a/app/views/exercise/destroy.js.erb b/app/views/exercise/destroy.js.erb new file mode 100644 index 000000000..c17b5a0f6 --- /dev/null +++ b/app/views/exercise/destroy.js.erb @@ -0,0 +1 @@ +$("#exercise").html("<%= escape_javascript(render :partial => 'exercises_list') %>"); \ No newline at end of file diff --git a/app/views/exercise/index.html.erb b/app/views/exercise/index.html.erb index 1a8d15181..bbe4dd707 100644 --- a/app/views/exercise/index.html.erb +++ b/app/views/exercise/index.html.erb @@ -1,4 +1,4 @@ <%= stylesheet_link_tag 'polls', :media => 'all' %> -