Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course

Conflicts:
	app/controllers/exercise_controller.rb
This commit is contained in:
cxt 2015-11-17 19:52:41 +08:00
commit 2c9c87c3c6
1 changed files with 8 additions and 3 deletions

View File

@ -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,: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|
@ -229,6 +230,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