修改edit界面无法找到的问题

This commit is contained in:
huang 2015-11-17 19:47:48 +08:00
parent 3cdda2a60a
commit f316f43d6d
1 changed files with 9 additions and 4 deletions

View File

@ -1,15 +1,16 @@
class ExerciseController < ApplicationController class ExerciseController < ApplicationController
layout "base_courses" layout "base_courses"
before_filter :find_exercise_and_course, :only => [:create_exercise_question] before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit]
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list,:edit] before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
def index def index
# 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
else else
exercises = @course.exercises.where(:exercise_status => 1) exercises = @course.exercises.where(:exercise_status => 2)
end end
@exercises = paginateHelper exercises,20 #分页 @exercises = paginateHelper exercises,20 #分页
respond_to do |format| respond_to do |format|
@ -46,7 +47,7 @@ class ExerciseController < ApplicationController
:time => Time.now, :time => Time.now,
:end_time => Time.now, :end_time => Time.now,
:publish_time => Time.now, :publish_time => Time.now,
:polls_description => "" :exercise_description => ""
} }
@exercise = Exercise.create option @exercise = Exercise.create option
if @exercise if @exercise
@ -230,6 +231,10 @@ class ExerciseController < ApplicationController
end end
private private
def remove_invalid_exercise
excercises = @course.exercises
end
def find_exercise_and_course def find_exercise_and_course
@exercise = Exercise.find params[:id] @exercise = Exercise.find params[:id]
@course = Course.find @exercise.course_id @course = Course.find @exercise.course_id