dev_local
杨树明 6 years ago
commit 21de026a99

@ -6817,68 +6817,70 @@ end
# 用户评测时更新实训作业成绩
def update_myshixun_work_score myshixun
student_works = myshixun.student_works
#logger.info("#############student_works_count: #{student_works.count}")
if student_works.count > 0
student_works.each do |work|
homework = work.homework_common
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
#logger.info("#############member_course_group_id: #{member.try(:course_group_id)}")
setting_time = homework_group_setting homework, member.try(:course_group_id)
if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && !homework.course.is_end))
#logger.info("#############setting_time: #{setting_time.end_time}")
user_total_score = 0
pass_consume_time = 0
final_score = 0
homework.homework_challenge_settings.each do |setting|
game = myshixun.games.where(:challenge_id => setting.challenge_id, :status => 2).first
unless game.nil?
pass_consume_time += (game.cost_time / 60.0).to_f
user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last
final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score >= 0 ? setting.score : 0))
ActiveRecord::Base.transaction do
student_works = myshixun.student_works
#logger.info("#############student_works_count: #{student_works.count}")
if student_works.count > 0
student_works.each do |work|
homework = work.homework_common
member = Member.find_by_sql("select course_group_id from members where course_id = #{homework.course_id} and user_id = #{User.current.id}").first
#logger.info("#############member_course_group_id: #{member.try(:course_group_id)}")
setting_time = homework_group_setting homework, member.try(:course_group_id)
if setting_time.end_time.present? && (setting_time.end_time > Time.now || (homework.allow_late && !homework.course.is_end))
#logger.info("#############setting_time: #{setting_time.end_time}")
user_total_score = 0
pass_consume_time = 0
final_score = 0
homework.homework_challenge_settings.each do |setting|
game = myshixun.games.where(:challenge_id => setting.challenge_id, :status => 2).first
unless game.nil?
pass_consume_time += (game.cost_time / 60.0).to_f
user_total_score += game.final_score.to_i < 0 ? 0 : game.challenge.score.to_i
adjust_score = work.challenge_work_scores.where(:challenge_id => setting.challenge_id).last
final_score += adjust_score.present? ? adjust_score.score : (homework.homework_detail_manual.answer_open_evaluation ? setting.score : (game.final_score >= 0 ? setting.score : 0))
end
end
if work.work_status == 0
is_complete = myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)
work.work_status = setting_time.end_time > Time.now ? 1 : (is_complete ? 1 : 2)
work.late_penalty = setting_time.end_time > Time.now ? 0 : (is_complete ? 0 : homework.late_penalty)
work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at
work.myshixun_id = myshixun.id
end
end
if work.work_status == 0
is_complete = myshixun.is_complete? && (myshixun.done_time < setting_time.end_time)
work.work_status = setting_time.end_time > Time.now ? 1 : (is_complete ? 1 : 2)
work.late_penalty = setting_time.end_time > Time.now ? 0 : (is_complete ? 0 : homework.late_penalty)
work.commit_time = myshixun.created_at > setting_time.publish_time ? setting_time.publish_time : myshixun.created_at
work.myshixun_id = myshixun.id
end
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
work.efficiency = format("%.2f", efficiency)
games = myshixun.games.where(:challenge_id => homework.homework_challenge_settings.map(&:challenge_id))
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
if myshixun_endtime.present?
min_efficiency_changed = min_efficiency_changed.present? ? min_efficiency_changed : false
work.compelete_status = 1
work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i
# 计算作品的效率分(已完成才计算)
if homework.work_efficiency
# 如果作业的最大效率值有变更则更新所有作品的效率分
if homework.max_efficiency < work.efficiency
homework.max_efficiency = work.efficiency
homework.update_column("max_efficiency", homework.max_efficiency)
update_student_eff_score homework
efficiency = (pass_consume_time == 0 ? 0 : Math.log((user_total_score / pass_consume_time.to_f) + 1.0))
work.efficiency = format("%.2f", efficiency)
games = myshixun.games.where(:challenge_id => homework.homework_challenge_settings.map(&:challenge_id))
myshixun_endtime = games.select{|game| game.status == 2}.size == games.size ? games.map(&:end_time).max : nil
if myshixun_endtime.present?
min_efficiency_changed = min_efficiency_changed.present? ? min_efficiency_changed : false
work.compelete_status = 1
work.cost_time = myshixun_endtime.to_i - setting_time.publish_time.to_i
# 计算作品的效率分(已完成才计算)
if homework.work_efficiency
# 如果作业的最大效率值有变更则更新所有作品的效率分
if homework.max_efficiency < work.efficiency
homework.max_efficiency = work.efficiency
homework.update_column("max_efficiency", homework.max_efficiency)
update_student_eff_score homework
end
eff_score = homework.max_efficiency == 0 ? 0 : work.efficiency / homework.max_efficiency * homework.eff_score
work.eff_score = format("%.2f", eff_score)
end
eff_score = homework.max_efficiency == 0 ? 0 : work.efficiency / homework.max_efficiency * homework.eff_score
work.eff_score = format("%.2f", eff_score)
end
end
work.update_time = Time.now
work.update_time = Time.now
# 为迁移的数据做特殊处理, 若分数小于当前通关分数则不更新
work.final_score = final_score if work.final_score.nil? || final_score > work.final_score
score = work.final_score + work.eff_score - work.late_penalty
work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score
#logger.info("#############work_score: #{score}")
work.save!
# 为迁移的数据做特殊处理, 若分数小于当前通关分数则不更新
work.final_score = final_score if work.final_score.nil? || final_score > work.final_score
score = work.final_score + work.eff_score - work.late_penalty
work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) unless work.ultimate_score
#logger.info("#############work_score: #{score}")
work.save!
end
end
end
end

@ -1,8 +1,6 @@
<div class="bor-bottom-greyE clearfix pl20 pr20 pt40 pb20 edu-back-white challengeNav">
<a href="<%= shixun_challenges_url(@shixun) %>" class="<%= params[:action] == "index" ? "active" : "" %> fl mr40">任务</a>
<% if @shixun.propaedeutics.present? %>
<a href="<%= propaedeutics_shixun_path(@shixun) %>" class="<%= params[:action] == "propaedeutics" ? "active" : "" %> fl mr40">背景知识</a>
<% end %>
<% if User.current.manager_of_shixun?(@shixun) %>
<%= link_to l(:project_module_repository),
({:controller => 'repositories',

@ -6,9 +6,12 @@
<%= image_tag(url_to_avatar(member.user), :width =>"80", :height => "80", :class => "radius", :alt=>"头像") %>
</a>
<div class="fl ml15 flex1">
<p class="mb10 mt5"><%= member.user.try(:show_name) %></p>
<div class="clearfix">
<p class="color-grey-9 font-12 fl"><span class="mr10"><%= member.user.school_name %></span><span><%= member.user.identity == "学生" ? "" : member.user.identity %></span></p>
<p class="mb10 mt5"><%= member.user.try(:show_name) %> <span><%= member.user.identity == "学生" ? "" : member.user.identity %></span></p>
<div class="clearfix ml3">
<p class="color-grey-9 font-12 fl">
<!-- <span class="mr10"><%#= member.user.school_name %></span>-->
</p>
<!--<a href="JavaScript:void(0)" class="edu-default-btn edu-focus-btn fr color-grey-6">关注</a>-->
</div>
</div>

Loading…
Cancel
Save