|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
class GraduationTasksController < ApplicationController
|
|
|
|
|
before_action :require_login, :check_auth, except: [:index]
|
|
|
|
|
before_action :find_course, except: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment,
|
|
|
|
|
:cross_comment_setting, :assign_works, :commit_comment_setting]
|
|
|
|
|
:cross_comment_setting, :assign_works, :commit_comment_setting, :sonar]
|
|
|
|
|
before_action :find_task, only: [:edit, :update, :settings, :update_settings, :tasks_list, :show, :show_comment,
|
|
|
|
|
:cross_comment_setting, :assign_works, :commit_comment_setting]
|
|
|
|
|
:cross_comment_setting, :assign_works, :commit_comment_setting, :sonar]
|
|
|
|
|
before_action :user_course_identity
|
|
|
|
|
before_action :task_publish, only: [:show, :show_comment, :tasks_list, :settings]
|
|
|
|
|
before_action :teacher_allowed, only: [:new, :create, :edit, :update, :set_public,:multi_destroy, :publish_task, :end_task,
|
|
|
|
@ -66,62 +66,8 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
(@user_course_identity == Course::STUDENT && @work.present? && @work.take.work_status > 0 &&
|
|
|
|
|
((!@task.allow_late && @task.status > 1) || (@task.allow_late && @task.late_time && @task.late_time < Time.now)) &&
|
|
|
|
|
(@task.open_work || @task.open_score)))
|
|
|
|
|
# 如有有分班则看分班内的学生,否则看所有学生的作品
|
|
|
|
|
user_ids =
|
|
|
|
|
if @user_course_identity < Course::STUDENT
|
|
|
|
|
@course.teacher_group_user_ids(current_user.id)
|
|
|
|
|
else
|
|
|
|
|
course_group_id = @course.course_member(current_user.id).course_group_id
|
|
|
|
|
@course.students.where(course_group_id: course_group_id).pluck(:user_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
|
|
|
|
|
@all_work_count = @work_list.count
|
|
|
|
|
@teachers = @course.teachers.where.not(user_id: current_user.id).includes(:user)
|
|
|
|
|
# 教师评阅搜索 0: 未评, 1 已评
|
|
|
|
|
unless params[:teacher_comment].blank?
|
|
|
|
|
graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id)
|
|
|
|
|
if params[:teacher_comment].to_i == 0
|
|
|
|
|
@work_list = @work_list.where("work_status != 0")
|
|
|
|
|
elsif params[:teacher_comment].to_i == 1
|
|
|
|
|
@work_list = @work_list.where("work_status != 0").where(id: graduation_work_ids)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 作品状态 0: 未提交, 1 按时提交, 2 延迟提交
|
|
|
|
|
unless params[:task_status].blank?
|
|
|
|
|
@work_list = @work_list.where(work_status: params[:task_status])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 分班情况
|
|
|
|
|
unless params[:course_group].blank?
|
|
|
|
|
group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
|
|
|
|
|
# 有分组只可能是老师身份查看列表
|
|
|
|
|
@work_list = @work_list.where(user_id: group_user_ids)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 只看我的交叉评阅
|
|
|
|
|
unless params[:cross_comment].blank?
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# 组员、组长作品的筛选
|
|
|
|
|
if @task.task_type == 2 && !params[:member_work].blank?
|
|
|
|
|
if params[:member_work].to_i == 1
|
|
|
|
|
@work_list = @work_list.where("user_id = commit_user_id")
|
|
|
|
|
elsif params[:member_work].to_i == 0
|
|
|
|
|
@work_list = @work_list.where("user_id != commit_user_id")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 输入姓名和学号搜索
|
|
|
|
|
# TODO user_extension 如果修改 请调整
|
|
|
|
|
unless params[:search].blank?
|
|
|
|
|
@work_list = @work_list.joins(user: :user_extension).where("concat(lastname, firstname) like ?
|
|
|
|
|
or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
|
|
|
|
|
end
|
|
|
|
|
_tasks_list
|
|
|
|
|
|
|
|
|
|
# 排序
|
|
|
|
|
rorder = params[:order].blank? ? "update_time" : params[:order]
|
|
|
|
@ -265,6 +211,33 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 代码检测
|
|
|
|
|
def sonar
|
|
|
|
|
tip_exception(403, "无权限访问") unless current_user.admin_or_business?
|
|
|
|
|
|
|
|
|
|
_tasks_list
|
|
|
|
|
|
|
|
|
|
person_list = @work_list.map do |work|
|
|
|
|
|
o = {
|
|
|
|
|
name: "#{work.user&.real_name}",
|
|
|
|
|
uid: "#{work.user&.student_id}",
|
|
|
|
|
downloadUrl: ''
|
|
|
|
|
}
|
|
|
|
|
attachment = work.attachments.last
|
|
|
|
|
if attachment
|
|
|
|
|
o[:downloadUrl] = "https://#{edu_setting('host_name')}/"+download_url(attachment)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
o
|
|
|
|
|
end
|
|
|
|
|
filename = "#{@task.name}_#{Time.now.strftime('%Y%m%d%H%M%S')}.json"
|
|
|
|
|
json = File.open("/tmp/#{filename}", "w+")
|
|
|
|
|
json.puts(person_list.to_json)
|
|
|
|
|
json.close
|
|
|
|
|
|
|
|
|
|
send_file json.path, filename: filename
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 设为公开
|
|
|
|
|
def set_public
|
|
|
|
|
tip_exception("仅公开课堂才能公开毕设任务") if @course.is_public == 0
|
|
|
|
@ -657,6 +630,65 @@ class GraduationTasksController < ApplicationController
|
|
|
|
|
tip_exception("请先开启交叉评阅再设置") unless @task.cross_comment
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def _tasks_list
|
|
|
|
|
# 如有有分班则看分班内的学生,否则看所有学生的作品
|
|
|
|
|
user_ids =
|
|
|
|
|
if @user_course_identity < Course::STUDENT
|
|
|
|
|
@course.teacher_group_user_ids(current_user.id)
|
|
|
|
|
else
|
|
|
|
|
course_group_id = @course.course_member(current_user.id).course_group_id
|
|
|
|
|
@course.students.where(course_group_id: course_group_id).pluck(:user_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@work_list = @task.graduation_works.where(user_id: user_ids).includes(user: [:user_extension])
|
|
|
|
|
@all_work_count = @work_list.count
|
|
|
|
|
@teachers = @course.teachers.where.not(user_id: current_user.id).includes(:user)
|
|
|
|
|
# 教师评阅搜索 0: 未评, 1 已评
|
|
|
|
|
unless params[:teacher_comment].blank?
|
|
|
|
|
graduation_work_ids = GraduationWorkScore.where(graduation_work_id: @work_list.map(&:id)).pluck(:graduation_work_id)
|
|
|
|
|
if params[:teacher_comment].to_i == 0
|
|
|
|
|
@work_list = @work_list.where("work_status != 0")
|
|
|
|
|
elsif params[:teacher_comment].to_i == 1
|
|
|
|
|
@work_list = @work_list.where("work_status != 0").where(id: graduation_work_ids)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 作品状态 0: 未提交, 1 按时提交, 2 延迟提交
|
|
|
|
|
unless params[:task_status].blank?
|
|
|
|
|
@work_list = @work_list.where(work_status: params[:task_status])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 分班情况
|
|
|
|
|
unless params[:course_group].blank?
|
|
|
|
|
group_user_ids = @course.students.where(course_group_id: params[:course_group]).pluck(:user_id)
|
|
|
|
|
# 有分组只可能是老师身份查看列表
|
|
|
|
|
@work_list = @work_list.where(user_id: group_user_ids)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 只看我的交叉评阅
|
|
|
|
|
unless params[:cross_comment].blank?
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# 组员、组长作品的筛选
|
|
|
|
|
if @task.task_type == 2 && !params[:member_work].blank?
|
|
|
|
|
if params[:member_work].to_i == 1
|
|
|
|
|
@work_list = @work_list.where("user_id = commit_user_id")
|
|
|
|
|
elsif params[:member_work].to_i == 0
|
|
|
|
|
@work_list = @work_list.where("user_id != commit_user_id")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 输入姓名和学号搜索
|
|
|
|
|
# TODO user_extension 如果修改 请调整
|
|
|
|
|
unless params[:search].blank?
|
|
|
|
|
@work_list = @work_list.joins(user: :user_extension).where("concat(lastname, firstname) like ?
|
|
|
|
|
or student_id like ?", "%#{params[:search]}%", "%#{params[:search]}%")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# def graduation_work_to_xls items
|
|
|
|
|
# xls_report = StringIO.new
|
|
|
|
|