diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 1c6476a34..0a7a4fece 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -524,8 +524,13 @@ class ShixunsController < ApplicationController # 如果存在实训,则直接进入实训 # 如果实训允许跳关,传参params[:challenge_id]跳入具体的关卡 @current_task = - if params[:challenge_id] && @shixun.task_pass - games.where(challenge_id: params[:challenge_id]).take + if params[:challenge_id] + game = games.where(challenge_id: params[:challenge_id]).take + if game.status == 3 && !@shixun.task_pass + tip_show_exception(-4, "关卡还未开启") + else + game + end else current_myshixun.current_task(games) end diff --git a/app/models/challenge.rb b/app/models/challenge.rb index e7a382a51..ac031c31c 100644 --- a/app/models/challenge.rb +++ b/app/models/challenge.rb @@ -76,8 +76,9 @@ class Challenge < ApplicationRecord ## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成 def user_tpi_status user_id # todo: 以前没加索引导致相同关卡,同一用户有多个games - game = games.last - + # 允许跳关则直接开启 + return 1 if shixun.task_pass + game = games.where(user_id: user_id).take if game.blank? self.position == 1 ? 1 : 0 elsif game.status == 2