多重身份的成员:教师模拟答题和学生答题作为两条记录

This commit is contained in:
cxt 2016-09-01 14:21:19 +08:00
parent 5676f0b82f
commit e61cf5dd4f
2 changed files with 3 additions and 3 deletions

View File

@ -1402,7 +1402,7 @@ class StudentWorkController < ApplicationController
end
def find_or_save_student_work(is_test)
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id, is_test: is_test).first
if student_work.nil?
@homework.student_works.build(
name: params[:title],
@ -1413,7 +1413,7 @@ class StudentWorkController < ApplicationController
unless @homework.save
logger.debug @homework.errors.full_messages
else
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id, is_test: is_test).first
end
end
student_work

View File

@ -983,7 +983,7 @@ class UsersController < ApplicationController
@user = User.current
@homework = HomeworkCommon.find(params[:homework_id])
@is_test = params[:is_test] == 'true'
@student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id).first
@student_work = StudentWork.where(homework_common_id: @homework.id, user_id: User.current.id, is_test: @is_test).first
if @student_work.nil?
@student_work = StudentWork.new
end