毕设任务调整

dev_ec
cxt 5 years ago
parent 04406419f3
commit 2606717142

@ -503,8 +503,8 @@ class ApplicationController < ActionController::Base
# 只看我的交叉评阅
if option[:cross_comment]
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 = work_list.where(id: graduation_work_id)
end

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

@ -308,7 +308,7 @@ class GraduationWorksController < ApplicationController
end
end
if @work.formal_graduation_work_comment_assignations.where(user_id: current_user.id).count > 0
if @task.cross_comment && @work.graduation_work_comment_assignations.where(user_id: current_user.id).count > 0
new_score.reviewer_role = 2
else
new_score.reviewer_role = 1

@ -15,7 +15,7 @@ module GraduationTasksHelper
# 交叉评阅
def cross_comment task, user_id
if task.cross_comment && task.status >= 3
[{id: 1, name: "只看我的交叉评阅", count: task.formal_graduation_work_comment_assignations.myself(user_id).count}]
[{id: 1, name: "只看我的交叉评阅", count: task.graduation_work_comment_assignations.myself(user_id).count}]
else
[]
end

@ -12,7 +12,9 @@ class GraduationTaskCrossCommentJob < ApplicationJob
if graduation_group.present? && work.present?
member_ids = graduation_group.course_members.pluck(:user_id).uniq
member_ids.each do |user_id|
work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(user_id: user_id, graduation_task_id: task.id)
unless work.graduation_work_comment_assignations.exists?(user_id: user_id)
work.graduation_work_comment_assignations << GraduationWorkCommentAssignation.new(user_id: user_id, graduation_task_id: task.id)
end
end
end
end

@ -14,14 +14,14 @@ class GraduationTask < ApplicationRecord
has_many :attachments, as: :container, dependent: :destroy
has_many :graduation_work_comment_assignations, dependent: :destroy
has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
has_many :delete_graduation_work_comment_assignations, -> { temporary_delete }, class_name: "GraduationWorkCommentAssignation"
# has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
# has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
# has_many :delete_graduation_work_comment_assignations, -> { temporary_delete }, class_name: "GraduationWorkCommentAssignation"
#
has_many :graduation_task_group_assignations, dependent: :destroy
has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
has_many :delete_graduation_task_group_assignations, -> { temporary_delete }, class_name: "GraduationTaskGroupAssignation"
# has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
# has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
# has_many :delete_graduation_task_group_assignations, -> { temporary_delete }, class_name: "GraduationTaskGroupAssignation"
has_many :graduation_works, -> { where("is_delete = 0") }
has_many :score_graduation_works, -> { where("is_delete = 0 and work_status != 0").order("work_score desc") }, class_name: "GraduationWork"

@ -11,12 +11,12 @@ class GraduationWork < ApplicationRecord
has_many :graduation_work_scores, dependent: :destroy
has_many :graduation_work_comment_assignations, dependent: :destroy
has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
# has_many :formal_graduation_work_comment_assignations, -> { formal }, class_name: "GraduationWorkCommentAssignation"
# has_many :temporary_graduation_work_comment_assignations, -> { temporary }, class_name: "GraduationWorkCommentAssignation"
has_many :graduation_task_group_assignations, dependent: :destroy
has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
# has_many :formal_graduation_task_group_assignations, -> { formal }, class_name: "GraduationTaskGroupAssignation"
# has_many :temporary_graduation_task_group_assignations, -> { temporary }, class_name: "GraduationTaskGroupAssignation"
validates :description, length: { maximum: 5000 }

@ -44,9 +44,9 @@ namespace :graduation_task do
tasks = GraduationTask.where("cross_comment = 1 and comment_time is not null and comment_time <= '#{Time.now}' and status = 2")
tasks.each do |task|
# 改成设置时都实时分配
# if task.comment_status == 4
# GraduationTaskCrossCommentJob.perform_later(task.id)
# end
if task.comment_status == 4
GraduationTaskCrossCommentJob.perform_later(task.id)
end
task.update_attributes(status: 3)
# 给老师发消息

Loading…
Cancel
Save