diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 69194f1f8..72d476c49 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -316,9 +316,8 @@ class GamesController < ApplicationController answer_right = [] @game_challenge.challenge_chooses.each_with_index do |choose, index| correct = (params[:answer][index] == choose.standard_answer) ? true : false - if choose.current_choose_outputs.blank? - ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct) - end + choose.current_choose_outputs.delete if choose.current_choose_outputs.present? + ChooseOutputs.create(:challenge_choose_id => choose.id, :user_id => User.current.id, :answer => params[:answer][index], :correct => correct) if @shixun.status > 1 && !@game.answer_open if correct score += choose.score @@ -332,12 +331,13 @@ class GamesController < ApplicationController end answer_right << correct end - @game.update_attributes(:status => 2, :end_time => Time.now) @had_done = @game.had_done - reward_grade(@game.user, @game.id, 'Game', score) - reward_experience(@game.user, @game.id, 'Game', score) - @game.update_attribute(:final_score, score) - + if @right + @game.update_attributes(:status => 2, :end_time => Time.now) + reward_grade(@game.user, @game.id, 'Game', score) + reward_experience(@game.user, @game.id, 'Game', score) + @game.update_attribute(:final_score, score) + end respond_to do |format| format.js{redirect_to myshixun_game_path(@game, :myshixun_id => @myshixun, :choose => 1)} end diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index d11285bc7..170349350 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -254,9 +254,9 @@ class ShixunsController < ApplicationController # 确定 sort 1升序 2 降序 @order = params[:order] || "myshixun_count" bsort = params[:sort] || "desc" - @sort = bsort == "desc" ? "asc" : "desc" + @sort = bsort == "asc" ? "desc" : "asc" if @order == "updated_at" - order_str = "#{Shixun.table_name}.updated_at #{bsort}" + order_str = "#{Shixun.table_name}.updated_at #{@sort}" else order_str = "myshixun_count #{bsort}, #{Shixun.table_name}.updated_at #{bsort}" end diff --git a/app/views/games/_choice_question.html.erb b/app/views/games/_choice_question.html.erb index 8330ad846..486fa2317 100644 --- a/app/views/games/_choice_question.html.erb +++ b/app/views/games/_choice_question.html.erb @@ -31,7 +31,7 @@
<% end %> - + <% end %>