|
|
@ -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)
|
|
|
|
# 当前用户评测最大次数
|
|
|
|
myshixuns = @shixun.myshixuns.where(:user_id => student_works_user_id).includes(games: [:outputs])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 课堂实训中,评测次数最大值
|
|
|
|
|
|
|
|
@total_evaluate_max = 0
|
|
|
|
|
|
|
|
@user_evaluate_count = 0
|
|
|
|
@user_evaluate_count = 0
|
|
|
|
# 为了取最小efficiency。最小值是一个不确定数
|
|
|
|
if @myshixun.user_id == @work.user.id
|
|
|
|
@min_efficiency = []
|
|
|
|
@user_evaluate_count = @myshixun.games.pluck(:evaluate_count).sum.to_i
|
|
|
|
power = []
|
|
|
|
end
|
|
|
|
@game_user_query = []
|
|
|
|
|
|
|
|
myshixuns.each do |myshixun|
|
|
|
|
unless params[:pdf]
|
|
|
|
# 用户个人实训总得分
|
|
|
|
student_works_user_id = StudentWork.where(:homework_common_id => @homework.id).pluck(:user_id)
|
|
|
|
user_total_score = 0
|
|
|
|
myshixuns = @shixun.myshixuns.where(:user_id => student_works_user_id).includes(:games)
|
|
|
|
# consume_time通关的关卡总耗时间;all_tine实训的总耗时
|
|
|
|
|
|
|
|
pass_consume_time = 0
|
|
|
|
# 课堂实训中,评测次数最大值
|
|
|
|
all_time = 0
|
|
|
|
@total_evaluate_max = 0
|
|
|
|
# evaluate_count: 每次总评测次数;eff_score:用户得分/总评测次数;round_size:log(所有课堂实训最大评测次数/当前实训评测次数)
|
|
|
|
# 为了取最小efficiency。最小值是一个不确定数
|
|
|
|
evaluate_count = 0
|
|
|
|
@min_efficiency = []
|
|
|
|
eff_score = 0
|
|
|
|
power = []
|
|
|
|
|
|
|
|
@game_user_query = []
|
|
|
|
myshixun.games.each do |game|
|
|
|
|
myshixuns.each do |myshixun|
|
|
|
|
evaluate_count += game.outputs.first.try(:query_index).to_i # 评测次数
|
|
|
|
# 用户个人实训总得分
|
|
|
|
# y_score = (evaluate_count == 0 ? 0 : (user_total_score / evaluate_count.to_f))
|
|
|
|
user_total_score = 0
|
|
|
|
# eff_score = format("%.2f", y_score).to_f
|
|
|
|
# consume_time通关的关卡总耗时间;all_tine实训的总耗时
|
|
|
|
if game.status == 2
|
|
|
|
pass_consume_time = 0
|
|
|
|
pass_consume_time += (game.cost_time / 60.0).to_f
|
|
|
|
all_time = 0
|
|
|
|
end
|
|
|
|
# evaluate_count: 每次总评测次数;eff_score:用户得分/总评测次数;round_size:log(所有课堂实训最大评测次数/当前实训评测次数)
|
|
|
|
all_time += (game.cost_time / 60.0).to_f
|
|
|
|
evaluate_count = 0
|
|
|
|
user_total_score += game.status == 2 ? game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i : 0
|
|
|
|
eff_score = 0
|
|
|
|
if myshixun.user_id == @work.user.id
|
|
|
|
|
|
|
|
@game_user_query << [game.id, game.outputs.first.try(:query_index).to_i]
|
|
|
|
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
|
|
|
|
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
|
|
|
|
x_time = (all_time <= 1) ? 1 : Math.log(all_time).to_f
|
|
|
|
consume_time = format("%.2f", x_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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|