From 221a73309fc0f49a16a70d3ed3e9beab7fd73452 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 17 Nov 2015 20:23:39 +0800 Subject: [PATCH] =?UTF-8?q?index=E9=A1=B5=E9=9D=A2=E5=88=A0=E6=8E=89?= =?UTF-8?q?=E6=97=A0=E6=95=88=E7=9A=84=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index f19e15ba1..62be77790 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -5,7 +5,7 @@ class ExerciseController < ApplicationController before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] def index - # remove_invalid_exercise(@course) + remove_invalid_exercise(@course) @is_teacher = User.current.allowed_to?(:as_teacher,@course) if @is_teacher exercises = @course.exercises @@ -231,8 +231,13 @@ class ExerciseController < ApplicationController end private - def remove_invalid_exercise - excercises = @course.exercises + def remove_invalid_exercise(course) + exercises = course.exercises.where("exercise_name=?","") + unless exercises.empty? + exercises.each do |exercise| + exercise.destroy + end + end end def find_exercise_and_course