|
|
|
@ -102,8 +102,8 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 只看我的交叉评阅
|
|
|
|
|
unless params[:cross_comment].blank?
|
|
|
|
|
graduation_work_id = @task.formal_graduation_work_comment_assignations.where(:user_id =>current_user.id)
|
|
|
|
|
.pluck(:graduation_work_id).uniq if @task.formal_graduation_work_comment_assignations
|
|
|
|
|
graduation_work_id = @task.graduation_work_comment_assignations.where(:user_id =>current_user.id)
|
|
|
|
|
.pluck(:graduation_work_id).uniq if @task.graduation_work_comment_assignations
|
|
|
|
|
@work_list = @task.graduation_works.where(id: graduation_work_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -459,9 +459,7 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
|
|
|
|
|
@task.comment_status = 2 if @task.cross_comment && @task.comment_status == 0
|
|
|
|
|
|
|
|
|
|
# unless @task.cross_comment
|
|
|
|
|
# @task.graduation_work_comment_assignations.destroy_all
|
|
|
|
|
# end
|
|
|
|
|
@task.graduation_work_comment_assignations.destroy_all if !@task.cross_comment
|
|
|
|
|
# 去掉评阅设置
|
|
|
|
|
# @task.comment_num = @task.cross_comment ? params[:comment_num].to_i : 3
|
|
|
|
|
# @task.comment_status = @task.cross_comment ? params[:comment_status] : 0
|
|
|
|
@ -512,8 +510,14 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
group_ids = group_ids & params[:group_ids].map(&:to_i) unless params[:group_ids].blank?
|
|
|
|
|
page = params[:page] ? params[:page].to_i : 1
|
|
|
|
|
limit = params[:limit] ? params[:limit].to_i : 10
|
|
|
|
|
@work_list = @task.graduation_works.joins("join course_members on graduation_works.user_id=course_members.user_id").
|
|
|
|
|
where(course_members: {course_group_id: group_ids})
|
|
|
|
|
|
|
|
|
|
# 取所有课堂的作品
|
|
|
|
|
if group_ids.sort == @course.course_groups.pluck(:id).sort
|
|
|
|
|
@work_list = @task.graduation_works
|
|
|
|
|
else
|
|
|
|
|
@work_list = @task.graduation_works.joins("join course_members on graduation_works.user_id=course_members.user_id").
|
|
|
|
|
where(course_members: {course_group_id: group_ids})
|
|
|
|
|
end
|
|
|
|
|
@user_count = @work_list.size
|
|
|
|
|
@work_list = @work_list.page(page).per(limit).includes(user: [:user_extension])
|
|
|
|
|
@students = @course.students.where(user_id: @work_list.pluck(:user_id))
|
|
|
|
@ -528,25 +532,27 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
works = @task.graduation_works.where(id: params[:work_ids])
|
|
|
|
|
# 手动分配:分配给老师
|
|
|
|
|
if !params[:user_ids].blank?
|
|
|
|
|
@task.update_attributes(comment_status: 2)
|
|
|
|
|
works.each do |work|
|
|
|
|
|
# 之前分配的老师但现在未分配时,置为删除位,点取消时需要还原,点确认时再删除
|
|
|
|
|
work.graduation_work_comment_assignations.where.not(user_id: params[:user_ids]).update_all(temporary: 2)
|
|
|
|
|
# 之前分配的老师但现在未分配时需要删除
|
|
|
|
|
work.graduation_work_comment_assignations.where.not(user_id: params[:user_ids]).destroy_all
|
|
|
|
|
@course.teachers.where(user_id: params[:user_ids]).pluck(:user_id).uniq.each do |user_id|
|
|
|
|
|
unless work.graduation_work_comment_assignations.exists?(user_id: user_id)
|
|
|
|
|
GraduationWorkCommentAssignation.create!(graduation_task_id: @task.id, graduation_work_id: work.id,
|
|
|
|
|
user_id: user_id, temporary: 1)
|
|
|
|
|
user_id: user_id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 答辩组分配:分配答辩组
|
|
|
|
|
elsif !params[:graduation_group_ids].blank?
|
|
|
|
|
@task.update_attributes(comment_status: 4)
|
|
|
|
|
works.each do |work|
|
|
|
|
|
work.graduation_task_group_assignations.where.not(graduation_group_id: params[:graduation_group_ids]).update_all(temporary: 2)
|
|
|
|
|
work.graduation_task_group_assignations.where.not(graduation_group_id: params[:graduation_group_ids]).destroy_all
|
|
|
|
|
@course.graduation_groups.where(id: params[:graduation_group_ids]).pluck(:id).uniq.each do |graduation_group_id|
|
|
|
|
|
unless work.graduation_task_group_assignations.exists?(graduation_group_id: graduation_group_id)
|
|
|
|
|
GraduationTaskGroupAssignation.create!(graduation_task_id: @task.id, graduation_work_id: work.id,
|
|
|
|
|
graduation_group_id: graduation_group_id, temporary: 1)
|
|
|
|
|
graduation_group_id: graduation_group_id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -565,28 +571,28 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
# 提交弹框
|
|
|
|
|
if params[:type] == "commit"
|
|
|
|
|
tip_exception("comment_status参数有误") if params[:comment_status].blank? || ![2, 4].include?(params[:comment_status].to_i)
|
|
|
|
|
@task.update_attributes(comment_status: params[:comment_status])
|
|
|
|
|
if params[:comment_status].to_i == 2
|
|
|
|
|
@task.temporary_graduation_work_comment_assignations.update_all(temporary: 0) # 临时数据转正
|
|
|
|
|
@task.delete_graduation_work_comment_assignations.destroy_all # 删除置了删除位的数据
|
|
|
|
|
@task.graduation_task_group_assignations.destroy_all # 删除答辩组分配数据
|
|
|
|
|
else
|
|
|
|
|
@task.temporary_graduation_task_group_assignations.update_all(temporary: 0)
|
|
|
|
|
@task.delete_graduation_task_group_assignations.destroy_all
|
|
|
|
|
@task.graduation_work_comment_assignations.destroy_all
|
|
|
|
|
|
|
|
|
|
GraduationTaskCrossCommentJob.perform_later(@task.id)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
# 取消时删除临时数据,恢复删除位数据
|
|
|
|
|
@task.temporary_graduation_work_comment_assignations.destroy_all # 删除临时数据
|
|
|
|
|
@task.delete_graduation_work_comment_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
|
|
|
|
|
|
|
|
|
|
@task.temporary_graduation_task_group_assignations.destroy_all # 删除临时数据
|
|
|
|
|
@task.delete_graduation_task_group_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
|
|
|
|
|
end
|
|
|
|
|
# if params[:type] == "commit"
|
|
|
|
|
# tip_exception("comment_status参数有误") if params[:comment_status].blank? || ![2, 4].include?(params[:comment_status].to_i)
|
|
|
|
|
# @task.update_attributes(comment_status: params[:comment_status])
|
|
|
|
|
# if params[:comment_status].to_i == 2
|
|
|
|
|
# @task.temporary_graduation_work_comment_assignations.update_all(temporary: 0) # 临时数据转正
|
|
|
|
|
# @task.delete_graduation_work_comment_assignations.destroy_all # 删除置了删除位的数据
|
|
|
|
|
# @task.graduation_task_group_assignations.destroy_all # 删除答辩组分配数据
|
|
|
|
|
# else
|
|
|
|
|
# @task.temporary_graduation_task_group_assignations.update_all(temporary: 0)
|
|
|
|
|
# @task.delete_graduation_task_group_assignations.destroy_all
|
|
|
|
|
# @task.graduation_work_comment_assignations.destroy_all
|
|
|
|
|
#
|
|
|
|
|
# GraduationTaskCrossCommentJob.perform_later(@task.id)
|
|
|
|
|
# end
|
|
|
|
|
# else
|
|
|
|
|
# # 取消时删除临时数据,恢复删除位数据
|
|
|
|
|
# @task.temporary_graduation_work_comment_assignations.destroy_all # 删除临时数据
|
|
|
|
|
# @task.delete_graduation_work_comment_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
|
|
|
|
|
#
|
|
|
|
|
# @task.temporary_graduation_task_group_assignations.destroy_all # 删除临时数据
|
|
|
|
|
# @task.delete_graduation_task_group_assignations.update_all(temporary: 0) # 恢复置了删除位的数据
|
|
|
|
|
# end
|
|
|
|
|
normal_status("操作成功")
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|