From 0ed5b9fd68b4e07e756f1481928cf4f158cceb65 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 16 Aug 2019 17:44:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E7=AD=94=E9=A2=98=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 781ede214..c9162448b 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1566,15 +1566,22 @@ class ExercisesController < ApplicationController def check_user_id_start_answer #判断用户在开始答题时,是否有用户id传入,如果为老师,则id必需,否则为当前用户的id user_login = params[:login] - # exercise_current_user_id = params[:user_id] if user_login.blank? && @user_course_identity < Course::STUDENT #id不存在,且当前为老师/管理员等 normal_status(-1,"请输入学生登陆名!") else - @ex_answerer = User.find_by(login: user_login) #回答者 + if @user_course_identity < Course::STUDENT || @exercise.score_open + @ex_answerer = user_login.blank? ? current_user : User.find_by(login: user_login) + else + @ex_answerer = current_user + end + if @ex_answerer.blank? normal_status(404,"答题用户不存在") + elsif @user_course_identity > Course::STUDENT && !@exercise.is_public + normal_status(403,"非公开试卷") else - @exercise_current_user_id = @ex_answerer.id || current_user.id + # @exercise_current_user_id = @ex_answerer.id || current_user.id + @exercise_current_user_id = @ex_answerer.id end end end