实训作业的调分

issues25489
cxt 5 years ago
parent 898c43e782
commit f47dbb2c27

@ -1512,7 +1512,7 @@ class HomeworkCommonsController < ApplicationController
end_time = game.end_time end_time = game.end_time
# 用户关卡的得分 # 用户关卡的得分
all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f all_score = homework_challenge_settings.find_by(challenge_id: challenge.id).try(:score).to_f
final_score = @student_work.work_challenge_score game, all_score final_score = @student_work.work_challenge_score game, all_score, challenge.id
# 抄袭用户 # 抄袭用户
copy_user = User.find_by_id(game_codes[0].try(:target_user_id)) copy_user = User.find_by_id(game_codes[0].try(:target_user_id))
copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present? copy_end_time = copy_user.games.find_by(challenge_id: challenge.id).try(:end_time) if copy_user.present?

@ -464,6 +464,7 @@ class StudentWorksController < ApplicationController
@shixun = @homework.shixuns.take @shixun = @homework.shixuns.take
# 提示: 这里如果includes outputs表的话 sum(:evaluate_count)会出现错误 # 提示: 这里如果includes outputs表的话 sum(:evaluate_count)会出现错误
@games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun @games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun
@challenges = @shixun.challenges if @shixun
@comment = @work.shixun_work_comments.find_by(challenge_id: 0) @comment = @work.shixun_work_comments.find_by(challenge_id: 0)
# 用户最大评测次数 # 用户最大评测次数
@ -517,6 +518,7 @@ class StudentWorksController < ApplicationController
@user = @work.user @user = @work.user
@shixun = @homework.shixuns.take @shixun = @homework.shixuns.take
@games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun @games = @work.myshixun.games.includes(:challenge, :game_codes, :outputs) if @work.myshixun
@challenges = @shixun.challenges if @shixun
# 用户最大评测次数 # 用户最大评测次数
@user_evaluate_count = @games.pluck(:evaluate_count).sum if @games @user_evaluate_count = @games.pluck(:evaluate_count).sum if @games
@ -727,7 +729,11 @@ class StudentWorksController < ApplicationController
challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score], challenge_score = @work.challenge_work_scores.create(challenge_id: params[:challenge_id], user_id: current_user.id, score: params[:score],
comment: comment) comment: comment)
challenge_score.create_tiding current_user.id challenge_score.create_tiding current_user.id
HomeworksService.new.update_myshixun_work_score @work, @work&.myshixun, @work&.myshixun&.games, @homework, @homework.homework_challenge_settings if @work.work_status != 0 && @work.myshixun
HomeworksService.new.update_myshixun_work_score @work, @work.myshixun, @work.myshixun&.games, @homework, @homework.homework_challenge_settings
else
update_none_commit_work @work, @homework
end
rescue Exception => e rescue Exception => e
uid_logger(e.message) uid_logger(e.message)
tip_exception(e.message) tip_exception(e.message)
@ -855,4 +861,20 @@ class StudentWorksController < ApplicationController
end end
end end
end end
def update_none_commit_work work, homework
if work.work_status == 0
work.work_status = 1
work.commit_time = homework.end_time
work.update_time = Time.now
end
final_score = 0
homework.homework_challenge_settings.each do |cha_setting|
adjust_score = work.challenge_work_scores.select{|work_score| work_score.challenge_id == cha_setting.challenge_id}.last
final_score += adjust_score.score if adjust_score.present?
end
work.final_score = final_score
work.work_score = final_score
work.save!
end
end end

@ -19,7 +19,7 @@ module StudentWorksHelper
# 作业的开启时间 # 作业的开启时间
def myshixun_open_time game def myshixun_open_time game
game.open_time ? (format_time game.open_time) : "--" game&.open_time ? (format_time game.open_time) : "--"
end end
# 作业完成时间 # 作业完成时间
@ -29,7 +29,7 @@ module StudentWorksHelper
# 作业耗时 # 作业耗时
def time_consuming game def time_consuming game
game.end_time.blank? ? "--" : (game_spend_time game.cost_time) game&.end_time.blank? ? "--" : (game_spend_time game.cost_time)
end end
# 用户个人实训总得分user_total_score # 用户个人实训总得分user_total_score

@ -196,12 +196,12 @@ class StudentWork < ApplicationRecord
student_works_scores.where.not(reviewer_role: 3, score: nil).exists? student_works_scores.where.not(reviewer_role: 3, score: nil).exists?
end end
def work_challenge_score game, score def work_challenge_score game, score, challenge_id
game_score = 0 game_score = 0
adjust_score = challenge_work_scores.where(challenge_id: game.challenge_id).last adjust_score = challenge_work_scores.where(challenge_id: challenge_id).last
if adjust_score.present? if adjust_score.present?
game_score = adjust_score.score game_score = adjust_score.score
else elsif game.present?
setting = homework_common.homework_group_setting game.user_id setting = homework_common.homework_group_setting game.user_id
if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time)) if game.status == 2 && ((game.end_time && game.end_time < setting.end_time) || (homework_common.allow_late && game.end_time && game.end_time < homework_common.late_time))
answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation answer_open_evaluation = homework_common.homework_detail_manual.answer_open_evaluation

@ -76,22 +76,23 @@
<th>调分</th> <th>调分</th>
</thead> </thead>
<tbody> <tbody>
<% @games.each_with_index do |game, index| %> <% @challenges.each_with_index do |challenge, index| %>
<% challenge_score = @homework.challenge_score game.challenge_id %> <% challenge_score = @homework.challenge_score challenge.id %>
<% game_score = @work.work_challenge_score game, challenge_score %> <% game = @games.select{|game| game.challenge_id == challenge.id}.first if @games %>
<% game_score = @work.work_challenge_score game, challenge_score, challenge.id %>
<tr> <tr>
<td><%= index + 1 %></td> <td><%= index + 1 %></td>
<td style="text-align: left;"> <td style="text-align: left;">
<span class="task-hide edu-info-dark fl"><%= game.challenge.subject %></span> <span class="task-hide edu-info-dark fl"><%= challenge.subject %></span>
<% if ((Time.now > @homework.end_time) && game.end_time.blank?) || (game.end_time.present? && game.end_time > @homework.end_time) %> <% if game && (((Time.now > @homework.end_time) && game.end_time.blank?) || (game.end_time.present? && game.end_time > @homework.end_time)) %>
<span class="delay ml10">延时</span> <span class="delay ml10">延时</span>
<% end %> <% end %>
</td> </td>
<td><%= myshixun_open_time(game) %></td> <td><%= myshixun_open_time(game) %></td>
<td><%= game.evaluate_count %></td> <td><%= game ? game&.evaluate_count : 0 %></td>
<td><%= finished_time game.end_time %></td> <td><%= game ? finished_time(game.end_time) : "--" %></td>
<td><%= ApplicationController.helpers.time_consuming game %></td> <td><%= ApplicationController.helpers.time_consuming game %></td>
<td><%= game.final_score %> / <%= game.challenge.all_score %></td> <td><%= game ? game.final_score : 0 %> / <%= challenge.all_score %></td>
<td><span class="color-orange"><%= game_score %></span> / <%= challenge_score %></td> <td><span class="color-orange"><%= game_score %></span> / <%= challenge_score %></td>
<td><%= game_score %></td> <td><%= game_score %></td>
</tr> </tr>

@ -22,25 +22,26 @@ if @shixun
# 阶段成绩 # 阶段成绩
json.stage_list do json.stage_list do
json.array! @games do |game| json.array! @challenges do |challenge|
json.name game.challenge.subject json.name challenge.subject
json.is_delay student_work_is_delay?(@homework, game) game = @games.select{|game| game.challenge_id == challenge.id}.first if @games
json.is_delay game ? student_work_is_delay?(@homework, game) : false
json.open_time myshixun_open_time game json.open_time myshixun_open_time game
json.evaluate_count game.evaluate_count json.evaluate_count game ? game&.evaluate_count : 0
json.finished_time finished_time game.end_time json.finished_time game ? finished_time game.end_time : "--"
json.time_consuming time_consuming game json.time_consuming time_consuming game
json.myself_experience game.final_score json.myself_experience game ? game&.final_score : 0
json.experience game.challenge.all_score json.experience challenge.all_score
json.complete_status game_status(game, @homework) json.complete_status game ? game_status(game, @homework) : 0
json.challenge_id game.challenge_id json.challenge_id challenge.id
challenge_score = @homework.challenge_score game.challenge_id challenge_score = @homework.challenge_score challenge.id
json.game_score_full challenge_score json.game_score_full challenge_score
json.game_score @work.work_challenge_score game, challenge_score json.game_score @work.work_challenge_score game, challenge_score, challenge.id
challenge_comment = @work.shixun_work_comments.find_by(challenge_id: game.challenge_id) challenge_comment = @work.shixun_work_comments.find_by(challenge_id: challenge.id)
json.challenge_comment challenge_comment&.comment json.challenge_comment challenge_comment&.comment
json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil json.challenge_comment_hidden @user_course_identity < Course::STUDENT ? challenge_comment&.hidden_comment : nil
json.comment_id challenge_comment&.id json.comment_id challenge_comment&.id
json.view_answer game.answer_open != 0 json.view_answer game ? game.answer_open != 0 : 0
end end
end end

Loading…
Cancel
Save