From 19bb4ff1151a1a330dde29bd2ab9f23cd94702a6 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Sep 2019 17:42:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_works/shixun_work_report.json.jbuilder | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/student_works/shixun_work_report.json.jbuilder b/app/views/student_works/shixun_work_report.json.jbuilder index e8e3af057..e63cc2c13 100644 --- a/app/views/student_works/shixun_work_report.json.jbuilder +++ b/app/views/student_works/shixun_work_report.json.jbuilder @@ -39,6 +39,7 @@ if @shixun challenge_comment = @work.shixun_work_comments.find_by(challenge_id: game.challenge_id) json.challenge_comment challenge_comment&.comment json.challenge_comment_hidden challenge_comment&.hidden_comment + json.comment_id challenge_comment&.id end end @@ -59,6 +60,7 @@ if @shixun # 评阅信息 json.work_comment @comment&.comment json.work_comment_hidden @user_course_identity < Course::STUDENT ? @comment&.hidden_comment : nil + json.comment_id @comment&.id # 图形统计 # 1: 效率 From e83aaf6da25ff94bc8a7bd69c66dbaf15b36d1fa Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Sep 2019 18:06:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 9e37571b1..63dd509fe 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -494,7 +494,15 @@ class StudentWorksController < ApplicationController # 删除实训作品评阅 def destroy_work_comment ActiveRecord::Base.transaction do - @work.shixun_work_comments.find_by!(id: params[:comment_id]).destroy_all + tip_exception("visible_comment参数有误") if params[:visible_comment].blank? + + comment = @work.shixun_work_comments.find_by!(id: params[:comment_id]) + params[:visible_comment] ? comment.comment = nil : comment.hidden_comment = nil + if comment.comment.nil? && comment.hidden_comment.nil? + comment.destroy! + else + comment.save! + end normal_status("删除成功") end end