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

dev_forum
daiao 5 years ago
commit dd51430b94

@ -121,23 +121,26 @@ class HomeworkCommonsController < ApplicationController
@work = @homework.user_work(current_user.id) @work = @homework.user_work(current_user.id)
# 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段 # 学生已提交作品且补交(提交)已截止、作品公开、非匿评阶段
if @work.work_status > 0 && @homework.work_public && if @work&.work_status.to_i > 0 && @homework.work_public &&
((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4) ((!@homework.anonymous_comment && @homework.end_or_late) || @homework_detail_manual.comment_status > 4)
@student_works = student_works.where("user_id != #{@work.id}") @student_works = student_works.where("user_id != #{@work.user_id}")
# 匿评、申诉阶段只能看到分配给自己的匿评作品 # 匿评、申诉阶段只能看到分配给自己的匿评作品
elsif @work.work_status > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2 elsif @work&.work_status.to_i > 0 && @homework.anonymous_comment && @homework_detail_manual.comment_status > 2
@is_evaluation = true @is_evaluation = true
@student_works = student_works.joins(:student_works_evaluation_distributions).where( @student_works = student_works.joins(:student_works_evaluation_distributions).where(
"student_works_evaluation_distributions.user_id = #{@current_user.id}") "student_works_evaluation_distributions.user_id = #{@current_user.id}")
else else
@student_works = [] @student_works = []
end end
@score_open = @homework.score_open && @work&.work_status.to_i > 0
elsif @user_course_identity < Course::STUDENT elsif @user_course_identity < Course::STUDENT
@student_works = @homework.teacher_works(@member) @student_works = @homework.teacher_works(@member)
@all_member_count = @student_works.size @all_member_count = @student_works.size
@score_open = true
elsif @user_course_identity > Course::STUDENT && @homework.work_public elsif @user_course_identity > Course::STUDENT && @homework.work_public
@student_works = student_works @student_works = student_works
@score_open = false
else else
@student_works = [] @student_works = []
end end

@ -0,0 +1,33 @@
class HomeworkAbsencePenaltyCalculationJob < ApplicationJob
queue_as :score
def perform(homework_common_id)
homework_common = HomeworkCommon.find_by(id: homework_common_id)
return if homework_common.blank?
#计算缺评扣分 参与匿评
work_ids = homework_common.student_works.has_committed.pluck(:id)
homework_detail_manual = homework_common.homework_detail_manual
homework_common.student_works.where("work_status != 0").each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where(student_work_id: work_ids).count -
student_work.user.student_works_scores.where(student_work_id: work_ids, reviewer_role: 3).group_by(:student_work_id).count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
end
# 未参与匿评
if homework_detail_manual.no_anon_penalty == 0
all_dis_eva = StudentWorksEvaluationDistribution.where(student_work_id: work_ids)
has_sw_count = all_dis_eva.select("distinct user_id").count
anon_count = all_dis_eva.count / has_sw_count
homework_common.student_works.where("work_status != 0").each do |student_work|
if student_work.user.student_works_evaluation_distributions.where(student_work_id: work_ids).count == 0
student_work.absence_penalty = homework_detail_manual.absence_penalty * anon_count
student_work.save
end
end
end
end
end

@ -0,0 +1,27 @@
class HomeworkAnonymousAppealStartNotifyJob < ApplicationJob
queue_as :notify
def perform(homework_common_id)
homework = HomeworkCommon.find_by(id: homework_common_id)
return if homework.blank?
eva_distribution = StudentWorksEvaluationDistribution.where(student_work_id: homework.student_works.pluck(:id))
attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type
belong_container_id belong_container_type viewed tiding_type created_at updated_at
]
same_attrs = {
trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon',
parent_container_id: homework.id, parent_container_type: 'AnonymousAppeal',
belong_container_id: homework.course_id, belong_container_type: 'Course',
viewed: 0, tiding_type: 'HomeworkCommon'
}
Tiding.bulk_insert(*attrs) do |worker|
eva_distribution.pluck(:user_id).uniq.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end
end
end

@ -24,7 +24,7 @@ class HomeworkCommonPushNotifyJob < ApplicationJob
same_attrs = { same_attrs = {
trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon', trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon',
parent_container_id: homework.id, parent_container_type: 'HomeworkPublish', parent_container_id: homework.id, parent_container_type: 'HomeworkPublish',
belong_container_id: task.course_id, belong_container_type: 'Course', belong_container_id: homework.course_id, belong_container_type: 'Course',
viewed: 0, tiding_type: 'HomeworkCommon' viewed: 0, tiding_type: 'HomeworkCommon'
} }
Tiding.bulk_insert(*attrs) do |worker| Tiding.bulk_insert(*attrs) do |worker|

@ -0,0 +1,48 @@
class HomeworkEvaluationCommentAssginJob < ApplicationJob
queue_as :evaluation_comment
def get_assigned_homeworks(student_works, n, index)
student_works += student_works
student_works[index + 1..index + n]
end
def perform(homework_common_id)
homework_common = HomeworkCommon.find_by(id: homework_common_id)
return if homework_common.blank?
homework_detail_manual = homework_common.homework_detail_manual
if homework_common.homework_type == "group"
student_works = homework_common.student_works.where("work_status != 0").group(:group_id)
student_work_projects = homework_common.student_works.where("work_status != 0").shuffle
student_work_projects.each do |pro_work|
n = homework_detail_manual.evaluation_num
n = (n < student_works.size && n != -1) ? n : student_works.size - 1
work_index = -1
student_works.each_with_index do |stu_work, stu_index|
if stu_work.group_id.to_i == pro_work.group_id.to_i
work_index = stu_index
end
end
assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
end
else
student_works = homework_common.student_works.has_committed
student_works = student_works.shuffle
student_works.each_with_index do |work, index|
user = work.user
n = homework_detail_manual.evaluation_num
n = (n < student_works.size && n != -1) ? n : student_works.size - 1
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
end
end
end
end

@ -0,0 +1,30 @@
class HomeworkEvaluationStartNotifyJob < ApplicationJob
queue_as :notify
def perform(homework_common_id, content)
homework = HomeworkCommon.find_by(id: homework_common_id)
return if homework.blank?
course = homework.course
members = content.blank? ? course.course_members : course.teachers
tiding_type = content.blank? ? "HomeworkCommon" : "System"
attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type
belong_container_id belong_container_type viewed tiding_type extra created_at updated_at
]
same_attrs = {
trigger_user_id: homework.user_id, container_id: homework.id, container_type: 'HomeworkCommon',
parent_container_id: homework.id, parent_container_type: 'AnonymousComment',
belong_container_id: homework.course_id, belong_container_type: 'Course',
viewed: 0, tiding_type: tiding_type, extra: content
}
Tiding.bulk_insert(*attrs) do |worker|
member_ids = members.pluck(:user_id).uniq
member_ids.each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end
end
end

@ -1,6 +1,6 @@
class HomeworkPublishUpdateWorkStatusJob < ApplicationJob class HomeworkPublishUpdateWorkStatusJob < ApplicationJob
# 作业发布时更新学生(发布前已开启过实训)的作业状态和成绩 # 作业发布时更新学生(发布前已开启过实训)的作业状态和成绩
queue_as :default queue_as :score
def perform(group_ids, homework_id) def perform(group_ids, homework_id)
# Do something later # Do something later

@ -33,19 +33,19 @@ elsif @user_course_identity == Course::STUDENT
json.late_penalty @work.late_penalty if @homework.allow_late json.late_penalty @work.late_penalty if @homework.allow_late
json.cost_time @work.myshixun.try(:total_cost_time) json.cost_time @work.myshixun.try(:total_cost_time)
json.work_score work_score_format(@work.work_score, true, @homework.score_open) json.work_score work_score_format(@work.work_score, true, @score_open)
json.final_score work_score_format(@work.final_score, true, @homework.score_open) json.final_score work_score_format(@work.final_score, true, @score_open)
json.efficiency work_score_format(@work.efficiency, true, @homework.score_open) json.efficiency work_score_format(@work.efficiency, true, @score_open)
json.eff_score work_score_format(@work.eff_score, true, @homework.score_open) json.eff_score work_score_format(@work.eff_score, true, @score_open)
json.complete_count @work.myshixun.try(:passed_count) json.complete_count @work.myshixun.try(:passed_count)
else else
json.(@work, :id, :work_status, :update_time, :ultimate_score) json.(@work, :id, :work_status, :update_time, :ultimate_score)
json.work_score work_score_format(@work.work_score, true, @homework.score_open) json.work_score work_score_format(@work.work_score, true, @score_open)
json.final_score work_score_format(@work.final_score, true, @homework.score_open) json.final_score work_score_format(@work.final_score, true, @score_open)
json.teacher_score work_score_format(@work.teacher_score, true, @homework.score_open) json.teacher_score work_score_format(@work.teacher_score, true, @score_open)
json.student_score work_score_format(@work.student_score, true, @homework.score_open) json.student_score work_score_format(@work.student_score, true, @score_open)
json.teaching_asistant_score work_score_format(@work.teaching_asistant_score, true, @homework.score_open) json.teaching_asistant_score work_score_format(@work.teaching_asistant_score, true, @score_open)
json.ta_comment_count @work.ta_comment_count json.ta_comment_count @work.ta_comment_count
@ -84,10 +84,10 @@ if @homework.homework_type == "practice"
json.(work, :id, :work_status, :update_time, :ultimate_score) json.(work, :id, :work_status, :update_time, :ultimate_score)
json.late_penalty work.late_penalty if @homework.allow_late json.late_penalty work.late_penalty if @homework.allow_late
json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open)
json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) json.final_score work_score_format(work.final_score, @current_user == work.user, @score_open)
json.efficiency work_score_format(work.efficiency, @current_user == work.user, @homework.score_open) json.efficiency work_score_format(work.efficiency, @current_user == work.user, @score_open)
json.eff_score work_score_format(work.eff_score, @current_user == work.user, @homework.score_open) json.eff_score work_score_format(work.eff_score, @current_user == work.user, @score_open)
json.cost_time work.myshixun.try(:total_cost_time) json.cost_time work.myshixun.try(:total_cost_time)
json.complete_count work.myshixun.try(:passed_count) json.complete_count work.myshixun.try(:passed_count)
@ -117,11 +117,11 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
:teaching_asistant_score, :ultimate_score) :teaching_asistant_score, :ultimate_score)
json.late_penalty work.late_penalty if @homework.allow_late json.late_penalty work.late_penalty if @homework.allow_late
json.work_score work_score_format(work.work_score, @current_user == work.user, @homework.score_open) json.work_score work_score_format(work.work_score, @current_user == work.user, @score_open)
json.final_score work_score_format(work.final_score, @current_user == work.user, @homework.score_open) json.final_score work_score_format(work.final_score, @current_user == work.user, @score_open)
json.teacher_score work_score_format(work.teacher_score, @current_user == work.user, @homework.score_open) json.teacher_score work_score_format(work.teacher_score, @current_user == work.user, @score_open)
json.student_score work_score_format(work.student_score, @current_user == work.user, @homework.score_open) json.student_score work_score_format(work.student_score, @current_user == work.user, @score_open)
json.teaching_asistant_score work_score_format(work.teaching_asistant_score, @current_user == work.user, @homework.score_open) json.teaching_asistant_score work_score_format(work.teaching_asistant_score, @current_user == work.user, @score_open)
# 助教评分次数 # 助教评分次数
json.ta_comment_count work.ta_comment_count json.ta_comment_count work.ta_comment_count

@ -3,4 +3,6 @@
:logfile: log/sidekiq.log :logfile: log/sidekiq.log
:queues: :queues:
- [default, 3] - [default, 3]
- [score, 4]
- [evaluation_comment, 5]
- [notify, 100] - [notify, 100]

@ -23,59 +23,11 @@ namespace :homework_evaluation do
else else
student_works = homework_common.student_works.has_committed student_works = homework_common.student_works.has_committed
end end
if student_works.present? && student_works.length >= 2
if homework_common.homework_type == "group"
student_work_projects = homework_common.student_works.where("work_status != 0").shuffle
student_work_projects.each_with_index do |pro_work, pro_index|
n = homework_detail_manual.evaluation_num
n = (n < student_works.size && n != -1) ? n : student_works.size - 1
work_index = -1
student_works.each_with_index do |stu_work, stu_index|
if stu_work.group_id.to_i == pro_work.group_id.to_i
work_index = stu_index
end
end
assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
#更新CourseHomeworkStatistics中该学生的待匿评数 if student_works.size >= 2
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, pro_work.user_id) HomeworkEvaluationCommentAssginJob.perform_later(homework_common.id)
# course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
end
else
student_works = student_works.shuffle
student_works.each_with_index do |work, index|
user = work.user
n = homework_detail_manual.evaluation_num
n = (n < student_works.size && n != -1) ? n : student_works.size - 1
assigned_homeworks = get_assigned_homeworks(student_works, n, index)
assigned_homeworks.each do |h|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: user.id, student_work_id: h.id)
student_works_evaluation_distributions.save
end
#更新CourseHomeworkStatistics中该学生的待匿评数
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, user.id)
# course_statistics.update_attribute('un_evaluation_work_num', course_statistics.un_evaluation_work_num + n) if course_statistics
end
end
homework_detail_manual.update_column('comment_status', 3) homework_detail_manual.update_column('comment_status', 3)
# 匿评开启消息邮件通知,# 所有人
str = ""
homework_common.course.course_members.pluck(:user_id).uniq.each do |user_id|
str += "," if str != ""
str += "('#{user_id}', '#{homework_common.user_id}', '#{homework_common.id}','HomeworkCommon','#{homework_common.id}',
'AnonymousComment',#{homework_common.course_id},'Course',0,'HomeworkCommon',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
else else
#作业数小于2启动失败, 只给老师和助教发 #作业数小于2启动失败, 只给老师和助教发
extra = "作品数量低于两个,无法开启匿评" extra = "作品数量低于两个,无法开启匿评"
@ -83,20 +35,8 @@ namespace :homework_evaluation do
else else
extra = "存在尚未截止的分班,无法开启匿评" extra = "存在尚未截止的分班,无法开启匿评"
end end
HomeworkEvaluationStartNotifyJob.perform_later(homework_common.id, extra)
if extra.present? if extra.present?
str = ''
homework_common.course.teachers.each do |mem|
str += "," if str != ""
str += "('#{mem.user.id}', '#{homework_common.user_id}', '#{homework_common.id}','HomeworkCommon','#{homework_common.id}',
'AnonymousCommentFail',#{homework_common.course_id},'Course',0,'System','#{extra}',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type,parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, extra, created_at,
updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
homework_detail_manual.update_attributes(:evaluation_start => nil, :evaluation_end => nil, :absence_penalty => 0, homework_detail_manual.update_attributes(:evaluation_start => nil, :evaluation_end => nil, :absence_penalty => 0,
:evaluation_num => 0, :appeal_time => nil, :appeal_penalty => 0) :evaluation_num => 0, :appeal_time => nil, :appeal_penalty => 0)
homework_common.update_attributes(:anonymous_comment => 0, :anonymous_appeal => 0) homework_common.update_attributes(:anonymous_comment => 0, :anonymous_appeal => 0)
@ -114,63 +54,15 @@ namespace :homework_evaluation do
homework_detail_manuals.each do |homework_detail_manual| homework_detail_manuals.each do |homework_detail_manual|
homework_common = homework_detail_manual.homework_common homework_common = homework_detail_manual.homework_common
if homework_common.anonymous_comment #开启匿评状态才可关闭匿评 if homework_common.anonymous_comment #开启匿评状态才可关闭匿评
#计算缺评扣分 参与匿评
work_ids = "(" + homework_common.student_works.has_committed.map(&:id).join(",") + ")"
homework_common.student_works.where("work_status != 0").each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count -
student_work.user.student_works_scores.where("student_work_id IN #{work_ids} and reviewer_role = 3").count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * homework_detail_manual.absence_penalty : 0
student_work.save
#更新CourseHomeworkStatistics中该学生的待匿评数和缺评数
# absence_penalty_count = absence_penalty_count > 0 ? absence_penalty_count : 0
# course_statistics = CourseHomeworkStatistics.find_by_course_id_and_user_id(homework_common.course_id, student_work.user_id)
# course_statistics.update_attribute('un_evaluation_work_num', (course_statistics.un_evaluation_work_num - absence_penalty_count) < 0 ? 0 :
# (course_statistics.un_evaluation_work_num - absence_penalty_count)) if course_statistics
# course_statistics.update_attribute('absence_evaluation_work_num', course_statistics.absence_evaluation_work_num + absence_penalty_count) if course_statistics
end
# 未参与匿评
if homework_common.homework_detail_manual.no_anon_penalty == 0
all_dis_eva = StudentWorksEvaluationDistribution.where("student_work_id IN #{work_ids}")
has_sw_count = all_dis_eva.select("distinct user_id").count
anon_count = all_dis_eva.count / has_sw_count
homework_common.student_works.where("work_status != 0").each do |student_work|
if student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count == 0
student_work.absence_penalty = homework_detail_manual.absence_penalty * anon_count
student_work.save
end
end
end
if homework_common.anonymous_appeal if homework_common.anonymous_appeal
homework_detail_manual.update_column('comment_status', 4) homework_detail_manual.update_column('comment_status', 4)
# 申诉开启 # 申诉开启发送消息
eva_distribution = StudentWorksEvaluationDistribution.where(:student_work_id => homework_common.student_works.pluck(:id)) HomeworkAnonymousAppealStartNotifyJob.perform_later(homework_common.id)
str = ""
eva_distribution.pluck(:user_id).uniq.each do |user_id|
str += "," if str != ""
str += "(#{user_id}, #{homework_common.user_id}, #{homework_common.id}, 'HomeworkCommon', #{homework_common.id},
'AnonymousAppeal', #{homework_common.course_id}, 'Course', 0, 'HomeworkCommon',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into tidings (user_id,trigger_user_id,container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
else else
homework_detail_manual.update_column('comment_status', 5) homework_detail_manual.update_column('comment_status', 5)
end end
# 匿评关闭消息通知 给所有人发
# course = homework_common.course HomeworkAbsencePenaltyCalculationJob.perform_later(homework_common.id)
# course.members.each do |m|
# homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => false, :status => 3)
# end
# 邮件通知
# Mailer.send_mail_anonymous_comment_close(homework_common).deliver
end end
end end
end end

@ -21,34 +21,29 @@ namespace :homework_publishtime do
homework_commons.each do |homework| homework_commons.each do |homework|
homework_detail_manual = homework.homework_detail_manual homework_detail_manual = homework.homework_detail_manual
homework_detail_manual.update_column('comment_status', 1) homework_detail_manual.update_column('comment_status', 1)
course = homework.course # 统一设置的作业在这发消息,非统一设置的只给有全部分班权限的老师发
students = course.students if homework.unified_setting
if !course.nil? && !students.empty? HomeworkPublishUpdateWorkStatusJob.perform_later(nil, homework.id)
HomeworkCommonPushNotifyJob.perform_later(homework.id, nil)
else
course = homework.course
teachers = course.teachers.where.not(id: course.teacher_course_groups.select(:course_member_id))
tid_str = "" tid_str = ""
course.teachers.find_each do |member| teachers.find_each do |member|
tid_str += "," if tid_str != "" tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish', tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish',
#{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', #{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end
if homework.unified_setting
students.each do |student|
tid_str += "," if tid_str != ""
tid_str += "(#{student.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id},
'HomeworkPublish', #{course.id}, 'Course', 0, 'HomeworkCommon',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
HomeworkPublishUpdateWorkStatusJob.perform_now(nil, homework.id)
end
if tid_str != "" if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id, tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at, parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at,
updated_at) values" + tid_str updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql ActiveRecord::Base.connection.execute tid_sql
end end
end end
if homework.course_acts.size == 0 if homework.course_acts.size == 0
homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id) homework.course_acts << CourseActivity.new(:user_id => homework.user_id,:course_id => homework.course_id)
end end
@ -59,27 +54,8 @@ namespace :homework_publishtime do
homework_group_settings.each do |homework_group| homework_group_settings.each do |homework_group|
homework = homework_group.homework_common homework = homework_group.homework_common
if homework.present? if homework.present?
course = homework.course
homework_detail_manual = homework.homework_detail_manual
homework_detail_manual.update_column('comment_status', 1) if homework_detail_manual.comment_status == 0
tid_str = ""
members = course.students.where(:course_group_id => homework_group.course_group_id)
members.find_each do |member|
tid_str += "," if tid_str != ""
tid_str += "(#{member.user_id}, #{homework.user_id}, #{homework.id}, 'HomeworkCommon', #{homework.id}, 'HomeworkPublish',
#{course.id}, 'Course', 0, 'HomeworkCommon', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}',
'#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if tid_str != ""
tid_sql = "insert into tidings (user_id, trigger_user_id, container_id, container_type, parent_container_id,
parent_container_type, belong_container_id, belong_container_type, viewed, tiding_type, created_at,
updated_at) values" + tid_str
ActiveRecord::Base.connection.execute tid_sql
end
HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id) HomeworkPublishUpdateWorkStatusJob.perform_now([homework_group.id], homework.id)
HomeworkCommonPushNotifyJob.perform_later(homework.id, [homework_group.id])
end end
end end
Rails.logger.info("log--------------------------------homework_publish end") Rails.logger.info("log--------------------------------homework_publish end")
@ -98,11 +74,10 @@ namespace :homework_publishtime do
student_works = homework.student_works.where("work_status != 0") student_works = homework.student_works.where("work_status != 0")
# none_student_works = homework.student_works.where("work_status = 0") # none_student_works = homework.student_works.where("work_status = 0")
else else
setting = homework.homework_group_settings.where(:end_time => homework.end_time) setting = homework.homework_group_settings.where(end_time: homework.end_time)
unless setting.blank? unless setting.blank?
users = homework.course.students.where(:course_group_id => setting.map(&:course_group_id)) users = homework.course.students.where(course_group_id: setting.pluck(:course_group_id))
user_ids = users.blank? ? "(-1)" : "(" + users.map(&:user_id).join(",") + ")" student_works = homework.student_works.where("work_status != 0").where(user_id: users.pluck(:user_id))
student_works = homework.student_works.where("work_status != 0 and user_id in #{user_ids}")
# none_student_works = homework.student_works.where("work_status = 0 and user_id in #{user_ids}") # none_student_works = homework.student_works.where("work_status = 0 and user_id in #{user_ids}")
end end
end end
@ -172,8 +147,7 @@ namespace :homework_publishtime do
# homework_challenge_settings = homework.homework_challenge_settings # homework_challenge_settings = homework.homework_challenge_settings
users = homework.course.students.where(:course_group_id => homework_setting.course_group_id) users = homework.course.students.where(:course_group_id => homework_setting.course_group_id)
user_ids = users.blank? ? "(-1)" : "(" + users.map(&:user_id).join(",") + ")" student_works = homework.student_works.where("work_status != 0").where(user_id: users.pluck(:user_id))
student_works = homework.student_works.where("work_status != 0 and user_id in #{user_ids}")
student_works.joins(:myshixun).where("myshixuns.status != 1").update_all(late_penalty: homework.late_penalty) if student_works.present? student_works.joins(:myshixun).where("myshixuns.status != 1").update_all(late_penalty: homework.late_penalty) if student_works.present?
else else
# HomeworksService.new.update_student_eff_score homework # 分班设置的不需要另外算效率分 # HomeworksService.new.update_student_eff_score homework # 分班设置的不需要另外算效率分

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

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

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

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