69 lines
1.1 KiB
Ruby
69 lines
1.1 KiB
Ruby
class HomeworkCommonController < ApplicationController
|
|
layout "base_courses"
|
|
before_filter :find_course, :only => [:index,:new]
|
|
|
|
def index
|
|
homeworks = @course.homework_commons
|
|
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
|
|
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
|
@homeworks = paginateHelper homeworks,10
|
|
respond_to do |format|
|
|
format.html
|
|
end
|
|
end
|
|
|
|
def new
|
|
|
|
respond_to do |format|
|
|
format.html
|
|
end
|
|
end
|
|
|
|
def create
|
|
|
|
end
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
def update
|
|
|
|
end
|
|
|
|
def destroy
|
|
|
|
end
|
|
|
|
#开启匿评
|
|
def start_anonymous_comment
|
|
|
|
end
|
|
|
|
#关闭匿评
|
|
def stop_anonymous_comment
|
|
|
|
end
|
|
|
|
#提示
|
|
def alert_anonymous_comment
|
|
respond_to do |format|
|
|
format.js
|
|
end
|
|
end
|
|
|
|
private
|
|
#获取课程
|
|
def find_course
|
|
@course = Course.find params[:course]
|
|
rescue
|
|
render_404
|
|
end
|
|
#获取作业
|
|
def find_homework
|
|
@homework = HomeworkCommon.find params[:id]
|
|
@course = @homework.course
|
|
rescue
|
|
render_404
|
|
end
|
|
end |