index页面删掉无效的测试

This commit is contained in:
huang 2015-11-17 20:23:39 +08:00
parent d61ec92318
commit 221a73309f
1 changed files with 8 additions and 3 deletions

View File

@ -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