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 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