Merge branch 'educoder' into develop

project_pack
cxt 5 years ago
commit 67363893f8

@ -1066,12 +1066,14 @@ class AccountController < ApplicationController
# end # end
elsif !User.current.user_extensions.school.nil? elsif !User.current.user_extensions.school.nil?
@tip = "申请已提交我们将在5分钟内完成审核" @tip = "申请已提交我们将在5分钟内完成审核"
unless apply_action.present? if !apply_action.present?
ApplyAction.create(:user_id => User.current.id, :status => 0, :ip_addr => request.remote_ip, :container_type => "TrialAuthorization", :apply_reason => params[:apply_reason]) ApplyAction.create(:user_id => User.current.id, :status => 0, :ip_addr => request.remote_ip, :container_type => "TrialAuthorization", :apply_reason => params[:apply_reason])
begin if user_ex.identity == 0 || user_ex.identity == 2
status = Trustie::Sms.send(mobile:17680641960, send_type:'user_apply_auth',name:'管理员' ) begin
rescue => e status = Trustie::Sms.send(mobile:17680641960, send_type:'user_apply_auth',name:'管理员' )
Rails.logger.error "发送验证码出错: #{e}" rescue => e
Rails.logger.error "发送验证码出错: #{e}"
end
end end
end end
end end

@ -79,89 +79,91 @@ class StudentWorkController < ApplicationController
@shixun = Shixun.select([:id, :gpid, :name]).find(HomeworkCommonsShixuns.where(:homework_common_id => @homework.id).pluck(:shixun_id).first) @shixun = Shixun.select([:id, :gpid, :name]).find(HomeworkCommonsShixuns.where(:homework_common_id => @homework.id).pluck(:shixun_id).first)
@challenges = Challenge.select([:id]).where(:shixun_id => @shixun.id) @challenges = Challenge.select([:id]).where(:shixun_id => @shixun.id)
@myshixun = @work.myshixun @myshixun = @work.myshixun
@games = Game.where(:myshixun_id => @myshixun.id).includes(:challenge, :game_codes,:outputs).reorder("challenges.position") # 页面循环需要outputs @games = Game.where(:myshixun_id => @myshixun.id).includes(:challenge, :game_codes, :outputs).reorder("challenges.position") # 页面循环需要outputs
# 用户个人信息 # 用户个人信息
@user_name = @work.user.show_real_name @user_name = @work.user.show_real_name
@student_id = @work.user.user_extensions.try(:student_id).nil? ? '--' : @work.user.user_extensions.try(:student_id) @student_id = @work.user.user_extensions.try(:student_id).nil? ? '--' : @work.user.user_extensions.try(:student_id)
student_works_user_id = StudentWork.where(:homework_common_id => @homework.id).pluck(:user_id) unless params[:pdf]
myshixuns = @shixun.myshixuns.where(:user_id => student_works_user_id).includes(games: [:outputs]) student_works_user_id = StudentWork.where(:homework_common_id => @homework.id).pluck(:user_id)
myshixuns = @shixun.myshixuns.where(:user_id => student_works_user_id).includes(:games)
# 课堂实训中,评测次数最大值
@total_evaluate_max = 0 # 课堂实训中,评测次数最大值
@user_evaluate_count = 0 @total_evaluate_max = 0
# 为了取最小efficiency。最小值是一个不确定数 @user_evaluate_count = 0
@min_efficiency = [] # 为了取最小efficiency。最小值是一个不确定数
power = [] @min_efficiency = []
@game_user_query = [] power = []
myshixuns.each do |myshixun| @game_user_query = []
# 用户个人实训总得分 myshixuns.each do |myshixun|
user_total_score = 0 # 用户个人实训总得分
# consume_time通关的关卡总耗时间all_tine实训的总耗时 user_total_score = 0
pass_consume_time = 0 # consume_time通关的关卡总耗时间all_tine实训的总耗时
all_time = 0 pass_consume_time = 0
# evaluate_count: 每次总评测次数eff_score用户得分/总评测次数round_sizelog(所有课堂实训最大评测次数/当前实训评测次数) all_time = 0
evaluate_count = 0 # evaluate_count: 每次总评测次数eff_score用户得分/总评测次数round_sizelog(所有课堂实训最大评测次数/当前实训评测次数)
eff_score = 0 evaluate_count = 0
eff_score = 0
myshixun.games.each do |game|
evaluate_count += game.outputs.first.try(:query_index).to_i # 评测次数 myshixun.games.each do |game|
# y_score = (evaluate_count == 0 ? 0 : (user_total_score / evaluate_count.to_f)) evaluate_count += game.evaluate_count.to_i # 评测次数
# eff_score = format("%.2f", y_score).to_f # y_score = (evaluate_count == 0 ? 0 : (user_total_score / evaluate_count.to_f))
if game.status == 2 # eff_score = format("%.2f", y_score).to_f
pass_consume_time += (game.cost_time / 60.0).to_f if game.status == 2
pass_consume_time += (game.cost_time / 60.0).to_f
end
all_time += (game.cost_time / 60.0).to_f
user_total_score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0
if myshixun.user_id == @work.user.id
@game_user_query << [game.id, game.evaluate_count.to_i]
end
end end
all_time += (game.cost_time / 60.0).to_f
user_total_score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0 # 当前用户评测最大次数
if myshixun.user_id == @work.user.id if myshixun.user_id == @work.user.id
@game_user_query << [game.id, game.outputs.first.try(:query_index).to_i] @user_evaluate_count = evaluate_count
end end
end
# 当前用户评测最大次数 x_time = (all_time <= 1) ? 1 : Math.log(all_time).to_f
if myshixun.user_id == @work.user.id consume_time = format("%.2f", x_time).to_f
@user_evaluate_count = evaluate_count
end
x_time = (all_time <= 1) ? 1 : Math.log(all_time).to_f
consume_time = format("%.2f", x_time).to_f
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0)) efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
efficiency = format("%.2f", efficiency).to_f efficiency = format("%.2f", efficiency).to_f
@min_efficiency << efficiency @min_efficiency << efficiency
@total_evaluate_max = @total_evaluate_max > evaluate_count.to_i ? @total_evaluate_max : evaluate_count @total_evaluate_max = @total_evaluate_max > evaluate_count.to_i ? @total_evaluate_max : evaluate_count
power << {:consume_time => consume_time, :evaluate_count => evaluate_count, :user_id => myshixun.user_id, power << {:consume_time => consume_time, :evaluate_count => evaluate_count, :user_id => myshixun.user_id,
:user_total_score => user_total_score, :efficiency => efficiency} :user_total_score => user_total_score, :efficiency => efficiency}
end end
# 数据库操作改成对数组操作 # 数据库操作改成对数组操作
min_efficiency = @min_efficiency.min min_efficiency = @min_efficiency.min
result_list = [] result_list = []
power.each do |p| power.each do |p|
y_score = (p[:evaluate_count] == 0 ? 0 : (p[:user_total_score] / p[:evaluate_count].to_f)) y_score = (p[:evaluate_count] == 0 ? 0 : (p[:user_total_score] / p[:evaluate_count].to_f))
eff_score = format("%.2f", y_score).to_f eff_score = format("%.2f", y_score).to_f
user_id = p[:user_id] user_id = p[:user_id]
consume_time = p[:consume_time] consume_time = p[:consume_time]
efficiency = p[:efficiency] < 0 ? format("%.2f", p[:efficiency] - min_efficiency).to_f : p[:efficiency] efficiency = p[:efficiency] < 0 ? format("%.2f", p[:efficiency] - min_efficiency).to_f : p[:efficiency]
round_size = (p[:evaluate_count] == 0 ? 0 : Math.log(@total_evaluate_max / p[:evaluate_count].to_f)) * 3.14 round_size = (p[:evaluate_count] == 0 ? 0 : Math.log(@total_evaluate_max / p[:evaluate_count].to_f)) * 3.14
result_list << {:eff_score => eff_score, :user_id => user_id, :consume_time => consume_time, :efficiency => efficiency, :round_size => round_size} result_list << {:eff_score => eff_score, :user_id => user_id, :consume_time => consume_time, :efficiency => efficiency, :round_size => round_size}
end end
@power = [] @power = []
@efficiency = [] @efficiency = []
result_list.sort{|x, y| x[:efficiency] <=> y[:efficiency]}.each_with_index do |result, index| result_list.sort{|x, y| x[:efficiency] <=> y[:efficiency]}.each_with_index do |result, index|
@efficiency << [index+1, result[:efficiency], result[:user_id]] @efficiency << [index+1, result[:efficiency], result[:user_id]]
if result[:user_id] == @work.user.id if result[:user_id] == @work.user.id
@myself_eff = [index+1, result[:efficiency]] @myself_eff = [index+1, result[:efficiency]]
@myself_power = [result[:consume_time], result[:eff_score], result[:round_size]] @myself_power = [result[:consume_time], result[:eff_score], result[:round_size]]
end
end end
end
result_list.sort{|x, y| x[:consume_time] <=> y[:consume_time]}.each do |result| result_list.sort{|x, y| x[:consume_time] <=> y[:consume_time]}.each do |result|
@power << [result[:consume_time], result[:eff_score], result[:round_size], result[:user_id]] @power << [result[:consume_time], result[:eff_score], result[:round_size], result[:user_id]]
end
end end

Loading…
Cancel
Save