|
|
|
@ -69,15 +69,16 @@ class Challenge < ApplicationRecord
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 开启挑战
|
|
|
|
|
def open_game shixun
|
|
|
|
|
# 这里的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
|
|
|
|
|
end
|
|
|
|
|
# def open_game shixun
|
|
|
|
|
# # 这里的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
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # 开启挑战
|
|
|
|
|
# def open_game(user_id, shixun)
|
|
|
|
@ -93,16 +94,16 @@ class Challenge < ApplicationRecord
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
|
|
|
|
|
def user_tpi_status shixun
|
|
|
|
|
def user_tpi_status shixun, user_id
|
|
|
|
|
# todo: 以前没加索引导致相同关卡,同一用户有多个games
|
|
|
|
|
# 允许跳关则直接开启
|
|
|
|
|
identifier = self.identifier
|
|
|
|
|
if identifier.blank?
|
|
|
|
|
self.position == 1 ? 1 : 0
|
|
|
|
|
game = games.where(user_id: user_id).take
|
|
|
|
|
if game.blank?
|
|
|
|
|
position == 1 ? 1 : 0
|
|
|
|
|
else
|
|
|
|
|
if status == 3
|
|
|
|
|
if game.status == 3
|
|
|
|
|
shixun.task_pass ? 1 : 0
|
|
|
|
|
elsif status == 2
|
|
|
|
|
elsif game.status == 2
|
|
|
|
|
2
|
|
|
|
|
else
|
|
|
|
|
1
|
|
|
|
@ -110,6 +111,24 @@ class Challenge < ApplicationRecord
|
|
|
|
|
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
|
|
|
|
|
if self.challenge_tags.nil?
|
|
|
|
|
"--"
|
|
|
|
|