|
|
@ -56,20 +56,13 @@ class Myshixun < ApplicationRecord
|
|
|
|
# status:0 可以测评的,正在测评的
|
|
|
|
# status:0 可以测评的,正在测评的
|
|
|
|
# 如果都完成,则当前任务为最后一个任务
|
|
|
|
# 如果都完成,则当前任务为最后一个任务
|
|
|
|
def current_task
|
|
|
|
def current_task
|
|
|
|
|
|
|
|
games = self.games
|
|
|
|
current_game = self.games.select{|game| game.status == 1 || game.status == 0}.first
|
|
|
|
current_game = games.select{|game| game.status == 1 || game.status == 0}.first
|
|
|
|
if current_game.blank?
|
|
|
|
if current_game.blank?
|
|
|
|
if self.status == 1
|
|
|
|
current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id}
|
|
|
|
logger.info("@3333333333344444444#{self.id}")
|
|
|
|
and g.challenge_id = c.id and g.status = 2 order by c.position desc").first
|
|
|
|
current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and
|
|
|
|
|
|
|
|
g.challenge_id = c.id and g.status = 2 order by c.position desc").first
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# 如果没开启过的,status都为3,所以应该进入第一关
|
|
|
|
|
|
|
|
current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and
|
|
|
|
|
|
|
|
g.challenge_id = c.id and g.status = 3 order by c.position asc").first
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return current_game
|
|
|
|
current_game
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|