|
|
|
@ -458,7 +458,7 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
@shixun = @homework.shixuns.take
|
|
|
|
|
# 提示: 这里如果includes outputs表的话: sum(:evaluate_count)会出现错误
|
|
|
|
|
@games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun
|
|
|
|
|
@comment = @work.student_works_scores.shixun_comment.first
|
|
|
|
|
@comment = @work.shixun_work_comments.find_by(challenge_id: 0)
|
|
|
|
|
|
|
|
|
|
# 用户最大评测次数
|
|
|
|
|
if @games
|
|
|
|
@ -474,19 +474,29 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 实训作品的评阅
|
|
|
|
|
def shixun_work_comment
|
|
|
|
|
tip_exception("评阅不能为空") if params[:comment].blank?
|
|
|
|
|
tip_exception("缺少is_hidden参数") if params[:is_hidden].blank? || ![1, 0].include?(params[:is_hidden])
|
|
|
|
|
comment = @work.student_works_scores.shixun_comment.first || StudentWorksScore.new(student_work_id: @work.id, user_id: current_user.id)
|
|
|
|
|
comment.comment = params[:comment]
|
|
|
|
|
comment.is_hidden = params[:is_hidden]
|
|
|
|
|
comment.save!
|
|
|
|
|
normal_status("评阅成功")
|
|
|
|
|
tip_exception("请至少输入一个评阅") if params[:comment].blank? && params[:hidden_comment].blank?
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
challenge = @homework.shixuns.first&.challenges.find_by(id: params[:challenge_id]) unless params[:challenge_id].blank?
|
|
|
|
|
if challenge.present?
|
|
|
|
|
comment = @work.shixun_work_comments.find_by(challenge_id: challenge.id) ||
|
|
|
|
|
ShixunWorkComment.new(student_work_id: @work.id, user_id: current_user.id, challenge_id: challenge.id)
|
|
|
|
|
else
|
|
|
|
|
comment = @work.shixun_work_comments.find_by(challenge_id: 0) ||
|
|
|
|
|
ShixunWorkComment.new(student_work_id: @work.id, user_id: current_user.id, challenge_id: 0)
|
|
|
|
|
end
|
|
|
|
|
comment.comment = params[:comment]
|
|
|
|
|
comment.hidden_comment = params[:hidden_comment]
|
|
|
|
|
comment.save!
|
|
|
|
|
normal_status("评阅成功")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 删除实训作品评阅
|
|
|
|
|
def destroy_work_comment
|
|
|
|
|
@work.student_works_scores.shixun_comment.first.destroy! if @work.student_works_scores.shixun_comment.first.present?
|
|
|
|
|
normal_status("删除成功")
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
@work.shixun_work_comments.find_by!(id: params[:comment_id]).destroy_all
|
|
|
|
|
normal_status("删除成功")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def export_shixun_work_report
|
|
|
|
|