diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index d5efe210f..b3e715157 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -203,16 +203,16 @@ class GamesController < ApplicationController shixun = @myshixun.shixun logger.info("##### resubmit_identifier is #{resubmit_identifier}") if params[:resubmit].blank? # 非重新评测 - @game.update_attribute(:end_time, Time.now) if had_done == 1 # 通过最后一关,即所有关卡 @myshixun.update_attribute(:status, 1) - else # 通过当前一关 - if @game.status == 2 - game_passed_code(@game.id, game_challenge.try(:path), @myshixun.try(:gpid), 1) - if !@game.answer_open && shixun.status > 1 - reward_grade(@game.user, @game.id, @game.class, game_challenge.score) - reward_experience(@game.user, @game.id, @game.class, game_challenge.score) - end + end + # 通过当前一关 + if @game.status == 2 + @game.update_attribute(:end_time, Time.now) + game_passed_code(@game.id, game_challenge.try(:path), @myshixun.try(:gpid), 1) + if !@game.answer_open && shixun.status > 1 + reward_grade(@game.user, @game.id, @game.class, game_challenge.score) + reward_experience(@game.user, @game.id, @game.class, game_challenge.score) end end game_status = @game.status diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 5d23cb584..bc01a40b4 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -60,7 +60,7 @@ class Myshixun < ActiveRecord::Base current_game = games.select{|game| game.status==1 || game.status==0}.first if current_game.blank? passed_games = games.select{|game| game.status==2} - current_game = passed_games.last + current_game = passed_games.first end return current_game end diff --git a/app/views/games/_code_actions.html.erb b/app/views/games/_code_actions.html.erb index 2f76c6632..e45ee671a 100644 --- a/app/views/games/_code_actions.html.erb +++ b/app/views/games/_code_actions.html.erb @@ -52,8 +52,8 @@ function formatDuring(time){ var days = parseInt(time / (1000 * 60 * 60 * 24)); var hours = parseInt((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - var minutes = parseInt((time % (1000 * 60 * 60)) / (1000 * 60)); - var seconds = parseInt((time % (1000 * 60)) / 1000); + var minutes = parseInt((time % (1000 * 60 * 60 * 24) % (1000 * 60 * 60))/ (1000 * 60)); + var seconds = parseInt((time % (1000 * 60 * 60 * 24) % (1000 * 60 * 60)) % (1000 * 60) / 1000); $("#time-consuming").html("耗时:" + days + " 天 " + hours + " 小时 " + minutes + " 分钟 " + seconds + " 秒 "); }