实训开启状态调整

dev_forum
jingquan huang 5 years ago
parent 4c84839da2
commit cc3687df2f

@ -51,8 +51,8 @@ class Challenge < ApplicationRecord
end
# 开启挑战
def open_game user_id, challenge_id, shixun
game = games.select{|game| game.challenge_id = challenge_id && game.user_id == user_id}.first
def open_game user_id, shixun
game = self.games.select([:status, :identifier]).where(user_id: user_id).first
if game.present?
shixun.task_pass || game.status != 3 ? "/tasks/#{game.identifier}" : ""
else

@ -17,7 +17,7 @@ if @challenges.present?
json.passed_count challenge.user_passed_count
json.playing_count challenge.playing_count
json.name_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)
json.open_game challenge.open_game(@user.id, challenge.id, @shixun)
json.open_game challenge.open_game(@user.id, @shixun)
if @editable
json.edit_url edit_shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)
json.delete_url shixun_challenge_path(challenge, shixun_identifier: @shixun.identifier)

Loading…
Cancel
Save