diff --git a/app/controllers/competitions_controller.rb b/app/controllers/competitions_controller.rb index e6112539..071cd200 100644 --- a/app/controllers/competitions_controller.rb +++ b/app/controllers/competitions_controller.rb @@ -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] @@ -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] @@ -741,11 +741,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 = challenges.size / 3 #每个实训的关卡数 + length = challenge_count #每个实训的关卡数 for i in 1..length score = 0 time = 0 diff --git a/app/views/competitions/charts.html.erb b/app/views/competitions/charts.html.erb index 29a24b35..723f54e9 100644 --- a/app/views/competitions/charts.html.erb +++ b/app/views/competitions/charts.html.erb @@ -1,4 +1,4 @@ -<% if @competition.identifier == 'hn' || @competition.identifier == 'gcc-dev-2018' || @competition.identifier == "gcc-annotation-2018" %> +<% if @competition.identifier == 'hn' || @competition.identifier == 'gcc-dev-2018' || @competition.identifier == "gcc-annotation-2018" || @competition.identifier == "gcc-task-2019" %>