From f109f7aaeb1a501481bdbdefc145706bd61bf655 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 1 Aug 2019 15:41:46 +0800 Subject: [PATCH 1/4] =?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/controllers/memos_controller.rb | 17 ++++++++--------- app/views/memos/reply.json.jbuilder | 2 ++ 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 app/views/memos/reply.json.jbuilder diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 66adcc46b..d950fe1c8 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -147,16 +147,15 @@ class MemosController < ApplicationController ActiveRecord::Base.transaction do begin memo = Memo.find_by!(id: params[:parent_id]) - reply = Memo.new - reply.content = params[:content] - reply.author = current_user - reply.forum_id = memo.forum_id - reply.subject = memo.subject - reply.root_id = memo.root_id || memo.id - memo.children << reply - m = Memo.find_by!(id: reply.root_id) + @reply = Memo.new + @reply.content = params[:content] + @reply.author = current_user + @reply.forum_id = memo.forum_id + @reply.subject = memo.subject + @reply.root_id = memo.root_id || memo.id + memo.children << @reply + m = Memo.find_by!(id: @reply.root_id) m.increment!(:all_replies_count) - normal_status("回复成功") rescue Exception => e tip_exception("回复失败,原因:#{e}") raise ActiveRecord::Rollback diff --git a/app/views/memos/reply.json.jbuilder b/app/views/memos/reply.json.jbuilder new file mode 100644 index 000000000..c117d2d24 --- /dev/null +++ b/app/views/memos/reply.json.jbuilder @@ -0,0 +1,2 @@ +json.(@reply, :id, :subject, :content, :hidden, :forum_id, :author_id, :all_replies_count, :is_md, :parent_id, :root_id, + :reward, :sticky, :updated_at, :created_at, :viewed_count) \ No newline at end of file From f8ad640971f951508d52ac150530eb0700598ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 1 Aug 2019 15:47:06 +0800 Subject: [PATCH 2/4] b --- public/react/src/modules/tpm/challengesnew/TPMevaluation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/tpm/challengesnew/TPMevaluation.js b/public/react/src/modules/tpm/challengesnew/TPMevaluation.js index 6cd0b9977..2eea2b8e4 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMevaluation.js +++ b/public/react/src/modules/tpm/challengesnew/TPMevaluation.js @@ -981,7 +981,7 @@ export default class TPMevaluation extends Component { {pathoptionvalue===1||pathoptionvalue===5||pathoptionvalue===6?
-

待处理图片路径

+

待处理文件路径

-

标准答案图片路径

+

学员答案文件路径

Date: Thu, 1 Aug 2019 15:52:57 +0800 Subject: [PATCH 3/4] b --- public/react/src/modules/tpm/challengesnew/TPMevaluation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/tpm/challengesnew/TPMevaluation.js b/public/react/src/modules/tpm/challengesnew/TPMevaluation.js index 2eea2b8e4..16c7cfedf 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMevaluation.js +++ b/public/react/src/modules/tpm/challengesnew/TPMevaluation.js @@ -1003,7 +1003,7 @@ export default class TPMevaluation extends Component { {pathoptionvalue===1||pathoptionvalue===5||pathoptionvalue===6?
-

学员答案文件路径

+

标准答案文件路径

Date: Thu, 1 Aug 2019 15:57:48 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B4=B4=E5=90=A7=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20190801075337_add_praises_count_to_memos.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 db/migrate/20190801075337_add_praises_count_to_memos.rb diff --git a/db/migrate/20190801075337_add_praises_count_to_memos.rb b/db/migrate/20190801075337_add_praises_count_to_memos.rb new file mode 100644 index 000000000..0cc2259e2 --- /dev/null +++ b/db/migrate/20190801075337_add_praises_count_to_memos.rb @@ -0,0 +1,12 @@ +class AddPraisesCountToMemos < ActiveRecord::Migration[5.2] + def change + add_column :memos, :praises_count, :integer, :default => 0 + + memos = Memo.includes(:praise_treads).all + memos.find_each do |m| + puts("####{m.id}") + praises_count = m.praise_treads.select{|pt| pt.praise_or_tread == 1}.count + m.update_column(:praises_count, praises_count) + end + end +end