实训报告新增评阅

dev_aliyun_beta
cxt 6 years ago
parent 0ae7984358
commit c8c4dc0359

@ -8,12 +8,15 @@ class StudentWorksController < ApplicationController
before_action :find_work, only: [:shixun_work_report, :adjust_review_score, :shixun_work, :commit_des, :update_des,
:adjust_score, :show, :adjust_score, :supply_attachments, :revise_attachment,
:comment_list, :add_score, :add_score_reply, :destroy_score, :appeal_anonymous_score,
:deal_appeal_score, :cancel_appeal, :edit, :update, :export_shixun_work_report]
:deal_appeal_score, :cancel_appeal, :edit, :update, :export_shixun_work_report,
:shixun_work_comment, :destroy_work_comment]
before_action :user_course_identity
before_action :allow_add_score, only: [:add_score]
before_action :homework_publish
before_action :teacher_allowed, only: [:adjust_score, :adjust_review_score, :deal_appeal_score]
before_action :teacher_allowed, only: [:adjust_score, :adjust_review_score, :deal_appeal_score, :shixun_work_comment,
:destroy_work_comment]
before_action :course_student, only: [:new, :commit_des, :update_des, :create, :edit, :update, :search_member_list, :relate_project,
:cancel_relate_project, :relate_project, :delete_work]
@ -455,6 +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
# 用户最大评测次数
if @games
@ -468,6 +472,23 @@ class StudentWorksController < ApplicationController
@echart_data = student_efficiency(@homework, @work)
end
# 实训作品的评阅
def shixun_work_comment
tip_exception("评阅不能为空") if params[:comment].blank?
tip_exception("缺少is_hidden参数") if params[:is_hidden].blank? || ![true, false].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("评阅成功")
end
# 删除实训作品评阅
def destroy_work_comment
@work.student_works_scores.shixun_comment.first.destroy! if @work.student_works_scores.shixun_comment.first.present?
normal_status("删除成功")
end
def export_shixun_work_report
@user = @work.user
@shixun = @homework.shixuns.take

@ -9,6 +9,9 @@ belongs_to :student_work
validates :comment, length: { maximum: 2000 }
scope :shixun_comment, lambda { where(is_ultimate: 0) }
def show_name identity, user
identity < Course::STUDENT || self.user == user || self.reviewer_role != 3
end

@ -46,6 +46,16 @@ if @shixun
json.user_id @user.id
json.username @user.real_name
json.student_id @user.student_id
json.image_url url_to_avatar(@user)
json.complete_count @work.myshixun&.passed_count
json.challenges_count @shixun.challenges_count
json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil
json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil
json.passed_time @work.myshixun&.passed_time
# 评阅信息
json.work_comment @user_course_identity < Course::STUDENT ? @comment&.comment : nil
json.work_comment_hidden @comment&.is_hidden
# 图形统计
# 1 效率

@ -438,6 +438,8 @@ Rails.application.routes.draw do
post :deal_appeal_score
post :cancel_appeal
get :export_shixun_work_report
post :shixun_work_comment
delete :destroy_work_comment
end
collection do

Loading…
Cancel
Save