:
homework_status.length>0 && homework_status[0]==="未发布"?
-
+
:
From 5a9ba51dec79368e97795234882d159fbbf95c49 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 18:00:38 +0800
Subject: [PATCH 06/24] =?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/application_controller.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 508d005a4..b6bba1f34 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -253,7 +253,10 @@ class ApplicationController < ActionController::Base
if Digest::MD5.hexdigest(content) == params[:chinaoocKey]
user = open_class_user
- start_user_session(user) if user
+ if user
+ start_user_session(user)
+ set_autologin_cookie(user)
+ end
User.current = user
end
end
From b53889524c831fea56888f44dac8972470cf07c5 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 18:10:11 +0800
Subject: [PATCH 07/24] =?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/searchs/index.json.jbuilder | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder
index 164e90b53..9983fa61e 100644
--- a/app/views/searchs/index.json.jbuilder
+++ b/app/views/searchs/index.json.jbuilder
@@ -11,8 +11,8 @@ json.results do
reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换
atta_reg = /!\[\]\(\/api\/attachments\/\d+\)/
- highlights[:description]&.first&.sub!(reg, '').sub!(atta_reg, '')
- highlights[:content]&.first&.sub!(reg, '').sub!(atta_reg, '')
+ highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
+ highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
json.content highlights
end
From facea97f5efccca9731532cb0a9821341833e5a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Sat, 21 Sep 2019 18:11:18 +0800
Subject: [PATCH 08/24] =?UTF-8?q?=E8=B0=83=E6=95=B4bd?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
public/react/src/modules/message/js/MessagSub.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/public/react/src/modules/message/js/MessagSub.js b/public/react/src/modules/message/js/MessagSub.js
index fccfbb0b2..1b1accd2b 100644
--- a/public/react/src/modules/message/js/MessagSub.js
+++ b/public/react/src/modules/message/js/MessagSub.js
@@ -479,6 +479,8 @@ class MessagSub extends Component{
return '';
case "PublicCourseStart":
return window.open(`/courses/${item.container_id}/informs`);
+ case "SubjectStartCourse":
+ return window.open(`/paths/${item.container_id}`);
default :
return window.open("/")
}
From a328375a97c657799b6469a58013440d5e750426 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Sat, 21 Sep 2019 18:15:32 +0800
Subject: [PATCH 09/24] =?UTF-8?q?=E8=B0=83=E6=95=B4bd?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../react/src/modules/courses/shixunHomework/shixunHomework.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/shixunHomework/shixunHomework.js b/public/react/src/modules/courses/shixunHomework/shixunHomework.js
index 55dfac7fc..eb59ce6f1 100644
--- a/public/react/src/modules/courses/shixunHomework/shixunHomework.js
+++ b/public/react/src/modules/courses/shixunHomework/shixunHomework.js
@@ -1064,8 +1064,7 @@ class ShixunHomework extends Component{
- {/*{datas&&datas.category_name===undefined||datas&&datas.category_name===null?datas&&datas.main_category_name:datas&&datas.category_name+" 作业列表"}*/}
- 实训作业
+ {datas&&datas.category_name===undefined||datas&&datas.category_name===null?datas&&datas.main_category_name:datas&&datas.category_name+" 作业列表"}
{datas===undefined?"":datas.homeworks && datas.homeworks.length>1?this.props.isAdminOrCreator()===true?datas&&datas.category_name===undefined||datas&&datas.category_name===null?
From a1aff1a8917e97ed9af91b632653c24280c8717c Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 18:25:57 +0800
Subject: [PATCH 10/24] =?UTF-8?q?=E5=88=A0=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/commons_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/commons_controller.rb b/app/controllers/commons_controller.rb
index 43ea31c97..bcb0fa45a 100644
--- a/app/controllers/commons_controller.rb
+++ b/app/controllers/commons_controller.rb
@@ -51,7 +51,7 @@ class CommonsController < ApplicationController
200
end
when 'journals_for_message'
- course = @object.jour&.course || @object.jour&.student_work&.homework_common&.course
+ course = @object&.jour_type.to_s == "StudentWorksScore" ? @object.jour&.student_work&.homework_common&.course : @object.jour&.course
if current_user.course_identity(course) >= Course::STUDENT && @object.user != current_user
403
else
From a32aa9dde6798333ced8d1ab5ee6b12a3ddb4bb6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Sat, 21 Sep 2019 18:40:57 +0800
Subject: [PATCH 11/24] =?UTF-8?q?=E8=B0=83=E6=95=B4bd?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../modules/courses/shixunHomework/Trainingjobsetting.js | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
index bee373bd9..854de0138 100644
--- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
+++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
@@ -86,7 +86,7 @@ class Trainingjobsetting extends Component {
latepenaltytype: false,
unifiedsetting: true,
allowreplenishment: undefined,
- completionefficiencyscore: true,
+ completionefficiencyscore: false,
whethertopay: false,
proportion: undefined,
level: undefined,
@@ -120,6 +120,7 @@ class Trainingjobsetting extends Component {
showmodel:false,
code_review:false,
testscripttiptype:false,
+
end_timebool:false,
late_timesbool:false,
}
@@ -1701,6 +1702,7 @@ class Trainingjobsetting extends Component {
flagPageEditstwo:releasetime,
flagPageEditsthrees:deadline,
flagPageEditsfor:endtime,
+ completionefficiencyscore:true,
unifiedsetting:this.state.unifiedsetting,
})
if(this.state.proportion === "自定义分值"){
@@ -2139,7 +2141,7 @@ class Trainingjobsetting extends Component {
分值
-
From 59aac6cfa8cc8d2b29bc06f5d6f5e6c6795321d3 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 18:44:47 +0800
Subject: [PATCH 12/24] =?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/searchs/index.json.jbuilder | 2 +-
app/views/shixun_lists/index.json.jbuilder | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder
index 9983fa61e..51bf4f221 100644
--- a/app/views/searchs/index.json.jbuilder
+++ b/app/views/searchs/index.json.jbuilder
@@ -10,7 +10,7 @@ json.results do
# 去除开头标点符号
reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换
- atta_reg = /!\[\]\(\/api\/attachments\/\d+\)/
+ atta_reg = /!\[]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
diff --git a/app/views/shixun_lists/index.json.jbuilder b/app/views/shixun_lists/index.json.jbuilder
index c925d6876..a4e49093a 100644
--- a/app/views/shixun_lists/index.json.jbuilder
+++ b/app/views/shixun_lists/index.json.jbuilder
@@ -8,7 +8,7 @@ json.shixun_list do
# 去除开头标点符号
reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换
- atta_reg = /!\[\]\(\/api\/attachments\/\d+\)/
+ atta_reg = /!\[]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
From de4b57d0777d4fe9b7970ff10829bbdf0d2bbce5 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 18:49:06 +0800
Subject: [PATCH 13/24] =?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/shixun_lists/index.json.jbuilder | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/views/shixun_lists/index.json.jbuilder b/app/views/shixun_lists/index.json.jbuilder
index a4e49093a..67875e82b 100644
--- a/app/views/shixun_lists/index.json.jbuilder
+++ b/app/views/shixun_lists/index.json.jbuilder
@@ -10,6 +10,8 @@ json.shixun_list do
# 附件的替换
atta_reg = /!\[]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
+ Rails.logger.info("#########serach_description#{highlights[:description]}------------#{highlights[:description]&.first}")
+
highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
From ee595e9e9a01101f779233c59e8310ea2aab2136 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Sat, 21 Sep 2019 18:53:13 +0800
Subject: [PATCH 14/24] =?UTF-8?q?=E8=B0=83=E6=95=B4bd?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/shixunHomework/Trainingjobsetting.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
index 854de0138..2edecd175 100644
--- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
+++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
@@ -1735,6 +1735,7 @@ class Trainingjobsetting extends Component {
hand__e_tip: "",
hand_flags: false,
handclass: undefined,
+ completionefficiencyscore:false,
unit_e_tip: "",
})
this.refs.targetElementTrainingjobsetting.scrollIntoView();
From 7619da0341dbeb2b07da3c294560ff51ed2ce220 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 18:54:04 +0800
Subject: [PATCH 15/24] =?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/searchs/index.json.jbuilder | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder
index 51bf4f221..27674e894 100644
--- a/app/views/searchs/index.json.jbuilder
+++ b/app/views/searchs/index.json.jbuilder
@@ -12,6 +12,7 @@ json.results do
# 附件的替换
atta_reg = /!\[]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
+ Rails.logger.info("#########serach_description#{highlights[:description]}------------#{highlights[:description]&.first}")
highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
json.content highlights
From b389560aed50c5322937da59fd43bd2cdcb6ea06 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 18:58:15 +0800
Subject: [PATCH 16/24] =?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/searchs/index.json.jbuilder | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder
index 27674e894..be62bf865 100644
--- a/app/views/searchs/index.json.jbuilder
+++ b/app/views/searchs/index.json.jbuilder
@@ -10,10 +10,12 @@ json.results do
# 去除开头标点符号
reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换
- atta_reg = /!\[]\(\/api\/attachments\/\d+\)/
- highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
+ atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
+ highlights[:description]&.first&.sub!(reg, '')
+ highlights[:description]&.map{|des| des.gsub!(atta_reg, '')}
Rails.logger.info("#########serach_description#{highlights[:description]}------------#{highlights[:description]&.first}")
- highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
+ highlights[:content]&.first&.sub!(reg, '')
+ highlights[:content]&.map{|des| des.gsub!(atta_reg, '')}
json.content highlights
end
From f1ff06df797b24ce588348dada1e175256f0798d Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 19:00:20 +0800
Subject: [PATCH 17/24] =?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/searchs/index.json.jbuilder | 1 -
app/views/shixun_lists/index.json.jbuilder | 9 +++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder
index be62bf865..65c4d248c 100644
--- a/app/views/searchs/index.json.jbuilder
+++ b/app/views/searchs/index.json.jbuilder
@@ -13,7 +13,6 @@ json.results do
atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '')
highlights[:description]&.map{|des| des.gsub!(atta_reg, '')}
- Rails.logger.info("#########serach_description#{highlights[:description]}------------#{highlights[:description]&.first}")
highlights[:content]&.first&.sub!(reg, '')
highlights[:content]&.map{|des| des.gsub!(atta_reg, '')}
diff --git a/app/views/shixun_lists/index.json.jbuilder b/app/views/shixun_lists/index.json.jbuilder
index 67875e82b..79ce4b09c 100644
--- a/app/views/shixun_lists/index.json.jbuilder
+++ b/app/views/shixun_lists/index.json.jbuilder
@@ -8,11 +8,12 @@ json.shixun_list do
# 去除开头标点符号
reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换
- atta_reg = /!\[]\(\/api\/attachments\/\d+\)/
- highlights[:description]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
- Rails.logger.info("#########serach_description#{highlights[:description]}------------#{highlights[:description]&.first}")
+ atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
- highlights[:content]&.first&.sub!(reg, '')&.sub!(atta_reg, '')
+ highlights[:description]&.first&.sub!(reg, '')
+ highlights[:description]&.map{|des| des.gsub!(atta_reg, '')}
+ highlights[:content]&.first&.sub!(reg, '')
+ highlights[:content]&.map{|des| des.gsub!(atta_reg, '')}
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '')
From e25ec454f658f4318bb1622f1a6e67075f304528 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com>
Date: Sat, 21 Sep 2019 19:05:27 +0800
Subject: [PATCH 18/24] =?UTF-8?q?=E8=B0=83=E6=95=B4bd?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/courses/shixunHomework/Trainingjobsetting.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
index 2edecd175..e9c100648 100644
--- a/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
+++ b/public/react/src/modules/courses/shixunHomework/Trainingjobsetting.js
@@ -1703,6 +1703,7 @@ class Trainingjobsetting extends Component {
flagPageEditsthrees:deadline,
flagPageEditsfor:endtime,
completionefficiencyscore:true,
+ latedeductiontwo:20,
unifiedsetting:this.state.unifiedsetting,
})
if(this.state.proportion === "自定义分值"){
@@ -1736,6 +1737,7 @@ class Trainingjobsetting extends Component {
hand_flags: false,
handclass: undefined,
completionefficiencyscore:false,
+ latedeductiontwo:0,
unit_e_tip: "",
})
this.refs.targetElementTrainingjobsetting.scrollIntoView();
From e535c92410f6d57f3bf86234e884d4a2a1f2d48e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 19:08:53 +0800
Subject: [PATCH 19/24] =?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/courses_controller.rb | 2 ++
app/jobs/create_subject_course_student_job.rb | 20 +++++++++++++++++++
.../create_subject_course_student_job_spec.rb | 5 +++++
3 files changed, 27 insertions(+)
create mode 100644 app/jobs/create_subject_course_student_job.rb
create mode 100644 spec/jobs/create_subject_course_student_job_spec.rb
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 0dc8829da..8d6c96b1c 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -166,6 +166,8 @@ class CoursesController < ApplicationController
CourseMember.create!(course_id: @course.id, user_id: s_member.user_id, role: 2)
end
+ CreateSubjectCourseStudentJob.perform_later(@course.id) if course.subject.subject_appointments.count > 0
+
Inform.create(container: @course, description: @subject.learning_notes, name: "学习须知")
@course.create_stages @course.subject
diff --git a/app/jobs/create_subject_course_student_job.rb b/app/jobs/create_subject_course_student_job.rb
new file mode 100644
index 000000000..66eb41f70
--- /dev/null
+++ b/app/jobs/create_subject_course_student_job.rb
@@ -0,0 +1,20 @@
+class CreateSubjectCourseStudentJob < ApplicationJob
+ queue_as :default
+
+ def perform(course_id)
+ course = Course.find_by(id: course_id)
+ return if course.blank? || course.subject.blank?
+
+ attrs = %i[course_id user_id role created_at updated_at]
+ same_attrs = {course_id: course.id, role: 4}
+
+ CourseMember.bulk_insert(*attrs) do |worker|
+ course.subject.subject_appointments.each do |app|
+ next if course.students.where(user_id: user_id).any?
+ worker.add same_attrs.merge(user_id: app.user_id)
+ end
+ end
+
+ course.subject.subject_appointments.destroy_all
+ end
+end
diff --git a/spec/jobs/create_subject_course_student_job_spec.rb b/spec/jobs/create_subject_course_student_job_spec.rb
new file mode 100644
index 000000000..1b506fe68
--- /dev/null
+++ b/spec/jobs/create_subject_course_student_job_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe CreateSubjectCourseStudentJob, type: :job do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
From 2050c040c6b7774b2ec5bac54918fa4aa089762e Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 19:15:15 +0800
Subject: [PATCH 20/24] =?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/courses_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 8d6c96b1c..a90855706 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -166,7 +166,7 @@ class CoursesController < ApplicationController
CourseMember.create!(course_id: @course.id, user_id: s_member.user_id, role: 2)
end
- CreateSubjectCourseStudentJob.perform_later(@course.id) if course.subject.subject_appointments.count > 0
+ CreateSubjectCourseStudentJob.perform_later(@course.id) if @course.subject.subject_appointments.count > 0
Inform.create(container: @course, description: @subject.learning_notes, name: "学习须知")
From 80a14f5d95d18cdf877f567710692871c76dc135 Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 19:16:44 +0800
Subject: [PATCH 21/24] =?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/jobs/create_subject_course_student_job.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/jobs/create_subject_course_student_job.rb b/app/jobs/create_subject_course_student_job.rb
index 66eb41f70..38ff83024 100644
--- a/app/jobs/create_subject_course_student_job.rb
+++ b/app/jobs/create_subject_course_student_job.rb
@@ -10,7 +10,7 @@ class CreateSubjectCourseStudentJob < ApplicationJob
CourseMember.bulk_insert(*attrs) do |worker|
course.subject.subject_appointments.each do |app|
- next if course.students.where(user_id: user_id).any?
+ next if course.students.where(user_id: app.user_id).any?
worker.add same_attrs.merge(user_id: app.user_id)
end
end
From 57c64784f049c3cecaac0b244fc49898a262af2a Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Sat, 21 Sep 2019 19:44:30 +0800
Subject: [PATCH 22/24] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/jobs/create_subject_course_student_job.rb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/jobs/create_subject_course_student_job.rb b/app/jobs/create_subject_course_student_job.rb
index 38ff83024..a7b8cb8af 100644
--- a/app/jobs/create_subject_course_student_job.rb
+++ b/app/jobs/create_subject_course_student_job.rb
@@ -8,13 +8,15 @@ class CreateSubjectCourseStudentJob < ApplicationJob
attrs = %i[course_id user_id role created_at updated_at]
same_attrs = {course_id: course.id, role: 4}
+ Rails.logger.info("1:course.students.count:##{course.students.count}")
CourseMember.bulk_insert(*attrs) do |worker|
course.subject.subject_appointments.each do |app|
+ Rails.logger.info("##{course.students.where(user_id: app.user_id)}")
next if course.students.where(user_id: app.user_id).any?
worker.add same_attrs.merge(user_id: app.user_id)
end
end
-
+ Rails.logger.info("2:course.students.count:##{course.students.count}")
course.subject.subject_appointments.destroy_all
end
end
From a1339c595bb800a8eab36edf2784f57b72a50e1f Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 19:49:49 +0800
Subject: [PATCH 23/24] =?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/jobs/create_subject_course_student_job.rb | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/jobs/create_subject_course_student_job.rb b/app/jobs/create_subject_course_student_job.rb
index 38ff83024..4675b59aa 100644
--- a/app/jobs/create_subject_course_student_job.rb
+++ b/app/jobs/create_subject_course_student_job.rb
@@ -12,9 +12,8 @@ class CreateSubjectCourseStudentJob < ApplicationJob
course.subject.subject_appointments.each do |app|
next if course.students.where(user_id: app.user_id).any?
worker.add same_attrs.merge(user_id: app.user_id)
+ app.destroy
end
end
-
- course.subject.subject_appointments.destroy_all
end
end
From d2d5759553d48414127b0ead96a41b8c65c63ecb Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Sat, 21 Sep 2019 19:53:41 +0800
Subject: [PATCH 24/24] =?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/courses_controller.rb | 15 +++++++--------
app/jobs/create_subject_course_student_job.rb | 5 ++---
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index a90855706..d2c9f88d2 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -128,8 +128,8 @@ class CoursesController < ApplicationController
# POST /courses
# POST /courses.json
def create
- ActiveRecord::Base.transaction do
- begin
+ begin
+ ActiveRecord::Base.transaction do
@course = Course.new(name: params[:name], class_period: params[:class_period], credit: params[:credit],
end_date: params[:end_date], is_public: params[:is_public], school_id: @school.id,
authentication: params[:authentication], professional_certification: params[:professional_certification])
@@ -166,8 +166,6 @@ class CoursesController < ApplicationController
CourseMember.create!(course_id: @course.id, user_id: s_member.user_id, role: 2)
end
- CreateSubjectCourseStudentJob.perform_later(@course.id) if @course.subject.subject_appointments.count > 0
-
Inform.create(container: @course, description: @subject.learning_notes, name: "学习须知")
@course.create_stages @course.subject
@@ -176,11 +174,12 @@ class CoursesController < ApplicationController
course_module_types = params[:course_module_types]
@course.create_course_modules(course_module_types)
end
- rescue => e
- uid_logger_error(e.message)
- tip_exception(e.message)
- raise ActiveRecord::Rollback
end
+ CreateSubjectCourseStudentJob.perform_later(@course.id) if @course.subject && @course.subject.subject_appointments.count > 0
+ rescue => e
+ uid_logger_error(e.message)
+ tip_exception(e.message)
+ raise ActiveRecord::Rollback
end
end
diff --git a/app/jobs/create_subject_course_student_job.rb b/app/jobs/create_subject_course_student_job.rb
index 71d4cda5f..a7b8cb8af 100644
--- a/app/jobs/create_subject_course_student_job.rb
+++ b/app/jobs/create_subject_course_student_job.rb
@@ -14,10 +14,9 @@ class CreateSubjectCourseStudentJob < ApplicationJob
Rails.logger.info("##{course.students.where(user_id: app.user_id)}")
next if course.students.where(user_id: app.user_id).any?
worker.add same_attrs.merge(user_id: app.user_id)
- app.destroy
end
end
- # Rails.logger.info("2:course.students.count:##{course.students.count}")
- # course.subject.subject_appointments.destroy_all
+ Rails.logger.info("2:course.students.count:##{course.students.count}")
+ course.subject.subject_appointments.destroy_all
end
end