From 17affc5de2b65b12651fa708d8bae09ce44911ae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 09:35:40 +0800 Subject: [PATCH 1/7] fix bug --- app/controllers/homework_commons_controller.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 6e2e1df40..3eb0364e9 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -205,6 +205,9 @@ class HomeworkCommonsController < ApplicationController exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: {table_columns: @work_head_cells,task_users: @work_cells_column} + Rails.logger.info("############_____________@work_head_cells_________###############{@work_head_cells}") + Rails.logger.info("############_____________@work_cells_column_________###############{@work_cells_column}") + else normal_status(-1,"暂无提交的学生!") end From 65d7336e58a14bf24f6b587163641e219d28d032 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 09:40:17 +0800 Subject: [PATCH 2/7] fix bug --- app/controllers/homework_commons_controller.rb | 7 ++++--- app/helpers/export_helper.rb | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 3eb0364e9..f265292ab 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -201,13 +201,14 @@ class HomeworkCommonsController < ApplicationController tip_exception(403, "无权限操作") else if @work_excel.present? + Rails.logger.info("############_____________@work_excel_________###############{@work_excel.size}") + Rails.logger.info("############_____________@homework_________###############{@homework.id}") student_work_to_xlsx(@work_excel,@homework) exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') + Rails.logger.info("############_____________exercise_export_name_________###############{exercise_export_name}") + render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: {table_columns: @work_head_cells,task_users: @work_cells_column} - Rails.logger.info("############_____________@work_head_cells_________###############{@work_head_cells}") - Rails.logger.info("############_____________@work_cells_column_________###############{@work_cells_column}") - else normal_status(-1,"暂无提交的学生!") end diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index af883131a..3a66c9dff 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -104,6 +104,8 @@ module ExportHelper @work_cells_column.push(row_cells_column) end else #实训题 + Rails.logger.info("############_____________homework.homework_type_________###############{homework.homework_type}") + shixun = homework.shixuns.first shixun_head_cells = %w(完成情况 通关时间 总耗时 总评测次数 获得经验值 关卡得分) eff_boolean = homework.work_efficiency From 298d7e5b02a33285b66d3ec2d9235eb18e5c8e08 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 25 Jun 2019 10:01:20 +0800 Subject: [PATCH 3/7] fix bug --- app/controllers/homework_commons_controller.rb | 3 --- app/helpers/export_helper.rb | 2 -- 2 files changed, 5 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f265292ab..13e58f21d 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -201,11 +201,8 @@ class HomeworkCommonsController < ApplicationController tip_exception(403, "无权限操作") else if @work_excel.present? - Rails.logger.info("############_____________@work_excel_________###############{@work_excel.size}") - Rails.logger.info("############_____________@homework_________###############{@homework.id}") student_work_to_xlsx(@work_excel,@homework) exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S') - Rails.logger.info("############_____________exercise_export_name_________###############{exercise_export_name}") render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals: {table_columns: @work_head_cells,task_users: @work_cells_column} diff --git a/app/helpers/export_helper.rb b/app/helpers/export_helper.rb index 3a66c9dff..af883131a 100644 --- a/app/helpers/export_helper.rb +++ b/app/helpers/export_helper.rb @@ -104,8 +104,6 @@ module ExportHelper @work_cells_column.push(row_cells_column) end else #实训题 - Rails.logger.info("############_____________homework.homework_type_________###############{homework.homework_type}") - shixun = homework.shixuns.first shixun_head_cells = %w(完成情况 通关时间 总耗时 总评测次数 获得经验值 关卡得分) eff_boolean = homework.work_efficiency From 28dbdd03eef8aa87b78382c636adbe1a830db88e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:21:03 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/myshixun.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/app/models/myshixun.rb b/app/models/myshixun.rb index 089b416de..b5bbdc249 100644 --- a/app/models/myshixun.rb +++ b/app/models/myshixun.rb @@ -56,20 +56,13 @@ class Myshixun < ApplicationRecord # status:0 可以测评的,正在测评的 # 如果都完成,则当前任务为最后一个任务 def current_task - - current_game = self.games.select{|game| game.status == 1 || game.status == 0}.first + games = self.games + current_game = games.select{|game| game.status == 1 || game.status == 0}.first if current_game.blank? - if self.status == 1 - logger.info("@3333333333344444444#{self.id}") - current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and - g.challenge_id = c.id and g.status = 2 order by c.position desc").first - else - # 如果没开启过的,status都为3,所以应该进入第一关 - current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} and - g.challenge_id = c.id and g.status = 3 order by c.position asc").first - end + current_game = Game.find_by_sql("SELECT g.* FROM games g, challenges c where g.myshixun_id=#{self.id} + and g.challenge_id = c.id and g.status = 2 order by c.position desc").first end - return current_game + current_game end From 4264679c7be42d75b568047f8efb5b947e118062 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:26:59 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98=E8=AF=84?= =?UTF-8?q?=E6=B5=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 79167150e..9c3051796 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -613,13 +613,10 @@ class GamesController < ApplicationController end # 批量插入评测结果 - uid_logger("choose_build") + uid_logger("#------------chooice score: #{score}") sql = "INSERT INTO outputs (game_id, test_set_position, actual_output, result, query_index, created_at, updated_at) VALUES" + str ActiveRecord::Base.connection.execute sql - had_done = @game.had_done - @myshixun.update_attribute(:status, 1) if had_done == 1 - # 没通关或者查看了答案通关的时候经验为0 # 通关但是查看了答案,评测的时候金币显示0(避免用户以为重复扣除),但是在关卡列表中金币显示负数 experience = 0 @@ -638,6 +635,8 @@ class GamesController < ApplicationController final_score = score RewardExperienceService.call(@myshixun.owner, reward_attrs) end + had_done = @game.had_done + @myshixun.update_attribute(:status, 1) if had_done == 1 end grade = @myshixun.owner.try(:grade) From 3b7aa73202af2edcfd065679424a49a339474a7b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:30:53 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 9c3051796..ecd84ebd5 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -627,6 +627,7 @@ class GamesController < ApplicationController @game.update_attributes(:status => 2, :end_time => Time.now) # TPM实训已发布并且没有查看答案 if @shixun.is_published? && !@game.answer_open + uid_logger("@@@@@@@@@@@@@@@@@chooice score: #{score}") # 查看答案的时候处理final_scor和扣分记录 experience = score reward_attrs = { container_id: @game.id, container_type: 'Game', score: score } From 62dd9051a4f42643c92b1309587570012a5d207e Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 25 Jun 2019 10:37:54 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98=E8=AF=84?= =?UTF-8?q?=E6=B5=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index ecd84ebd5..2a3c51762 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -626,7 +626,7 @@ class GamesController < ApplicationController if had_passed && !@game.had_passed? @game.update_attributes(:status => 2, :end_time => Time.now) # TPM实训已发布并且没有查看答案 - if @shixun.is_published? && !@game.answer_open + if @shixun.is_published? && @game.answer_open == 0 uid_logger("@@@@@@@@@@@@@@@@@chooice score: #{score}") # 查看答案的时候处理final_scor和扣分记录 experience = score