diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 8fa5e0230..f19e15ba1 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -1,15 +1,16 @@ class ExerciseController < ApplicationController layout "base_courses" - before_filter :find_exercise_and_course, :only => [:create_exercise_question] - before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list,:edit] + before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit] + before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list] def index + # remove_invalid_exercise(@course) @is_teacher = User.current.allowed_to?(:as_teacher,@course) if @is_teacher exercises = @course.exercises else - exercises = @course.exercises.where(:exercise_status => 1) + exercises = @course.exercises.where(:exercise_status => 2) end @exercises = paginateHelper exercises,20 #分页 respond_to do |format| @@ -46,7 +47,7 @@ class ExerciseController < ApplicationController :time => Time.now, :end_time => Time.now, :publish_time => Time.now, - :polls_description => "" + :exercise_description => "" } @exercise = Exercise.create option if @exercise @@ -230,6 +231,10 @@ class ExerciseController < ApplicationController end private + def remove_invalid_exercise + excercises = @course.exercises + end + def find_exercise_and_course @exercise = Exercise.find params[:id] @course = Course.find @exercise.course_id