From 6932dc7127a7c946e1e0e044b4247bd2adce1d13 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Jul 2019 10:12:31 +0800 Subject: [PATCH] =?UTF-8?q?=20=E5=85=81=E8=AE=B8=E8=B7=B3=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 9 +++++++-- app/models/challenge.rb | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) 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