|
|
|
@ -69,10 +69,11 @@ class Challenge < ApplicationRecord
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 开启挑战
|
|
|
|
|
def open_game user_id, shixun
|
|
|
|
|
game = self.games.where(user_id: user_id).first
|
|
|
|
|
if game.present?
|
|
|
|
|
shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : ""
|
|
|
|
|
def open_game
|
|
|
|
|
# 这里的identifier,status是关联了games取了games的identifier,status
|
|
|
|
|
identifier = self.identifier
|
|
|
|
|
if identifier.present?
|
|
|
|
|
shixun.task_pass || self.status != 3 ? "/tasks/#{identifier}" : ""
|
|
|
|
|
else
|
|
|
|
|
self.position == 1 ? "/api/shixuns/#{shixun.identifier}/shixun_exec" : ""
|
|
|
|
|
end
|
|
|
|
@ -92,16 +93,16 @@ class Challenge < ApplicationRecord
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
|
|
|
|
|
def user_tpi_status user_id
|
|
|
|
|
def user_tpi_status
|
|
|
|
|
# todo: 以前没加索引导致相同关卡,同一用户有多个games
|
|
|
|
|
# 允许跳关则直接开启
|
|
|
|
|
game = games.where(user_id: user_id).take
|
|
|
|
|
if game.blank?
|
|
|
|
|
position == 1 ? 1 : 0
|
|
|
|
|
identifier = self.identifier
|
|
|
|
|
if identifier.blank?
|
|
|
|
|
self.position == 1 ? 1 : 0
|
|
|
|
|
else
|
|
|
|
|
if game.status == 3
|
|
|
|
|
if status == 3
|
|
|
|
|
shixun.task_pass ? 1 : 0
|
|
|
|
|
elsif game.status == 2
|
|
|
|
|
elsif status == 2
|
|
|
|
|
2
|
|
|
|
|
else
|
|
|
|
|
1
|
|
|
|
|