Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_admin
杨树林 6 years ago
commit 8fa883b0e4

@ -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

@ -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
## 需添加发送消息的接口,稍后添加

@ -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

@ -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

@ -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

@ -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

@ -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"

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CommitExercsieNotifyJobJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe CommitPollNotifyJobJob, type: :job do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save