diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb
index 6f121db5f..e92c3b266 100644
--- a/app/controllers/exercises_controller.rb
+++ b/app/controllers/exercises_controller.rb
@@ -703,12 +703,14 @@ class ExercisesController < ApplicationController
end
if ex_status == 1 #如果试卷存在已发布的,或者是已截止的,那么则直接跳过
g_course = params[:group_ids] #表示是否传入分班参数,如果传入分班的参数,那么试卷的统一设置需修改
+ tiding_group_ids = g_course
if g_course
user_course_groups = @course.charge_group_ids(current_user)
if g_course.map(&:to_i).sort == user_course_groups.sort # 如果是设置为全部班级,则试卷不用分组,且试卷设定为统一设置,否则则分组设置
exercise.exercise_group_settings.destroy_all
ex_unified = true
e_time = ex_end_time
+ tiding_group_ids = []
else
ex_unified = false
g_course.each do |i|
@@ -748,7 +750,7 @@ class ExercisesController < ApplicationController
if exercise.course_acts.size == 0
exercise.course_acts << CourseActivity.new(:user_id => exercise.user_id,:course_id => exercise.course_id)
end
- ExercisePublishNotifyJob.perform_later(exercise.id, g_course)
+ ExercisePublishNotifyJob.perform_later(exercise.id, tiding_group_ids)
end
end
end
@@ -1084,6 +1086,7 @@ class ExercisesController < ApplicationController
:subjective_score => subjective_score
}
@answer_committed_user.update_attributes(commit_option)
+ CommitExercsieNotifyJobJob.perform_later(@exercise.id, current_user.id)
normal_status(0,"试卷提交成功!")
end
rescue Exception => e
diff --git a/app/controllers/polls_controller.rb b/app/controllers/polls_controller.rb
index 7d978d722..ba3030424 100644
--- a/app/controllers/polls_controller.rb
+++ b/app/controllers/polls_controller.rb
@@ -919,6 +919,7 @@ class PollsController < ApplicationController
:end_at => Time.now
}
poll_user_current.update_attributes(poll_user_params)
+ CommitPollNotifyJobJob.perform_later(@poll.id, current_user.id)
normal_status(0, "问卷提交成功!")
end
## 需添加发送消息的接口,稍后添加
diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb
index 30a325cd3..d1f6f08e6 100644
--- a/app/decorators/tiding_decorator.rb
+++ b/app/decorators/tiding_decorator.rb
@@ -47,13 +47,13 @@ module TidingDecorator
# ================ 各种类消息内容方法 ================
def apply_user_authentication_content
- return if trigger_user_id.zero?
+ t_user = trigger_user || User.find(1)
if tiding_type == 'Apply'
str1, str2 = if container.auth_type == 1
- [trigger_user.show_real_name, trigger_user.ID_number]
+ [t_user.show_real_name, t_user.ID_number]
elsif container.auth_type == 2
- ue = trigger_user.user_extension
+ ue = t_user.user_extension
[[ue.school&.name, ue.department&.name].join('_'), ue.identity_text]
end
I18n.t(locale_format(tiding_type, container.auth_type)) % [str1, str2]
@@ -97,7 +97,7 @@ module TidingDecorator
elsif status == 2
I18n.t(locale_format(tiding_type, "#{status}_#{extra.nil?}"), reason: extra) % [name, second_name]
else
- I18n.t(locale_format(tiding_type, status)) % [name, second_name]
+ I18n.t(locale_format(tiding_type, status), reason: extra) % [name, second_name]
end
end
@@ -106,9 +106,9 @@ module TidingDecorator
if tiding_type == 'Apply'
I18n.t(locale_format(tiding_type)) % name
elsif status == 2
- I18n.t(locale_format(tiding_type, "#{status}_#{extra.nil?}"), reason: extra) % name
+ I18n.t(locale_format(tiding_type, "#{status}_#{extra.nil?}"), name: name, reason: extra)
else
- I18n.t(locale_format(tiding_type, status)) % name
+ I18n.t(locale_format(tiding_type, status), name: name, reason: extra)
end
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 5040acec0..7e9fd652b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -130,15 +130,15 @@ module ApplicationHelper
if source.class.to_s == 'User'
File.join(relative_path, ["#{source.class}", "#{source.id}"])
else
- File.join("avatars", ["#{source.class}", "#{source.id}"])
+ File.join("images/avatars", ["#{source.class}", "#{source.id}"])
end
elsif source.class.to_s == 'User'
str = source.user_extension.try(:gender).to_i == 0 ? "b" : "g"
File.join(relative_path, "#{source.class}", str)
elsif source.class.to_s == 'Subject'
- File.join("educoder", "index", "subject", "subject#{rand(17)}.jpg")
+ File.join("images","educoder", "index", "subject", "subject#{rand(17)}.jpg")
elsif source.class.to_s == 'Shixun'
- File.join("educoder","index", "shixun", "shixun#{rand(23)}.jpg")
+ File.join("images","educoder", "index", "shixun", "shixun#{rand(23)}.jpg")
end
end
diff --git a/app/jobs/commit_exercsie_notify_job_job.rb b/app/jobs/commit_exercsie_notify_job_job.rb
new file mode 100644
index 000000000..1be0bb2bc
--- /dev/null
+++ b/app/jobs/commit_exercsie_notify_job_job.rb
@@ -0,0 +1,26 @@
+class CommitExercsieNotifyJobJob < ApplicationJob
+ queue_as :notify
+
+ def perform(exercise_id, user_id)
+ exercise = Exercise.find_by(id: exercise_id)
+ user = User.find_by(id: user_id)
+ return if [exercise, user].any?(&:blank?)
+ course = exercise.course
+
+ attrs = %i[user_id trigger_user_id container_id container_type parent_container_id parent_container_type
+ belong_container_id belong_container_type tiding_type viewed status created_at updated_at]
+
+ same_attrs = {
+ trigger_user_id: user.id,
+ container_id: exercise.id, container_type: 'Exercise',
+ parent_container_id: exercise.id, parent_container_type: 'CommitExercise',
+ belong_container_id: course.id, belong_container_type: 'Course',
+ tiding_type: 'Exercise', viewed: 0, status: 0
+ }
+ Tiding.bulk_insert(*attrs) do |worker|
+ course.course_member(user).member_teachers.each do |teacher|
+ worker.add same_attrs.merge(user_id: teacher.user_id)
+ end
+ end
+ end
+end
diff --git a/app/jobs/commit_poll_notify_job_job.rb b/app/jobs/commit_poll_notify_job_job.rb
new file mode 100644
index 000000000..6953fa9e9
--- /dev/null
+++ b/app/jobs/commit_poll_notify_job_job.rb
@@ -0,0 +1,26 @@
+class CommitPollNotifyJobJob < ApplicationJob
+ queue_as :notify
+
+ def perform(poll_id, user_id)
+ poll = Poll.find_by(id: poll_id)
+ user = User.find_by(id: user_id)
+ return if [poll, user].any?(&:blank?)
+ course = poll.course
+
+ attrs = %i[user_id trigger_user_id container_id container_type parent_container_id parent_container_type
+ belong_container_id belong_container_type tiding_type viewed status created_at updated_at]
+
+ same_attrs = {
+ trigger_user_id: user.id,
+ container_id: poll.id, container_type: 'Poll',
+ parent_container_id: poll.id, parent_container_type: 'CommitPoll',
+ belong_container_id: course.id, belong_container_type: 'Course',
+ tiding_type: 'Poll', viewed: 0, status: 0
+ }
+ Tiding.bulk_insert(*attrs) do |worker|
+ course.course_member(user).member_teachers.each do |teacher|
+ worker.add same_attrs.merge(user_id: teacher.user_id)
+ end
+ end
+ end
+end
diff --git a/app/models/apply_user_authentication.rb b/app/models/apply_user_authentication.rb
index c7fb5019e..d467eb850 100644
--- a/app/models/apply_user_authentication.rb
+++ b/app/models/apply_user_authentication.rb
@@ -3,8 +3,18 @@
class ApplyUserAuthentication < ApplicationRecord
belongs_to :user
+ has_many :tidings, :as => :container, :dependent => :destroy
+
scope :real_name_auth, -> { where(auth_type: 1) }
scope :professional_auth, -> { where(auth_type: 2) }
scope :processing, -> { where(status: 0) }
scope :passed, -> { where(status: 1) }
+
+ after_create :send_tiding
+
+ private
+
+ def send_tiding
+ self.tidings << Tiding.new(:user_id => '1', :status=> 0, :trigger_user_id => user_id, :belong_container_id => 1, :belong_container_type =>'User', :tiding_type => "Apply")
+ end
end
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index d5697d87f..4300ae9cc 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -11,6 +11,7 @@ class JournalsForMessage < ApplicationRecord
scope :parent_comment, -> { where(m_parent_id: nil)}
scope :search_by_jour_type, lambda{|type,ids| where(jour_type:type,jour_id: ids)}
+ has_many :tidings, as: :container, dependent: :destroy
# "jour_type", # 留言所属类型
# "jour_id", # 留言所属类型的id
diff --git a/app/models/student_graduation_topic.rb b/app/models/student_graduation_topic.rb
index ea1774695..50f150f92 100644
--- a/app/models/student_graduation_topic.rb
+++ b/app/models/student_graduation_topic.rb
@@ -17,7 +17,12 @@ class StudentGraduationTopic < ApplicationRecord
scope :is_refused, -> {where(status: 2)}
scope :is_accepted, -> {where(status: 1)}
scope :is_accepting, -> {where(status: 0)}
+ after_create :send_tiding
+ def send_tiding
+ self.tidings << Tiding.new(:user_id => self.graduation_topic.tea_id, :trigger_user_id => self.user_id, :parent_container_id => self.graduation_topic_id, :parent_container_type => "GraduationTopic",
+ :belong_container_id => self.graduation_topic.course_id, :belong_container_type => "Course", :viewed => 0, :status => 0, :tiding_type => "GraduationTopic")
+ end
# 学生名称
def name
diff --git a/app/views/tidings/_tiding.json.jbuilder b/app/views/tidings/_tiding.json.jbuilder
index c00670433..207d4b137 100644
--- a/app/views/tidings/_tiding.json.jbuilder
+++ b/app/views/tidings/_tiding.json.jbuilder
@@ -4,7 +4,15 @@ json.content tiding.content
json.identifier tiding.identifier
json.auth_type tiding.container_type == 'ApplyUserAuthentication' ? tiding.container.auth_type : nil
-json.homework_type tiding.container_type == 'HomeworkCommon' ? tiding.container.homework_type : nil
+
+homework_type = nil
+if tiding.container_type == 'HomeworkCommon'
+ homework_type = tiding.container.homework_type rescue nil
+end
+if homework_type.blank? && tiding.parent_container_type == 'HomeworkCommon'
+ homework_type = tiding.parent_container.homework_type rescue nil
+end
+json.homework_type homework_type
json.time tiding.how_long_time
json.new_tiding tiding.unread?(@onclick_time)
diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml
index 456f15887..3fbfb88fa 100644
--- a/config/locales/tidings/zh-CN.yml
+++ b/config/locales/tidings/zh-CN.yml
@@ -38,8 +38,8 @@
Apply_end: "申请添加单位:%s"
System:
"1_end": "你提交的添加单位申请:%{name},审核已通过"
- "2_reason_end": "你提交的添加单位申请:%{name},审核未通过
原因:%{reason}"
- "2_no_reason_end": "你提交的添加单位申请:%{name},审核未通过"
+ "2_false_end": "你提交的添加单位申请:%{name},审核未通过
原因:%{reason}"
+ "2_true_end": "你提交的添加单位申请:%{name},审核未通过"
"3_end": "你提交的添加单位申请:%{name},已被更改为:%{reason}"
ApplyAction:
ApplyShixun:
@@ -164,7 +164,7 @@
NearlyEnd_end: "试卷的截止时间快到啦:%s"
CommitExercise_end: "提交了试卷答题:%s"
ExerciseScore_end: "评阅了你的试卷:%s"
- StudentGraduationTopic_end: "选择了毕设选题:%s"
+ StudentGraduationTopic_end: "申请选择毕设选题:%s"
DealStudentTopicSelect:
1_end: "你提交的选题申请:%s,审核已通过"
2_end: "你提交的选题申请:%s,审核未通过"
@@ -195,11 +195,11 @@
ChallengeWorkScore_end: "调整了你的作品分数:%s"
StudentWorksScoresAppeal:
UserAppealResult:
- 1_end: "同意了你提交的匿评申诉申请:%s"
- 2_end: "拒绝了你提交的匿评申诉:%s"
+ 1_end: "你提交的匿评申诉申请:%s,审核已通过"
+ 2_end: "你提交的匿评申诉:%s,审核未通过"
AppealResult:
- 1_end: "同意了他人对你的匿评申诉申请:%s"
- 2_end: "拒绝了他人对你的匿评申诉:%s"
+ 1_end: "别人对你的匿评发起的申诉申请:%s,审核已通过"
+ 2_end: "别人对你的匿评发起的申诉申请:%s,审核未通过"
StudentWork:
Apply_end: "发起了匿评申诉申请:%s"
HomeworkCommon_end: "有人对你的匿评发起了申诉:%s"
diff --git a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js
index 17a944d41..8baee4b45 100644
--- a/public/react/src/modules/courses/busyWork/CommonWorkSetting.js
+++ b/public/react/src/modules/courses/busyWork/CommonWorkSetting.js
@@ -722,7 +722,7 @@ class CommonWorkSetting extends Component{
late_time: late_time ? new Date(late_time) : late_time, // 补交截止时间
anonymous_comment: anonymous_comment, // true: 启用匿评 false:未启用匿评
evaluation_start: evaluation_start ? new Date(evaluation_start) : evaluation_start, //匿评开始时间
- evaluation_end: evaluation_end,
+ evaluation_end: evaluation_end ? new Date(evaluation_end) : evaluation_end,
evaluation_num: evaluation_num, // 匿评数
absence_penalty: absence_penalty, // 匿评扣分
anonymous_appeal: anonymous_appeal, // true: 启用匿评申诉, false:未启用
diff --git a/public/react/src/modules/forums/RecommendShixun.js b/public/react/src/modules/forums/RecommendShixun.js
index aa9dec952..af0ca0007 100644
--- a/public/react/src/modules/forums/RecommendShixun.js
+++ b/public/react/src/modules/forums/RecommendShixun.js
@@ -28,7 +28,7 @@ class RecommendShixun extends Component {
+