编辑作业功能完成

This commit is contained in:
sw 2015-05-20 17:01:08 +08:00
parent 40f6295609
commit 25672aa229
2 changed files with 35 additions and 1 deletions

View File

@ -1,7 +1,7 @@
class HomeworkCommonController < ApplicationController
layout "base_courses"
before_filter :find_course, :only => [:index,:new,:create]
before_filter :find_homework, :only => [:edit]
before_filter :find_homework, :only => [:edit,:update]
def index
homeworks = @course.homework_commons
@ -81,7 +81,38 @@ class HomeworkCommonController < ApplicationController
end
def update
@homework.name = params[:homework_common][:name]
@homework.description = params[:homework_common][:description]
@homework.end_time = params[:homework_common][:end_time]
@homework.publish_time = params[:homework_common][:publish_time]
@homework.homework_type = params[:homework_common][:homework_type]
@homework.late_penalty = params[:late_penalty]
@homework.user_id = User.current.id
@homework.course_id = @course.id
#匿评作业相关属性
@homework_detail_manual.ta_proportion = params[:ta_proportion] || 0.6
@homework_detail_manual.evaluation_start = params[:evaluation_start]
@homework_detail_manual.evaluation_end = params[:evaluation_end]
@homework_detail_manual.evaluation_num = params[:evaluation_num]
@homework_detail_manual.absence_penalty = params[:absence_penalty]
if @homework.save && @homework_detail_manual.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_edit)
redirect_to homework_common_index_path(:course => @course.id)
}
end
return
else
respond_to do |format|
format.html {
flash[:notice] = l(:notice_failed_edit)
redirect_to edit_homework_common_path(@homework)
}
end
end
end
def destroy
@ -115,6 +146,7 @@ class HomeworkCommonController < ApplicationController
#获取作业
def find_homework
@homework = HomeworkCommon.find params[:id]
@homework_detail_manual = @homework.homework_detail_manual
@course = @homework.course
rescue
render_404

View File

@ -14,6 +14,8 @@ zh:
notice_successful_create: 创建成功
notice_failed_create: 创建失败
notice_successful_update: 更新成功
notice_successful_edit: 修改成功
notice_failed_edit: 修改失败
notice_successful_delete: 删除成功
notice_failed_delete: 删除失败
notice_successful_connection: 连接成功