index页面删掉无效的测试
This commit is contained in:
parent
d61ec92318
commit
221a73309f
|
@ -5,7 +5,7 @@ class ExerciseController < ApplicationController
|
||||||
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
|
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# remove_invalid_exercise(@course)
|
remove_invalid_exercise(@course)
|
||||||
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
@is_teacher = User.current.allowed_to?(:as_teacher,@course)
|
||||||
if @is_teacher
|
if @is_teacher
|
||||||
exercises = @course.exercises
|
exercises = @course.exercises
|
||||||
|
@ -231,8 +231,13 @@ class ExerciseController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def remove_invalid_exercise
|
def remove_invalid_exercise(course)
|
||||||
excercises = @course.exercises
|
exercises = course.exercises.where("exercise_name=?","")
|
||||||
|
unless exercises.empty?
|
||||||
|
exercises.each do |exercise|
|
||||||
|
exercise.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_exercise_and_course
|
def find_exercise_and_course
|
||||||
|
|
Loading…
Reference in New Issue