diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 089b416de..b5bbdc249 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -56,20 +56,13 @@ class Myshixun < ApplicationRecord # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 def current_task - - current_game = self.games.select{|game| game.status == 1 || game.status == 0}.first + games = self.games + current_game = games.select{|game| game.status == 1 || game.status == 0}.first if current_game.blank? - if self.status == 1 - logger.info("@3333333333344444444#{self.id}") - 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 + 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 end - return current_game + current_game end