Merge branch 'educoder' into develop

project_pack
cxt 5 years ago
commit 67363893f8

@ -1066,12 +1066,14 @@ class AccountController < ApplicationController
# end
elsif !User.current.user_extensions.school.nil?
@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])
begin
status = Trustie::Sms.send(mobile:17680641960, send_type:'user_apply_auth',name:'管理员' )
rescue => e
Rails.logger.error "发送验证码出错: #{e}"
if user_ex.identity == 0 || user_ex.identity == 2
begin
status = Trustie::Sms.send(mobile:17680641960, send_type:'user_apply_auth',name:'管理员' )
rescue => e
Rails.logger.error "发送验证码出错: #{e}"
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)
@challenges = Challenge.select([:id]).where(:shixun_id => @shixun.id)
@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
@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)
myshixuns = @shixun.myshixuns.where(:user_id => student_works_user_id).includes(games: [:outputs])
# 课堂实训中,评测次数最大值
@total_evaluate_max = 0
@user_evaluate_count = 0
# 为了取最小efficiency。最小值是一个不确定数
@min_efficiency = []
power = []
@game_user_query = []
myshixuns.each do |myshixun|
# 用户个人实训总得分
user_total_score = 0
# consume_time通关的关卡总耗时间all_tine实训的总耗时
pass_consume_time = 0
all_time = 0
# evaluate_count: 每次总评测次数eff_score用户得分/总评测次数round_sizelog(所有课堂实训最大评测次数/当前实训评测次数)
evaluate_count = 0
eff_score = 0
myshixun.games.each do |game|
evaluate_count += game.outputs.first.try(:query_index).to_i # 评测次数
# y_score = (evaluate_count == 0 ? 0 : (user_total_score / evaluate_count.to_f))
# eff_score = format("%.2f", y_score).to_f
if game.status == 2
pass_consume_time += (game.cost_time / 60.0).to_f
unless params[:pdf]
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
# 为了取最小efficiency。最小值是一个不确定数
@min_efficiency = []
power = []
@game_user_query = []
myshixuns.each do |myshixun|
# 用户个人实训总得分
user_total_score = 0
# consume_time通关的关卡总耗时间all_tine实训的总耗时
pass_consume_time = 0
all_time = 0
# evaluate_count: 每次总评测次数eff_score用户得分/总评测次数round_sizelog(所有课堂实训最大评测次数/当前实训评测次数)
evaluate_count = 0
eff_score = 0
myshixun.games.each do |game|
evaluate_count += game.evaluate_count.to_i # 评测次数
# y_score = (evaluate_count == 0 ? 0 : (user_total_score / evaluate_count.to_f))
# eff_score = format("%.2f", y_score).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
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.outputs.first.try(:query_index).to_i]
@user_evaluate_count = evaluate_count
end
end
# 当前用户评测最大次数
if myshixun.user_id == @work.user.id
@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
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 = format("%.2f", efficiency).to_f
@min_efficiency << efficiency
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
efficiency = format("%.2f", efficiency).to_f
@min_efficiency << efficiency
@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,
:user_total_score => user_total_score, :efficiency => efficiency}
end
@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,
:user_total_score => user_total_score, :efficiency => efficiency}
end
# 数据库操作改成对数组操作
min_efficiency = @min_efficiency.min
result_list = []
power.each do |p|
y_score = (p[:evaluate_count] == 0 ? 0 : (p[:user_total_score] / p[:evaluate_count].to_f))
eff_score = format("%.2f", y_score).to_f
# 数据库操作改成对数组操作
min_efficiency = @min_efficiency.min
result_list = []
power.each do |p|
y_score = (p[:evaluate_count] == 0 ? 0 : (p[:user_total_score] / p[:evaluate_count].to_f))
eff_score = format("%.2f", y_score).to_f
user_id = p[:user_id]
consume_time = p[:consume_time]
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
result_list << {:eff_score => eff_score, :user_id => user_id, :consume_time => consume_time, :efficiency => efficiency, :round_size => round_size}
end
user_id = p[:user_id]
consume_time = p[:consume_time]
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
result_list << {:eff_score => eff_score, :user_id => user_id, :consume_time => consume_time, :efficiency => efficiency, :round_size => round_size}
end
@power = []
@efficiency = []
result_list.sort{|x, y| x[:efficiency] <=> y[:efficiency]}.each_with_index do |result, index|
@efficiency << [index+1, result[:efficiency], result[:user_id]]
if result[:user_id] == @work.user.id
@myself_eff = [index+1, result[:efficiency]]
@myself_power = [result[:consume_time], result[:eff_score], result[:round_size]]
@power = []
@efficiency = []
result_list.sort{|x, y| x[:efficiency] <=> y[:efficiency]}.each_with_index do |result, index|
@efficiency << [index+1, result[:efficiency], result[:user_id]]
if result[:user_id] == @work.user.id
@myself_eff = [index+1, result[:efficiency]]
@myself_power = [result[:consume_time], result[:eff_score], result[:round_size]]
end
end
end
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]]
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]]
end
end

Loading…
Cancel
Save