From d9eb84eafc0015339743b8096ac249a9fec77e76 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 18 Jul 2019 14:38:00 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E7=BB=8F=E9=AA=8C=E5=80=BC=E4=B8=8D?= =?UTF-8?q?=E5=A4=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/game.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/game.rb b/app/models/game.rb index 88d636998..f1f2a09b4 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -61,7 +61,7 @@ class Game < ApplicationRecord if self.status == 2 # 通关了则取实际得分,没通关则取总分 gold = (shixun_status <= 1) ? 0 : self.final_score.to_i # 只要过关了,查看了答案经验值就是0;通关前查看了答案金final_score为负数 - experience = (shixun_status <= 1 || self.final_score.to_i < 0) ? 0 : challenge.score.to_i + experience = (shixun_status <= 1 || self.final_score.to_i < 0) ? 0 : challenge.final_score.to_i else gold = challenge.score.to_i experience = gold From 0536b357bc4d1a309ca38647f182477b416a7cd9 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 18 Jul 2019 14:48:02 +0800 Subject: [PATCH 02/24] competition: join team apig --- .../competition_teams_controller.rb | 25 +++++++++++++++-- app/models/competition.rb | 5 ++++ .../create_personal_team_service.rb | 27 +++++++++++++++++++ .../competitions/save_team_service.rb | 1 + config/routes.rb | 1 + 5 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 app/services/competitions/create_personal_team_service.rb diff --git a/app/controllers/competitions/competition_teams_controller.rb b/app/controllers/competitions/competition_teams_controller.rb index 34c80d24c..b4861c4d3 100644 --- a/app/controllers/competitions/competition_teams_controller.rb +++ b/app/controllers/competitions/competition_teams_controller.rb @@ -4,9 +4,16 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController end def create - team = current_competition.competition_teams.new(user: current_user) - Competitions::SaveTeamService.call(team, save_params) + if current_competition.personal? # 个人赛报名 + Competitions::CreatePersonalTeamService.call(current_competition, current_user) + else + team = current_competition.competition_teams.new(user: current_user) + Competitions::SaveTeamService.call(team, save_params) + end render_ok + + rescue Competitions::CreatePersonalTeamService::Error => ex + render_error(ex.message) end def update @@ -22,6 +29,20 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController render_error(ex.message) end + def leave + team = current_competition.competition_teams.find(params[:id]) + member = team.team_members.find_by(user_id: current_user.id) + return render_error('您不是该战队的成员') if member.blank? + + if member.user_id == team.user_id + team.destroy! # 队长退出,战队解散 + else + member.destroy! + end + + render_ok + end + private def all_competition_teams diff --git a/app/models/competition.rb b/app/models/competition.rb index f5d146ab4..024478ad6 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -23,6 +23,11 @@ class Competition < ApplicationRecord status? end + # 是否为个人赛 + def personal? + competition_staffs.maximum(:maximum) == 1 + end + # 报名是否结束 def enroll_ended? enroll_end_time.blank? || enroll_end_time < Time.now diff --git a/app/services/competitions/create_personal_team_service.rb b/app/services/competitions/create_personal_team_service.rb new file mode 100644 index 000000000..12b595cae --- /dev/null +++ b/app/services/competitions/create_personal_team_service.rb @@ -0,0 +1,27 @@ +class Competitions::CreatePersonalTeamService < ApplicationService + Error = Class.new(StandardError) + + attr_reader :competition, :user + + def initialize(competition, user) + @competition = competition + @user = user + end + + def call + raise Error, '个人赛才能报名' unless competition.personal? + + is_teacher = user.is_teacher? + raise Error, '本竞赛的参赛者限定为:学生' if is_teacher && competition.teacher_enroll_forbidden? + raise Error, '本竞赛的参赛者限定为:教师' if !is_teacher && competition.member_enroll_forbidden? + + enrolled = competition.competition_teams.exists?(user_id: user.id) + multiple_limited = (is_teacher && competition.teacher_multiple_limited?) || (!is_teacher && competition.member_multiple_limited?) + raise Error, '您已报名该竞赛' if enrolled && multiple_limited + + ActiveRecord::Base.transaction do + team = competition.competition_teams.create!(name: user.show_name, user_id: user.id) + team.team_members.create!(competition_id: competition, user_id: user.id, role: 1, is_teacher: is_teacher) + end + end +end \ No newline at end of file diff --git a/app/services/competitions/save_team_service.rb b/app/services/competitions/save_team_service.rb index c134e70d7..1021e6e6d 100644 --- a/app/services/competitions/save_team_service.rb +++ b/app/services/competitions/save_team_service.rb @@ -17,6 +17,7 @@ class Competitions::SaveTeamService < ApplicationService is_teacher = team.user.is_teacher? ActiveRecord::Base.transaction do team.generate_invite_code if new_record + team.team_type = 1 # 组队竞赛 team.name = params[:name].to_s.strip team.save! diff --git a/config/routes.rb b/config/routes.rb index dc521266c..a5742494d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -676,6 +676,7 @@ Rails.application.routes.draw do resource :competition_staff resources :competition_teams, only: [:index, :show] do post :join, on: :collection + post :leave, on: :member end resources :teachers, only: [:index] resources :students, only: [:index] From 074454743cf13d5514c9fc46ab7feb1234ea6e58 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 14:54:43 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 10 ++++++---- app/controllers/myshixuns_controller.rb | 10 +++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 4996a11ca..9eed3cc69 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -712,6 +712,7 @@ class GamesController < ApplicationController uid_logger("################params[:resubmit]: #{params[:resubmit]}") uid_logger("################resubmit_identifier: #{resubmit_identifier}") uid_logger("################time_out: #{params[:time_out]}") + sec_key = params[:sec_key] if (params[:time_out] == "false") && ((params[:resubmit].blank? && @game.status == 1) || (params[:resubmit].present? && (params[:resubmit] != resubmit_identifier))) # 代码评测的信息 @@ -759,7 +760,7 @@ class GamesController < ApplicationController # 轮询结束,更新评测统计耗时 if game_status == 0 || game_status == 2 - e_record = EvaluateRecord.where(:game_id => @game.id).first + e_record = EvaluateRecord.where(:sec_key => sec_key).first if e_record front_js = format("%.3f", (Time.now.to_f - e_record.try(:updated_at).to_f)).to_f consume_time = format("%.3f", (Time.now - e_record.created_at)).to_f @@ -767,7 +768,7 @@ class GamesController < ApplicationController end end - uid_logger("game is is #{@game.id}, record id is #{e_record.try(:id)}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") + uid_logger("game is #{@game.id}, record id is #{e_record.try(:id)}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") # 记录前端总耗时 record_consume_time = EvaluateRecord.where(:game_id => @game.id).first.try(:consume_time) # 实训制作者当前拥有的金币 @@ -852,7 +853,7 @@ class GamesController < ApplicationController if max_query_index > 0 uid_logger("max_query_index is #{max_query_index} game id is #{@game.id}, challenge_id is #{challenge.id}") - @qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output, o.out_put, o.result, o.test_set_position, + @qurey_test_sets = TestSet.find_by_sql("SELECT o.code, o.actual_output, o.out_put, o.result, o.test_set_position, o.ts_time, o.query_index, t.is_public, t.input, t.output, o.compile_success FROM outputs o, games g, challenges c, test_sets t where g.id=#{@game.id} and c.id=#{challenge.id} and o.query_index=#{max_query_index} and g.id = o.game_id and c.id= g.challenge_id and t.challenge_id = c.id and @@ -866,8 +867,9 @@ class GamesController < ApplicationController end @last_compile_output = @qurey_test_sets.first['out_put'].gsub(/\n/, '
').gsub(/\t/, " \; \; \; \; \; \; \; \;") if @qurey_test_sets.first['out_put'].present? else + # 没有评测过,第一次进来后的呈现方式 @qurey_test_sets = TestSet.find_by_sql("SELECT t.is_public, t.input, t.output, t.position - FROM test_sets t where t.challenge_id = #{challenge.id}") + FROM test_sets t where t.challenge_id = #{challenge.id}") end end diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 79358f5c2..617ed29a3 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -46,6 +46,7 @@ class MyshixunsController < ApplicationController end # 代码运行中的信息接口 + # 这个方法是中间层主动调用的,点击评测后,中间层会发送参数过来,告诉目前Pod的启动情况,一次评测会调用两次请求 def code_runinng_message begin jsonTestDetails = JSON.parse(params[:jsonTestDetails]) @@ -100,12 +101,11 @@ class MyshixunsController < ApplicationController game_id = jsonTestDetails['buildID'] sec_key = jsonTestDetails['sec_key'] - # 资源消耗 - res_usage = jsonTestDetails['resUsage'] - logger.info("training_task_status start#1**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") resubmit = jsonTestDetails['resubmit'] outPut = tran_base64_decode64(jsonTestDetails['outPut']) + # 资源消耗 + max_mem = tran_base64_decode64(jsonTestDetails['resUsage']) if jsonTestDetails['resUsage'].present? jenkins_testsets = jsonTestDetails['msg'] compile_success = jsonTestDetails['compileSuccess'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? @@ -140,7 +140,7 @@ class MyshixunsController < ApplicationController end end uid_logger("#############status: #{status}") - record = EvaluateRecord.where(:game_id => game_id).first + record = EvaluateRecord.where(:sec_key => sec_key).first logger.info("training_task_status start#3**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") answer_deduction_percentage = (100 - game.answer_deduction) / 100.to_f # 查看答案后剩余分数的百分比. # answer_deduction是查看答案的扣分比例 @@ -201,7 +201,7 @@ class MyshixunsController < ApplicationController if record.present? consume_time = format("%.3f", (Time.now - record.created_at)).to_f record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , :create_pod => timeCost['createPod'], - :pod_execute => timeCost['execute'], :test_cases => test_cases_time, + :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :max_mem => max_mem, :brige => timeCost['evaluateAllTime'], :return_back => return_back_time) end uid_logger("training_task_status start#4**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") From 01dac41ff80ece78678d6b65d0f8adbdaa733711 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 14:54:51 +0800 Subject: [PATCH 04/24] .. --- app/controllers/games_controller.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 9eed3cc69..b51dab344 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -741,14 +741,14 @@ class GamesController < ApplicationController end else # 重新评测 # 如果满足前面的条件,进入此处只可能是结果已返回并存入了数据库 - if params[:resubmit] == resubmit_identifier # 本次重新评测结果已经返回并存入数据库 + if params[:resubmit] == resubmit_identifier # 本次重新评测结果已经返回并存入数据库 game_status = (@game.retry_status == 2 ? 2 : 0) # retry_status是判断重新评测的通关情况。2表示通关 end end # 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集 max_query_index = @game.query_index - #max_query_index = @game.outputs.first.try(:query_index) + # max_query_index = @game.outputs.first.try(:query_index) # 区分评测过未评测过,未评测过按需求取数据 testset_detail max_query_index.to_i, game_challenge @@ -758,9 +758,10 @@ class GamesController < ApplicationController web_route = game_challenge.try(:web_route) mirror_name = @shixun.mirror_name + e_record = EvaluateRecord.where(:sec_key => sec_key).first # 轮询结束,更新评测统计耗时 if game_status == 0 || game_status == 2 - e_record = EvaluateRecord.where(:sec_key => sec_key).first + if e_record front_js = format("%.3f", (Time.now.to_f - e_record.try(:updated_at).to_f)).to_f consume_time = format("%.3f", (Time.now - e_record.created_at)).to_f @@ -770,7 +771,8 @@ class GamesController < ApplicationController uid_logger("game is #{@game.id}, record id is #{e_record.try(:id)}, time is**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") # 记录前端总耗时 - record_consume_time = EvaluateRecord.where(:game_id => @game.id).first.try(:consume_time) + record_consume_time = e_record.try(:pod_execute) + max_mem = e_record.try(:max_mem) # 实训制作者当前拥有的金币 grade = User.where(:id => @game.user_id).pluck(:grade).first @@ -781,7 +783,7 @@ class GamesController < ApplicationController @base_date = {grade: grade, gold: score, experience: experience, status: game_status, had_done: had_done, position: game_challenge.position, port: port, record_consume_time: record_consume_time, mirror_name: mirror_name, picture: picture, web_route: web_route, star: @game.star, - next_game: next_game, prev_game: prev_game} + next_game: next_game, prev_game: prev_game, max_mem: max_mem} end # 记录实训花费的时间 From c3d545bc57f5a7262521f14275aafbd7e38769aa Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 18 Jul 2019 15:04:19 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E8=AF=95=E5=8D=B7pdf=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exercise_export/blank_exercise.html.erb | 12 ++++++------ app/templates/exercise_export/exercise_user.html.erb | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/templates/exercise_export/blank_exercise.html.erb b/app/templates/exercise_export/blank_exercise.html.erb index 5e763d1cc..4a2373f3f 100644 --- a/app/templates/exercise_export/blank_exercise.html.erb +++ b/app/templates/exercise_export/blank_exercise.html.erb @@ -81,25 +81,25 @@
<% if q.question_type == 0 %> - <% q.exercise_choices.each do |s| %> + <% q.exercise_choices.each_with_index do |s,index| %>
- <%= to_markdown(s.choice_text,@request_url) %> + <%= to_markdown("#{(index+65).chr}.#{s.choice_text}",@request_url) %>
<% end %> <% elsif q.question_type == 1 %> - <% q.exercise_choices.each do |s| %> + <% q.exercise_choices.each_with_index do |s,index| %>
- <%= to_markdown(s.choice_text,@request_url) %> + <%= to_markdown("#{(index+65).chr}.#{s.choice_text}",@request_url) %>
<% end %> <% elsif q.question_type == 2 %>
- <% q.exercise_choices.each do |s| %> + <% q.exercise_choices.each_with_index do |s,index| %> - <%= s.choice_text %> + <%= "#{(index+65).chr}.#{s.choice_text}" %> <% end %>
diff --git a/app/templates/exercise_export/exercise_user.html.erb b/app/templates/exercise_export/exercise_user.html.erb index 1c91baec2..8d4da5ca2 100644 --- a/app/templates/exercise_export/exercise_user.html.erb +++ b/app/templates/exercise_export/exercise_user.html.erb @@ -182,16 +182,16 @@
<% if q_type == 0 %> - <% q.exercise_choices.each do |s| %> + <% q.exercise_choices.each_with_index do |s,index| %> <% check_answer = (user_answer.present? && (s.id == user_answer.first.exercise_choice_id)) ? "choose-answer" : '' %>
- <%= to_markdown(s.choice_text,@request_url) %> + <%= to_markdown("#{(index+65).chr}.#{s.choice_text}",@request_url) %>
<% end %>
<% elsif q_type == 1 %> - <% q.exercise_choices.each do |s| %> + <% q.exercise_choices.each_with_index do |s,index| %> <% check_answer = (user_answer.present? && (user_answer.pluck(:exercise_choice_id).include?(s.id))) ? true : false %>
<% if check_answer %> @@ -199,13 +199,13 @@ <% else %> <% end %> - <%= to_markdown(s.choice_text,@request_url) %> + <%= to_markdown("#{(index+65).chr}.#{s.choice_text}",@request_url) %>
<% end %>
<% elsif q_type == 2 %>
- <% q.exercise_choices.each do |s| %> + <% q.exercise_choices.each_with_index do |s,index| %> <% if user_answer.present? && (s.id == user_answer.first.exercise_choice_id) %> <% check_answer = 'choose-answer' %> <% else %> @@ -213,7 +213,7 @@ <% end %> - <%= s.choice_text %> + <%= "#{(index+65).chr}.#{s.choice_text}" %> <% end %>
From 8d522fe57e85ebde0af70b49464bb6936dd823ac Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 18 Jul 2019 15:14:04 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E8=AE=BA?= =?UTF-8?q?=E7=9A=84=E5=AD=90=E5=9B=9E=E5=A4=8D=E4=B8=8D=E5=86=8D=E9=9A=90?= =?UTF-8?q?=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/discuss.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/discuss.rb b/app/models/discuss.rb index 00e3209c0..2d9c00110 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -41,9 +41,7 @@ class Discuss < ApplicationRecord # end def child_discuss(user) - user.admin? ? - Discuss.where(parent_id: self.id).includes(:user).reorder(created_at: :asc) : - Discuss.where(parent_id: self.id, :hidden => false).includes(:user).reorder(created_at: :asc) + Discuss.where(parent_id: self.id).includes(:user).reorder(created_at: :asc) end private From e3f125a63cda4406228b5dc6f81af3cf10c4b015 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 15:15:29 +0800 Subject: [PATCH 07/24] =?UTF-8?q?500=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 | 4 ++-- app/controllers/myshixuns_controller.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index b51dab344..3a49f4d80 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -47,7 +47,7 @@ class GamesController < ApplicationController max_query_index = @game.query_index.to_i # 统计评测时间 - record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:consume_time) + record_onsume_time = EvaluateRecord.where(game_id: @game.id).first.try(:pod_execute) # myshixun_manager判断用户是否有权限查看隐藏测试集(TPM管理员;平台认证的老师;花费金币查看者) myshixun_manager = @identity < User::EDU_GAME_MANAGER @@ -758,7 +758,7 @@ class GamesController < ApplicationController web_route = game_challenge.try(:web_route) mirror_name = @shixun.mirror_name - e_record = EvaluateRecord.where(:sec_key => sec_key).first + e_record = EvaluateRecord.where(:identifier => sec_key).first # 轮询结束,更新评测统计耗时 if game_status == 0 || game_status == 2 diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index fc59f6b7c..0a86f88da 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -140,7 +140,7 @@ class MyshixunsController < ApplicationController end end uid_logger("#############status: #{status}") - record = EvaluateRecord.where(:sec_key => sec_key).first + record = EvaluateRecord.where(:identifier => sec_key).first logger.info("training_task_status start#3**#{game_id}**** #{Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")}") answer_deduction_percentage = (100 - game.answer_deduction) / 100.to_f # 查看答案后剩余分数的百分比. # answer_deduction是查看答案的扣分比例 From 8c841b95b66ff522ec77a760b63bb423a336e50b Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 18 Jul 2019 15:23:37 +0800 Subject: [PATCH 08/24] modify competition apig --- app/controllers/competitions/competition_teams_controller.rb | 4 ++-- app/models/searchable/dependents/challenge_tag.rb | 2 +- app/models/searchable/dependents/stage.rb | 2 +- app/models/searchable/dependents/user.rb | 4 ++-- app/views/competitions/competition_staffs/show.json.jbuilder | 1 + app/views/competitions/competition_teams/index.json.jbuilder | 3 +++ 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/competitions/competition_teams_controller.rb b/app/controllers/competitions/competition_teams_controller.rb index b4861c4d3..e03810b61 100644 --- a/app/controllers/competitions/competition_teams_controller.rb +++ b/app/controllers/competitions/competition_teams_controller.rb @@ -54,13 +54,13 @@ class Competitions::CompetitionTeamsController < Competitions::BaseController end @count = teams.count - @teams = paginate(teams.includes(:user, users: :user_extension)) + @teams = paginate(teams.includes(:user, users: { user_extension: :school })) end def user_competition_teams teams = current_competition.competition_teams teams = teams.joins(:team_members).where(team_members: { user_id: current_user.id }) - @teams = teams.includes(:user, users: :user_extension).to_a + @teams = teams.includes(:user, users: { user_extension: :school }).to_a @count = @teams.size end diff --git a/app/models/searchable/dependents/challenge_tag.rb b/app/models/searchable/dependents/challenge_tag.rb index fdec79d1b..51ef804dd 100644 --- a/app/models/searchable/dependents/challenge_tag.rb +++ b/app/models/searchable/dependents/challenge_tag.rb @@ -10,7 +10,7 @@ module Searchable::Dependents::ChallengeTag def check_searchable_dependents if new_record? || name_previously_changed? - challenge.shixun.reindex(:searchable_challenge_data) + challenge.shixun.reindex end end end \ No newline at end of file diff --git a/app/models/searchable/dependents/stage.rb b/app/models/searchable/dependents/stage.rb index 262ddd36f..d4207fec8 100644 --- a/app/models/searchable/dependents/stage.rb +++ b/app/models/searchable/dependents/stage.rb @@ -9,7 +9,7 @@ module Searchable::Dependents::Stage def check_searchable_dependents if name_previously_changed? || description_previously_changed? - subject.reindex(:searchable_stages_data) + subject.reindex end end end \ No newline at end of file diff --git a/app/models/searchable/dependents/user.rb b/app/models/searchable/dependents/user.rb index 761704d06..103131ed6 100644 --- a/app/models/searchable/dependents/user.rb +++ b/app/models/searchable/dependents/user.rb @@ -10,13 +10,13 @@ module Searchable::Dependents::User def check_searchable_dependents if firstname_previously_changed? || lastname_previously_changed? || user_extension.school_id_previously_changed? # reindex shixun - created_shixuns.each{ |shixun| shixun.reindex(:searchable_user_data) } + created_shixuns.each{ |shixun| shixun.reindex } # reindex course manage_courses.each(&:reindex) # reindex subject - created_subjects.each { |subject| subject.reindex(:searchable_user_data) } + created_subjects.each { |subject| subject.reindex } end end end \ No newline at end of file diff --git a/app/views/competitions/competition_staffs/show.json.jbuilder b/app/views/competitions/competition_staffs/show.json.jbuilder index 2cba22d2f..c490aaf5f 100644 --- a/app/views/competitions/competition_staffs/show.json.jbuilder +++ b/app/views/competitions/competition_staffs/show.json.jbuilder @@ -1,5 +1,6 @@ competition = current_competition +json.personal competition.personal? json.enroll_ended competition.enroll_ended? json.enrolled competition.enrolled?(current_user) diff --git a/app/views/competitions/competition_teams/index.json.jbuilder b/app/views/competitions/competition_teams/index.json.jbuilder index 86bb86a1c..b641b28e6 100644 --- a/app/views/competitions/competition_teams/index.json.jbuilder +++ b/app/views/competitions/competition_teams/index.json.jbuilder @@ -17,6 +17,9 @@ json.competition_teams do json.partial! 'users/user_simple', user: member.user json.user_id member.user_id json.role member.en_role + json.identity member.user.identity + json.school_name member.user.school_name + json.student_id member.user.student_id end end end From f6a5a0ebbca775e8f6d72ac8d4f65c7b9aea6b21 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 18 Jul 2019 15:27:07 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E8=AF=95=E5=8D=B7=EF=BC=8C=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E7=9A=84=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/exercise.rb | 12 ++++++++---- app/models/poll.rb | 28 +++++++++++++++++----------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index aba0a00bc..8286a96e2 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -127,8 +127,10 @@ class Exercise < ApplicationRecord #判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间 def get_exercise_status(user) - return Exercise::UNPUBLISHED if user.nil? - if user.student_of_course?(course) #当为学生的时候,需根据分班来判断试卷状态 + if course.end_time.present? && course.end_time <= Time.now + status = 4 + else + if user.present? && user.student_of_course?(course) #当为学生的时候,需根据分班来判断试卷状态 ex_time = get_exercise_times(user_id,false) pb_time = ex_time[:publish_time] ed_time = ex_time[:end_time] @@ -139,9 +141,11 @@ class Exercise < ApplicationRecord else status = Exercise::UNPUBLISHED end - else - status = exercise_status #当为老师的时候,则为试卷的总状态 + else + status = exercise_status #当为老师的时候,则为试卷的总状态 + end end + status end diff --git a/app/models/poll.rb b/app/models/poll.rb index e6a363f1d..5fda30609 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -100,19 +100,25 @@ class Poll < ApplicationRecord end def get_poll_status(user) - if user.student_of_course?(course) - ex_time = get_poll_times(user_id,false) - pb_time = ex_time[:publish_time] - ed_time = ex_time[:end_time] - if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now - status = 2 - elsif ed_time.present? && ed_time <= Time.now - status = 3 + if course.end_time.present? && course.end_time <= Time.now + status = 4 + else + if user.present? && user.student_of_course?(course) + ex_time = get_poll_times(user_id,false) + pb_time = ex_time[:publish_time] + ed_time = ex_time[:end_time] + if course.end_time.present? && course.end_time <= Time.now + status = 4 + elsif pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now + status = 2 + elsif ed_time.present? && ed_time <= Time.now + status = 3 + else + status = 1 + end else - status = 1 + status = polls_status end - else - status = polls_status end status end From e8e02abbbb28aff0583078ddc7f47b83fe0e1dcb Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 18 Jul 2019 15:29:59 +0800 Subject: [PATCH 10/24] fixbug --- app/models/exercise.rb | 2 +- app/models/poll.rb | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 8286a96e2..61c5c8eab 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -127,7 +127,7 @@ class Exercise < ApplicationRecord #判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间 def get_exercise_status(user) - if course.end_time.present? && course.end_time <= Time.now + if course.end_date.present? && course.end_date <= Time.now status = 4 else if user.present? && user.student_of_course?(course) #当为学生的时候,需根据分班来判断试卷状态 diff --git a/app/models/poll.rb b/app/models/poll.rb index 5fda30609..a9b4c2984 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -99,17 +99,15 @@ class Poll < ApplicationRecord end end - def get_poll_status(user) - if course.end_time.present? && course.end_time <= Time.now + def get_poll_status(user)s + if course.end_date.present? && course.end_date <= Time.now status = 4 else if user.present? && user.student_of_course?(course) ex_time = get_poll_times(user_id,false) pb_time = ex_time[:publish_time] ed_time = ex_time[:end_time] - if course.end_time.present? && course.end_time <= Time.now - status = 4 - elsif pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now + if pb_time.present? && ed_time.present? && pb_time <= Time.now && ed_time > Time.now status = 2 elsif ed_time.present? && ed_time <= Time.now status = 3 From a94728a6c434662767c15b474b3cd3363fc4f48e Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 18 Jul 2019 15:31:19 +0800 Subject: [PATCH 11/24] fixbug --- app/models/poll.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index a9b4c2984..52b814bb3 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -99,7 +99,7 @@ class Poll < ApplicationRecord end end - def get_poll_status(user)s + def get_poll_status(user) if course.end_date.present? && course.end_date <= Time.now status = 4 else From 4303995003e44804998bb1fe1d05a6b8c1d8a225 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 18 Jul 2019 15:33:47 +0800 Subject: [PATCH 12/24] fixbug --- app/models/exercise.rb | 3 +-- app/models/poll.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 61c5c8eab..825f7cd9f 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -127,7 +127,7 @@ class Exercise < ApplicationRecord #判断是否为分班,如果分班,试卷的截止时间为当前分班时间,否则为试卷的截止时间 def get_exercise_status(user) - if course.end_date.present? && course.end_date <= Time.now + if course.is_end status = 4 else if user.present? && user.student_of_course?(course) #当为学生的时候,需根据分班来判断试卷状态 @@ -145,7 +145,6 @@ class Exercise < ApplicationRecord status = exercise_status #当为老师的时候,则为试卷的总状态 end end - status end diff --git a/app/models/poll.rb b/app/models/poll.rb index 52b814bb3..7f0d2fd94 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -100,7 +100,7 @@ class Poll < ApplicationRecord end def get_poll_status(user) - if course.end_date.present? && course.end_date <= Time.now + if course.is_end status = 4 else if user.present? && user.student_of_course?(course) From de0aa8bcddf77952cc6e5b4d9c02569582e378fc Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 18 Jul 2019 15:38:00 +0800 Subject: [PATCH 13/24] fixbug --- app/controllers/polls_controller.rb | 6 +++--- app/views/polls/common_header.json.jbuilder | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 3fc17c661..9811cfa5a 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -205,15 +205,15 @@ class PollsController < ApplicationController @is_teacher_or = 1 @user_poll_answer = 3 #教师页面 end - poll_status = @poll.get_poll_status(current_user) + @poll_status = @poll.get_poll_status(current_user) poll_id_array = [@poll.id] @poll_publish_count = get_user_permission_course(poll_id_array,2).count #是否存在已发布的 @poll_unpublish_count = get_user_permission_course(poll_id_array,1).count #是否存在未发布的 if (@poll_publish_count == 0) && (@poll_unpublish_count == 0) #即表示没有分班 - if poll_status == 1 + if @poll_status == 1 @poll_unpublish_count = 1 #试卷未发布,且课堂没有分班的时候 - elsif poll_status == 2 + elsif @poll_status == 2 @poll_publish_count = 1 #试卷未发布,且课堂没有分班的时候 end end diff --git a/app/views/polls/common_header.json.jbuilder b/app/views/polls/common_header.json.jbuilder index 39c4ef811..b0a3d7374 100644 --- a/app/views/polls/common_header.json.jbuilder +++ b/app/views/polls/common_header.json.jbuilder @@ -1,5 +1,6 @@ json.course_is_end @course.is_end # true表示已结束,false表示未结束 -json.extract! @poll, :id,:polls_name,:polls_description,:polls_status,:show_result +json.extract! @poll, :id,:polls_name,:polls_description,:show_result +json.polls_status @poll_status json.user_permission do json.is_teacher_or @is_teacher_or From eb2290ffbcd54db402e6fb1a8b0fbb942dac638c Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 15:41:48 +0800 Subject: [PATCH 14/24] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=84=E6=B5=8B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=B7=BB=E5=8A=A0=E5=86=85=E5=AD=98=E5=92=8C?= =?UTF-8?q?=E8=AF=84=E6=B5=8B=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_testset_list.json.jbuilder | 1 + app/views/games/game_status.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/games/_testset_list.json.jbuilder b/app/views/games/_testset_list.json.jbuilder index 2111e3467..31c780570 100644 --- a/app/views/games/_testset_list.json.jbuilder +++ b/app/views/games/_testset_list.json.jbuilder @@ -7,6 +7,7 @@ json.test_sets @qurey_test_sets do |test_set| json.actual_output evaluate_actual_output(test_set) end json.compile_success test_set.try(:compile_success) + json.max_mem test_set.ts_time end json.allowed_unlock @shixun.test_set_permission diff --git a/app/views/games/game_status.json.jbuilder b/app/views/games/game_status.json.jbuilder index 73de75598..aecbf9d42 100644 --- a/app/views/games/game_status.json.jbuilder +++ b/app/views/games/game_status.json.jbuilder @@ -1,4 +1,4 @@ json.(@base_date, :grade, :gold, :experience, :status, :had_done, :position, :port, :record_consume_time, :mirror_name, - :picture, :web_route, :star, :next_game, :prev_game) + :picture, :web_route, :star, :next_game, :prev_game, :max_mem) # # 测试集相关 json.partial! 'games/testset_list' \ No newline at end of file From 66bef13e5c3317fd0cb0ae71830e4394d5ad2978 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 18 Jul 2019 15:45:26 +0800 Subject: [PATCH 15/24] fixbug --- app/controllers/exercises_controller.rb | 4 ++++ app/controllers/polls_controller.rb | 3 +++ 2 files changed, 7 insertions(+) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index f26e97849..03c943f8d 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -667,6 +667,7 @@ class ExercisesController < ApplicationController #立即发布的弹窗内容 def publish_modal + ActiveRecord::Base.transaction do begin exercise_ids = params[:check_ids] @@ -685,6 +686,9 @@ class ExercisesController < ApplicationController #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 def publish + tip_exception("缺少截止时间参数") if params[:end_time].blank? + tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) + tip_exception("截止时间不能晚于课堂结束时间") if @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) ActiveRecord::Base.transaction do begin check_ids = Exercise.where(id: params[:check_ids]) diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb index 9811cfa5a..f5003a0c7 100644 --- a/app/controllers/polls_controller.rb +++ b/app/controllers/polls_controller.rb @@ -244,6 +244,9 @@ class PollsController < ApplicationController end #首页批量或单独 立即发布,应是跳出弹窗,设置开始时间和截止时间。 def publish + tip_exception("缺少截止时间参数") if params[:end_time].blank? + tip_exception("截止时间不能早于当前时间") if params[:end_time] <= strf_time(Time.now) + tip_exception("截止时间不能晚于课堂结束时间") if @course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day) ActiveRecord::Base.transaction do begin check_ids = Poll.where(id: params[:check_ids]) From 44561b8a5196e6c93c1c0cbc3c442291fdd413cb Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 18 Jul 2019 16:01:42 +0800 Subject: [PATCH 16/24] =?UTF-8?q?=E8=AF=95=E7=94=A8=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8F=AF=E4=BB=A5=E4=B8=8D=E7=94=A8=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 875050642..6a7599f28 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -184,14 +184,13 @@ class ApplicationController < ActionController::Base end # 系统全局认证 - # def check_auth - if !current_user.profile_completed? - info_url = '/account/profile' - tip_exception(402, info_url) - elsif current_user.certification != 1 + if current_user.certification != 1 day_cer = UserDayCertification.find_by(user_id: current_user.id) tip_exception(407, "系统未授权") unless (Time.now.to_i - day_cer.try(:created_at).to_i) < 86400 + elsif !current_user.profile_completed? + info_url = '/account/profile' + tip_exception(402, info_url) end end From 02b0851e38de2b652ef2c850f117b27e229ad4aa Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 18 Jul 2019 16:05:24 +0800 Subject: [PATCH 17/24] competition module update api modify --- .../competitions/competition_modules_controller.rb | 12 +++++++++++- app/models/searchable/dependents/user.rb | 4 ++-- .../competition_modules/show.json.jbuilder | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/controllers/competitions/competition_modules_controller.rb b/app/controllers/competitions/competition_modules_controller.rb index da9873c43..c4692af70 100644 --- a/app/controllers/competitions/competition_modules_controller.rb +++ b/app/controllers/competitions/competition_modules_controller.rb @@ -15,7 +15,17 @@ class Competitions::CompetitionModulesController < Competitions::BaseController md = current_module.competition_module_md_content || current_module.build_competition_module_md_content md.name = params[:md_name] md.content = params[:md_content] - md.save! + + ActiveRecord::Base.transaction do + md.save! + + attachment_ids = Array.wrap(params[:attachment_ids]).map(&:to_i) + old_attachment_ids = md.attachments.pluck(:id) + + destroy_ids = old_attachment_ids - attachment_ids + md.attachments.where(id: destroy_ids).delete_all + Attachment.where(id: attachment_ids - old_attachment_ids).update_all(container: md) + end render_ok end diff --git a/app/models/searchable/dependents/user.rb b/app/models/searchable/dependents/user.rb index 103131ed6..f6dcaa430 100644 --- a/app/models/searchable/dependents/user.rb +++ b/app/models/searchable/dependents/user.rb @@ -10,13 +10,13 @@ module Searchable::Dependents::User def check_searchable_dependents if firstname_previously_changed? || lastname_previously_changed? || user_extension.school_id_previously_changed? # reindex shixun - created_shixuns.each{ |shixun| shixun.reindex } + created_shixuns.each(&:reindex) # reindex course manage_courses.each(&:reindex) # reindex subject - created_subjects.each { |subject| subject.reindex } + created_subjects.each(&:reindex) end end end \ No newline at end of file diff --git a/app/views/competitions/competition_modules/show.json.jbuilder b/app/views/competitions/competition_modules/show.json.jbuilder index d47742cf0..69cdcc544 100644 --- a/app/views/competitions/competition_modules/show.json.jbuilder +++ b/app/views/competitions/competition_modules/show.json.jbuilder @@ -5,4 +5,7 @@ if md.present? json.md_name md.name json.md_content md.content json.created_at md.created_at.strftime('%Y-%m-%d %H:%M:%S') + json.attachments do + json.array! md.attachments, partial: 'attachments/attachment_simple', as: :attachment + end end \ No newline at end of file From 24e0eeb0ab3db61ddd46385c840c857bc3fe0183 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 16:07:42 +0800 Subject: [PATCH 18/24] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 1 + config/elasticsearch.yml.example | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) delete mode 100644 config/elasticsearch.yml.example diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 0a86f88da..0cf220dcf 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -130,6 +130,7 @@ class MyshixunsController < ApplicationController # is_public = test_sets.where(:position => j_test_set['caseId']).first.try(:is_public) logger.info "actual_output:################################################# #{actual_output}" + ts_time = format("%.3f", j_test_set['testSetTime'].to_i).to_f Output.create!(:code => status, :game_id => game_id, :out_put => outPut, :test_set_position => j_test_set['caseId'], :actual_output => actual_output, :result => j_test_set['passed'].to_i, :query_index => max_query_index, :compile_success => compile_success.to_i, :sec_key => sec_key, :ts_time => j_test_set['testSetTime']) diff --git a/config/elasticsearch.yml.example b/config/elasticsearch.yml.example deleted file mode 100644 index cbecb85d7..000000000 --- a/config/elasticsearch.yml.example +++ /dev/null @@ -1,13 +0,0 @@ -defaults: &defaults - url: http://localhost:9200 - -development: - <<: *defaults - -test: - <<: *defaults - -production: - <<: *defaults - url: 'http://elastic:Elas+ucloud123@106.75.27.125:59200/' - # url: 'http://elastic:TEST_elastickibana321@es-cn-0pp174wsj000iubdx.public.elasticsearch.aliyuncs.com' From 66be66ef1ef2075c5604bd8895f6a362cfdd777f Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 16:12:39 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E6=AF=8F=E4=B8=AA=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=9B=86=E7=9A=84=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/games/_testset_list.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/games/_testset_list.json.jbuilder b/app/views/games/_testset_list.json.jbuilder index 31c780570..579adc3e6 100644 --- a/app/views/games/_testset_list.json.jbuilder +++ b/app/views/games/_testset_list.json.jbuilder @@ -7,7 +7,7 @@ json.test_sets @qurey_test_sets do |test_set| json.actual_output evaluate_actual_output(test_set) end json.compile_success test_set.try(:compile_success) - json.max_mem test_set.ts_time + json.ts_time test_set.ts_time end json.allowed_unlock @shixun.test_set_permission From 332359368d267f838e74c69fe8c964db250bbec5 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 18 Jul 2019 16:15:55 +0800 Subject: [PATCH 20/24] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9F=A5=E9=87=8D?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_commons/group_list.json.jbuilder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/homework_commons/group_list.json.jbuilder b/app/views/homework_commons/group_list.json.jbuilder index 5e6c63556..0108e5534 100644 --- a/app/views/homework_commons/group_list.json.jbuilder +++ b/app/views/homework_commons/group_list.json.jbuilder @@ -7,7 +7,7 @@ json.group_list do end end # 未分班展示情况放在最后 -if @course_groups.count < @limit.to_i +if @course_groups.count > 0 && @course_groups.count < @limit.to_i ungroup_work_count = homework_ungroup_works_count(@homework, @ungroup_user_ids) if ungroup_work_count > 0 json.ungroup_list do From e5d3c86063d19bfc7361b71b5f927aeac26450ba Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 18 Jul 2019 16:35:48 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E7=BB=8F=E9=AA=8C=E5=80=BC=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/game.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/game.rb b/app/models/game.rb index f1f2a09b4..ae056a702 100644 --- a/app/models/game.rb +++ b/app/models/game.rb @@ -61,7 +61,7 @@ class Game < ApplicationRecord if self.status == 2 # 通关了则取实际得分,没通关则取总分 gold = (shixun_status <= 1) ? 0 : self.final_score.to_i # 只要过关了,查看了答案经验值就是0;通关前查看了答案金final_score为负数 - experience = (shixun_status <= 1 || self.final_score.to_i < 0) ? 0 : challenge.final_score.to_i + experience = (shixun_status <= 1 || self.final_score.to_i < 0) ? 0 : self.final_score.to_i else gold = challenge.score.to_i experience = gold From c4d49d8097e7ce1a53e258b25ddab9f838e12f47 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 16:35:57 +0800 Subject: [PATCH 22/24] =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/myshixuns_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 0cf220dcf..8eae3547a 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -105,7 +105,9 @@ class MyshixunsController < ApplicationController resubmit = jsonTestDetails['resubmit'] outPut = tran_base64_decode64(jsonTestDetails['outPut']) # 资源消耗 + uid_logger("##########!!!!!!#{jsonTestDetails['resUsage']}") max_mem = tran_base64_decode64(jsonTestDetails['resUsage']) if jsonTestDetails['resUsage'].present? + uid_logger("##########!!!!!!#{max_mem}") jenkins_testsets = jsonTestDetails['msg'] compile_success = jsonTestDetails['compileSuccess'] # message = Base64.decode64(params[:msg]) unless params[:msg].blank? From 3c5f0385a32bf5797e41a418d225cf2f842c3827 Mon Sep 17 00:00:00 2001 From: jingquan huang Date: Thu, 18 Jul 2019 16:51:20 +0800 Subject: [PATCH 23/24] 500 and log --- app/controllers/myshixuns_controller.rb | 1 + app/views/games/_testset_list.json.jbuilder | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb index 8eae3547a..cb31f2464 100644 --- a/app/controllers/myshixuns_controller.rb +++ b/app/controllers/myshixuns_controller.rb @@ -203,6 +203,7 @@ class MyshixunsController < ApplicationController test_cases_time = format("%.3f", (Time.now.to_f - t1.to_f)).to_f if record.present? consume_time = format("%.3f", (Time.now - record.created_at)).to_f + uid_logger("11122233334444#{max_mem}, #{sec_key}") record.update_attributes!(:consume_time => consume_time, :git_pull => timeCost['pull'] , :create_pod => timeCost['createPod'], :pod_execute => timeCost['execute'], :test_cases => test_cases_time, :max_mem => max_mem, :brige => timeCost['evaluateAllTime'], :return_back => return_back_time) diff --git a/app/views/games/_testset_list.json.jbuilder b/app/views/games/_testset_list.json.jbuilder index 579adc3e6..e5cc76625 100644 --- a/app/views/games/_testset_list.json.jbuilder +++ b/app/views/games/_testset_list.json.jbuilder @@ -7,7 +7,7 @@ json.test_sets @qurey_test_sets do |test_set| json.actual_output evaluate_actual_output(test_set) end json.compile_success test_set.try(:compile_success) - json.ts_time test_set.ts_time + json.ts_time test_set.try(:ts_time) end json.allowed_unlock @shixun.test_set_permission From 718f94ac32db0576bbb9b0f81a1cde8cb9692e49 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 18 Jul 2019 16:53:17 +0800 Subject: [PATCH 24/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BA=B5=E5=8C=85?= =?UTF-8?q?=E5=92=8C=E6=95=99=E5=AD=A6=E6=A1=88=E4=BE=8B=E5=AF=BC=E8=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/get_navigation_info.json.jbuilder | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/users/get_navigation_info.json.jbuilder b/app/views/users/get_navigation_info.json.jbuilder index 586ddbd7c..96f54d3d0 100644 --- a/app/views/users/get_navigation_info.json.jbuilder +++ b/app/views/users/get_navigation_info.json.jbuilder @@ -13,6 +13,9 @@ json.top do json.message_url "#{@old_domain}#{@user_url}/user_tidings" json.new_message @new_message + json.moop_cases_url "#{@old_domain}/moop_cases" + json.crowdsourcing_url "#{@old_domain}/crowdsourcing" + json.career_url do json.array! @career.to_a do |c| if c[1].present?