|
|
|
@ -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_size:log(所有课堂实训最大评测次数/当前实训评测次数)
|
|
|
|
|
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
|
|
|
|
|
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]
|
|
|
|
|
if @myshixun.user_id == @work.user.id
|
|
|
|
|
@user_evaluate_count = @myshixun.games.pluck(:evaluate_count).sum.to_i
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
# 为了取最小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_size:log(所有课堂实训最大评测次数/当前实训评测次数)
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|