socialforge/app/controllers/homework_common_controller.rb

80 lines
1.8 KiB
Ruby
Raw Normal View History

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
@homework = HomeworkCommon.new
@homework.safe_attributes = params[:homework_common]
@homework.late_penalty = 2
@homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.publish_time = Time.now.strftime('%Y-%m-%d')
@homework_detail_manual = HomeworkDetailManual.new
@homework_detail_manual.ta_proportion = 0.6
@homework_detail_manual.absence_penalty = 2
@homework_detail_manual.evaluation_num = 3
@homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d')
@homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d')
@homework.homework_detail_manual = @homework_detail_manual
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