From 3d1242b2f6b8fa01fb18269279d4bb9e888a5fa0 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 25 Dec 2019 15:31:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?hack=E5=A5=96=E5=8A=B1=E9=87=91=E5=B8=81?= =?UTF-8?q?=E7=9A=84=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/decorators/grade_decorator.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/decorators/grade_decorator.rb b/app/decorators/grade_decorator.rb index ffffa11c9..b89cd99ce 100644 --- a/app/decorators/grade_decorator.rb +++ b/app/decorators/grade_decorator.rb @@ -31,6 +31,9 @@ module GradeDecorator when 'check_ta_answer' then game = Game.find_by(id: container_id) game.present? ? "查看实训“#{game.challenge.shixun.name}”第#{game.challenge.position}关的TA人解答消耗的金币" : '' + when 'hack' then + hack = Hack.find_by(id: container_id) + game.present? ? "完成了题目解答“#{hack.name}”,获得金币奖励:#{hack.score}" : '' end end end \ No newline at end of file From 5cbadac641737b4a84241b368ae335b1d3d622ca Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 25 Dec 2019 15:33:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=80=9A=E5=85=B3=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/hack_user_lastest_codes_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/hack_user_lastest_codes_controller.rb b/app/controllers/hack_user_lastest_codes_controller.rb index 08ca3ff77..5f5eddddc 100644 --- a/app/controllers/hack_user_lastest_codes_controller.rb +++ b/app/controllers/hack_user_lastest_codes_controller.rb @@ -166,12 +166,12 @@ class HackUserLastestCodesController < ApplicationController # 通关 if submit_params[:status] == "0" # 编程题已经发布,且之前未通关奖励积分 + @hack.increment!(:pass_num) if @hack.status == 1 && !@my_hack.passed? reward_attrs = { container_id: game.id, container_type: 'Hack', score: @hack.score } RewardGradeService.call(@my_hack.user, reward_attrs) RewardExperienceService.call(@my_hack.user, reward_attrs) # 评测完成更新通过数 - @hack.increment!(:pass_num) @my_hack.update_attributes(passed: true, passed_time: Time.now) end end