作业重复提交问题
This commit is contained in:
parent
fd03e62957
commit
39455f9f8a
|
@ -167,6 +167,12 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
# 提交作品前先判断是否已经提交
|
||||
if hsd_committed_work?(User.current.id, @homework.id)
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
redirect_to edit_student_work_url(params[:student_work])
|
||||
return
|
||||
end
|
||||
if params[:student_work]
|
||||
@submit_result = true
|
||||
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
|
||||
|
@ -499,6 +505,12 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
def hsd_committed_work?(user, homework)
|
||||
sw = StudentWork.where("user_id =? and homework_common_id =?", user, homework).first
|
||||
sw.nil? ? result = false : result = true
|
||||
result
|
||||
end
|
||||
|
||||
#获取作业
|
||||
def find_homework
|
||||
@homework = HomeworkCommon.find params[:homework]
|
||||
|
|
Loading…
Reference in New Issue