@ -246,14 +246,14 @@ class CompetitionsController < ApplicationController
# 第一阶段的得分和耗时
challenges_1 = Challenge . where ( :shixun_id = > shixun1_id )
challenge_rate1 = 0 . 5
result1 = chart_exp_score_pre user_ids , s1_time , e1_time , challenges_1 , challenge_rate1
result1 = chart_exp_score_pre user_ids , s1_time , e1_time , challenges_1 , challenge_rate1 , 3
score1 = result1 [ 0 ]
time1 = result1 [ 1 ]
# 第二阶段的得分和耗时
challenge_rate2 = 1 . 0
challenges_2 = Challenge . where ( :shixun_id = > shixun2_id )
result2 = chart_exp_score_pre user_ids , s2_time , e2_time , challenges_2 , challenge_rate2
result2 = chart_exp_score_pre user_ids , s2_time , e2_time , challenges_2 , challenge_rate2 , 3
score2 = result2 [ 0 ]
time2 = result2 [ 1 ]
@ -322,7 +322,7 @@ class CompetitionsController < ApplicationController
# 'nyog9r7c','yugrij4n','48flws5g','bfgau7s6','mfv6zrj7','f398leqr','qwaffs2p','ose7482b','y5wh2ofx'
# 预赛的实训id 第一阶段: 1185, 1197, 1195 第二阶段: 1202, 1210, 1207 第三阶段: 1254, 1255, 1243
shixun1_id = [ 2303 ]
shixun2_id = [ 2994 , 3012 , 30 1 4]
shixun2_id = [ 2994 , 3012 , 30 2 4]
shixun3_id = [ 2944 , 2938 , 2943 ]
elsif @type == " 决赛 "
# '92b7vt8x','a7fxenvc','wt2xfzny','xa4m9cng','tng6heyf','am5o73er','9fla2zry','fzp3iu4w','qlsy6xb4'
@ -346,15 +346,15 @@ class CompetitionsController < ApplicationController
user_ids = team . team_members . where ( :is_teacher = > 0 ) . pluck ( :user_id )
# 第一阶段的得分和耗时
challenges_1 = Challenge . where ( :shixun_id = > shixun1_id )
challenge_rate1 = 0. 5
result1 = chart_exp_score_pre user_ids , s1_time , e1_time , challenges_1 , challenge_rate1
challenge_rate1 = 1. 0
result1 = chart_exp_score_pre user_ids , s1_time , e1_time , challenges_1 , challenge_rate1 , 2
score1 = result1 [ 0 ]
time1 = result1 [ 1 ]
# 第二阶段的得分和耗时
challenge_rate2 = 1 . 0
challenges_2 = Challenge . where ( :shixun_id = > shixun2_id )
result2 = chart_exp_score_pre user_ids , s2_time , e2_time , challenges_2 , challenge_rate2
result2 = chart_exp_score_pre user_ids , s2_time , e2_time , challenges_2 , challenge_rate2 , 2
score2 = result2 [ 0 ]
time2 = result2 [ 1 ]
@ -452,8 +452,10 @@ class CompetitionsController < ApplicationController
sheet1 [ count_row , 11 ] = com_spend_time user [ :s_spend_time ] . to_i
count_row += 1
end
elsif @competition . identifier == " gcc-dev-2018 "
elsif @competition . identifier == " gcc-dev-2018 " || @competition . identifier == " gcc-task-2019 "
records = @competition . competition_teams
f_rate = @competition . identifier == " gcc-dev-2018 " ? 0 . 85 : 0 . 8
p_rate = @competition . identifier == " gcc-dev-2018 " ? 0 . 15 : 0 . 2
records . each do | team |
# 决赛记录
f_score = team . competition_scores . where ( :competition_stage_id = > @competition . competition_stages . where ( :name = > " 决赛 " ) . first . try ( :id ) ) . first
@ -463,7 +465,7 @@ class CompetitionsController < ApplicationController
team [ :p_time ] = p_score . try ( :cost_time )
team [ :f_score ] = f_score . try ( :score )
team [ :f_time ] = f_score . try ( :cost_time )
team [ :s_score ] = ( f_score . try ( :score ) . to_f * 0 . 85 + p_score . try ( :score ) . to_f * 0 . 15 ) . try ( :round , 2 )
team [ :s_score ] = ( f_score . try ( :score ) . to_f * f_rate + p_score . try ( :score ) . to_f * p_rate ) . try ( :round , 2 )
team [ :s_spend_time ] = f_score . try ( :cost_time ) . to_i + p_score . try ( :cost_time ) . to_i
end
records = records . sort do | a , b |
@ -741,11 +743,12 @@ class CompetitionsController < ApplicationController
# challenges 每阶段三个实训的所有关卡
# s_time 阶段开始时间 e_time 阶段结束时间
# rate 关卡经验值与分数的比值
# challenge_count 每个实训的关卡数
# 对三个实训的所有关卡循环: 找到在比赛时间内通关的最低耗时
def chart_exp_score_pre user_ids , s_time , e_time , challenges , rate
def chart_exp_score_pre user_ids , s_time , e_time , challenges , rate , challenge_count
total_score = 0
total_time = 0
length = challenge s. size / 3 #每个实训的关卡数
length = challenge _count #每个实训的关卡数
for i in 1 .. length
score = 0
time = 0