|
|
|
@ -52,7 +52,7 @@ class Challenge < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
# 开启挑战
|
|
|
|
|
def open_game user_id, shixun
|
|
|
|
|
game = self.games.select([:status, :identifier]).where(user_id: user_id).first
|
|
|
|
|
game = self.games.first
|
|
|
|
|
if game.present?
|
|
|
|
|
shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : ""
|
|
|
|
|
else
|
|
|
|
@ -76,7 +76,7 @@ class Challenge < ApplicationRecord
|
|
|
|
|
## 用户关卡状态 0: 不能开启实训; 1:直接开启; 2表示已完成
|
|
|
|
|
def user_tpi_status user_id
|
|
|
|
|
# todo: 以前没加索引导致相同关卡,同一用户有多个games
|
|
|
|
|
game = games.select{|game| game.user_id == user_id }.last
|
|
|
|
|
game = games.last
|
|
|
|
|
|
|
|
|
|
if game.blank?
|
|
|
|
|
self.position == 1 ? 1 : 0
|
|
|
|
|