|
|
@ -89,34 +89,16 @@ class Challenge < ApplicationRecord
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
|
|
|
|
## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
|
|
|
|
def user_tpi_status shixun, user_id
|
|
|
|
# def user_tpi_status shixun, user_id
|
|
|
|
# todo: 以前没加索引导致相同关卡,同一用户有多个games
|
|
|
|
|
|
|
|
# 允许跳关则直接开启
|
|
|
|
|
|
|
|
game = games.where(user_id: user_id).take
|
|
|
|
|
|
|
|
if game.blank?
|
|
|
|
|
|
|
|
position == 1 ? 1 : 0
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if game.status == 3
|
|
|
|
|
|
|
|
shixun.task_pass ? 1 : 0
|
|
|
|
|
|
|
|
elsif game.status == 2
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
|
|
|
|
|
|
|
|
# def user_tpi_status shixun
|
|
|
|
|
|
|
|
# # todo: 以前没加索引导致相同关卡,同一用户有多个games
|
|
|
|
# # todo: 以前没加索引导致相同关卡,同一用户有多个games
|
|
|
|
# # 允许跳关则直接开启
|
|
|
|
# # 允许跳关则直接开启
|
|
|
|
# identifier = self.identifier
|
|
|
|
# game = games.where(user_id: user_id).take
|
|
|
|
# if identifier.blank?
|
|
|
|
# if game.blank?
|
|
|
|
# self.position == 1 ? 1 : 0
|
|
|
|
# position == 1 ? 1 : 0
|
|
|
|
# else
|
|
|
|
# else
|
|
|
|
# if status == 3
|
|
|
|
# if game.status == 3
|
|
|
|
# shixun.task_pass ? 1 : 0
|
|
|
|
# shixun.task_pass ? 1 : 0
|
|
|
|
# elsif status == 2
|
|
|
|
# elsif game.status == 2
|
|
|
|
# 2
|
|
|
|
# 2
|
|
|
|
# else
|
|
|
|
# else
|
|
|
|
# 1
|
|
|
|
# 1
|
|
|
@ -124,6 +106,24 @@ class Challenge < ApplicationRecord
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
|
|
|
|
|
|
|
|
def user_tpi_status shixun
|
|
|
|
|
|
|
|
# todo: 以前没加索引导致相同关卡,同一用户有多个games
|
|
|
|
|
|
|
|
# 允许跳关则直接开启
|
|
|
|
|
|
|
|
identifier = self.identifier
|
|
|
|
|
|
|
|
if identifier.blank?
|
|
|
|
|
|
|
|
self.position == 1 ? 1 : 0
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if status == 3
|
|
|
|
|
|
|
|
shixun.task_pass ? 1 : 0
|
|
|
|
|
|
|
|
elsif status == 2
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
1
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def tags_show
|
|
|
|
def tags_show
|
|
|
|
if self.challenge_tags.nil?
|
|
|
|
if self.challenge_tags.nil?
|
|
|
|
"--"
|
|
|
|
"--"
|
|
|
|