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

dev_forum
daiao 5 years ago
commit 8e517b84fb

@ -106,11 +106,10 @@ class HomeworkCommonsController < ApplicationController
student_works = @homework.all_works
@all_member_count = student_works.size
logger.info("##########__________@homework.publish_time______________#############{@homework.publish_time}")
if @homework.publish_time.blank? || (@homework.publish_time > Time.now)
if @homework.publish_time.nil? || (@homework.publish_time > Time.now)
@student_works = []
if params[:format] == "xlsx" || params[:format] == "zip"
logger.info("##########__________params[:format]______________#############{params[:format]}")
if (params[:format] == "xlsx") || (params[:format] == "zip")
normal_status(-1,"作业未发布")
end
else
@ -198,7 +197,7 @@ class HomeworkCommonsController < ApplicationController
end
if params[:format] == "xlsx"
complete_works = @work_excel.where("work_status > 0").size
complete_works = @work_excel.present? ? @work_excel.where("work_status > 0").size : 0
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
elsif complete_works == 0
@ -218,8 +217,13 @@ class HomeworkCommonsController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
else
zip_works = @work_excel.where("work_status > 0")
status = checkfileSize(zip_works)
if @work_excel.present?
zip_works = @work_excel&.where("work_status > 0")
status = checkfileSize(zip_works)
else
status = -1
end
if status == 0
respond_to do |format|
format.zip{

@ -6,6 +6,7 @@ class ExercisePublishNotifyJob < ApplicationJob
exercise = Exercise.find_by(id: exercise_id)
return if exercise.blank?
user = exercise.user
course = exercise.course
if group_ids.present?
students = course.students.where(course_group_id: group_ids)

@ -5,6 +5,8 @@ class GraduationTaskPublishNotifyJob < ApplicationJob
def perform(graduation_task_id)
task = GraduationTask.find_by(id: graduation_task_id)
return if task.blank?
course = task.course
return if course.blank?
attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type
@ -18,7 +20,7 @@ class GraduationTaskPublishNotifyJob < ApplicationJob
viewed: 0, tiding_type: 'GraduationTask'
}
Tiding.bulk_insert(*attrs) do |worker|
task.course.course_members.pluck(:user_id).uniq.find_each do |user_id|
course.course_members.pluck(:user_id).uniq.find_each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end

@ -19,11 +19,12 @@ class SubmitGraduationWorkNotifyJob < ApplicationJob
next unless User.exists?(id: user_id)
work = task.graduation_works.find_by(user_id: user_id)
next if work.blank?
member = course.students.find_by(user_id: user_id)
next if work.blank? || member.blank?
attrs = same_attrs.merge(trigger_user_id: user_id, container_id: work.id)
course.course_member(user_id).member_teachers.find_each do |teacher|
member.member_teachers.find_each do |teacher|
worker.add attrs.merge(user_id: teacher.user_id)
end
end

@ -19,11 +19,12 @@ class SubmitStudentWorkNotifyJob < ApplicationJob
next unless User.exists?(id: user_id)
work = homework.student_works.find_by(user_id: user_id)
next if work.blank?
member = course.students.find_by(user_id: user_id)
next if work.blank? || member.blank?
attrs = same_attrs.merge(trigger_user_id: user_id, container_id: work.id)
course.course_member(user_id).member_teachers.find_each do |teacher|
member.member_teachers.find_each do |teacher|
worker.add attrs.merge(user_id: teacher.user_id)
end
end

@ -146,11 +146,11 @@ class CourseMember < ApplicationRecord
def member_teachers
teacher_groups = course.teacher_course_groups
if teacher_groups.count > 0
member_ids = teacher_groups.where(course_group_id: self.try(:course_group_id)).pluck(:course_member_id)
member_ids = teacher_groups.where(course_group_id: self.try(:course_group_id)).pluck(:course_member_id).compact
none_group_teachers = teacher_groups.pluck(:course_member_id).size > 0 ? teacher_groups.pluck(:course_member_id).join(',') : -1
teachers = course.teachers.where("members.id not in (#{none_group_teachers}) or
members.id in (#{member_ids.size > 0 ? member_ids.join(',') : -1})")
none_group_teachers = teacher_groups.pluck(:course_member_id).size > 0 ? teacher_groups.pluck(:course_member_id).compact.join(',') : -1
teachers = course.teachers.where("course_members.id not in (#{none_group_teachers}) or
course_members.id in (#{member_ids.size > 0 ? member_ids.join(',') : -1})")
else
teachers = course.teachers
end

Loading…
Cancel
Save