From 7c024985bf37c4f7b3a1bd313c2bafe0b5fc77b2 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 25 Sep 2017 11:16:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E9=80=89=E5=A4=9A=E9=80=89=E9=A2=98?= =?UTF-8?q?=E7=AD=94=E9=A2=98=E6=A8=A1=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 16 ++--- app/controllers/shixuns_controller.rb | 4 +- app/views/games/_choice_question.html.erb | 2 +- app/views/games/_game_choose_results.html.erb | 8 ++- app/views/games/_pass_game_show.html.erb | 60 +++++-------------- public/stylesheets/css/edu-popup.css | 6 +- 6 files changed, 36 insertions(+), 60 deletions(-) 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 %>