老师的测试结果能显示出来

This commit is contained in:
guange 2015-09-10 11:34:10 +08:00
parent 50aa22c5e5
commit a29ab60481
2 changed files with 3 additions and 3 deletions

View File

@ -631,7 +631,7 @@ class StudentWorkController < ApplicationController
unless @homework.save unless @homework.save
logger.debug @homework.errors.full_messages logger.debug @homework.errors.full_messages
else else
student_work = @homework.student_works.where(user_id: User.current.id).first student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
end end
end end
student_work student_work

View File

@ -354,7 +354,7 @@ class UsersController < ApplicationController
@user = User.current @user = User.current
@homework = HomeworkCommon.find(params[:homework_id]) @homework = HomeworkCommon.find(params[:homework_id])
@is_test = params[:is_test] == 'true' @is_test = params[:is_test] == 'true'
@student_work = @homework.student_works.where(user_id: User.current.id).first @student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
if @student_work.nil? if @student_work.nil?
@student_work = StudentWork.new @student_work = StudentWork.new
end end
@ -369,7 +369,7 @@ class UsersController < ApplicationController
def user_commit_homework def user_commit_homework
homework = HomeworkCommon.find(params[:homework]) homework = HomeworkCommon.find(params[:homework])
student_work = homework.student_works.where(user_id: User.current.id).first student_work = StudentWork.where(homework_common_id: homework.id, user_id: User.current.id).first
if student_work if student_work
student_work.save student_work.save
flash[:notice] = l(:notice_successful_create) flash[:notice] = l(:notice_successful_create)