From 39455f9f8abc13ba3a4a9f2f1885606dd3e0fc7a Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 23 Nov 2015 17:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E9=87=8D=E5=A4=8D=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 9ad46cd69..87d13e169 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -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]