多重身份的成员:教师模拟答题和学生答题作为两条记录
This commit is contained in:
parent
5676f0b82f
commit
e61cf5dd4f
|
@ -1402,7 +1402,7 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_or_save_student_work(is_test)
|
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?
|
if student_work.nil?
|
||||||
@homework.student_works.build(
|
@homework.student_works.build(
|
||||||
name: params[:title],
|
name: params[:title],
|
||||||
|
@ -1413,7 +1413,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 = 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
|
||||||
end
|
end
|
||||||
student_work
|
student_work
|
||||||
|
|
|
@ -983,7 +983,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 = 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?
|
if @student_work.nil?
|
||||||
@student_work = StudentWork.new
|
@student_work = StudentWork.new
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue