实训报错

dev_course
daiao 6 years ago
parent 298d7e5b02
commit 28dbdd03ee

@ -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

Loading…
Cancel
Save