@ -6,9 +6,11 @@ class ZipsController < ApplicationController
before_action :require_admin_or_teacher
before_action :require_admin_or_teacher
def shixun_report
def shixun_report
student_work_ids = Array . wrap ( params [ :student_work_ids ] )
# student_work_ids = Array.wrap(params[:student_work_ids])
# service = BatchExportShixunReportService.new(@homework, @student_work_ids)
service = BatchExportShixunReportService . new ( @homework , @all_student_works )
service = BatchExportShixunReportService . new ( @homework , student_work_ids )
filename = filename_for_content_disposition ( service . filename )
filename = filename_for_content_disposition ( service . filename )
send_file service . zip , filename : filename , type : 'application/zip'
send_file service . zip , filename : filename , type : 'application/zip'
@ -47,9 +49,26 @@ class ZipsController < ApplicationController
normal_status ( - 1 , " 试卷不存在 " )
normal_status ( - 1 , " 试卷不存在 " )
else
else
@course = @exercise . course
@course = @exercise . course
default_ex_users = @exercise . all_exercise_users ( current_user . id ) . exercise_user_committed
default_ex_users = @exercise . all_exercise_users ( current_user . id ) . exercise_user_committed
@ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
@ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
#是否评阅
if params [ :review ] . present?
review_type = params [ :review ] . first . to_i #已评, 则数据为1, 未评, 则数据为0,前端传过来的为数组
if review_type == 1
@ex_users = @ex_users . where ( " subjective_score >= ? " , 0 . 0 )
else
@ex_users = @ex_users . where ( " subjective_score < ? " , 0 . 0 )
end
end
#答题状态的选择
if params [ :commit_status ] . present? && ( params [ :commit_status ] . to_i == 1 )
@exercise_users_list = @exercise_users_list . where ( commit_status : params [ :commit_status ] )
elsif params [ :commit_status ] . present? && ( params [ :commit_status ] . to_i == 0 )
normal_status ( - 1 , " 仅支持导出已提交的学生! " )
end
#可以分班选择
#可以分班选择
if group_id . present?
if group_id . present?
exercise_students = @course . students . where ( course_group_id : group_id ) # 试卷所分班的全部人数
exercise_students = @course . students . where ( course_group_id : group_id ) # 试卷所分班的全部人数
@ -57,9 +76,14 @@ class ZipsController < ApplicationController
@ex_users = @ex_users . where ( user_id : user_ids )
@ex_users = @ex_users . where ( user_id : user_ids )
end
end
default_ex_users_size = @ex_users . size
#搜索
if params [ :search ] . present?
@ex_users = @ex_users . joins ( user : :user_extension ) . where ( " CONCAT(lastname, firstname) like ? OR student_id like ? " , " % #{ params [ :search ] } % " , " % #{ params [ :search ] } % " )
end
default_ex_users_size = @ex_users & . size
if default_ex_users_size == 0
if default_ex_users_size . blank? || default_ex_users_size == 0
normal_status ( - 1 , " 导出失败,暂时没有已提交的学生 " )
normal_status ( - 1 , " 导出失败,暂时没有已提交的学生 " )
elsif default_ex_users_size > 100
elsif default_ex_users_size > 100
normal_status ( - 2 , " 100 " )
normal_status ( - 2 , " 100 " )
@ -75,5 +99,33 @@ class ZipsController < ApplicationController
def load_homework
def load_homework
@homework = HomeworkCommon . find ( params [ :homework_common_id ] )
@homework = HomeworkCommon . find ( params [ :homework_common_id ] )
@course = @homework . course
@course = @homework . course
##7。2 -hs新增
@member = @course . course_member ( current_user . id )
@all_student_works = @homework . teacher_works ( @member )
work_status = params [ :work_status ]
group_id = params [ :course_group ]
if work_status . present? && ! work_status . include? ( 0 )
@all_student_works = @all_student_works . where ( work_status : work_status )
elsif work_status . present? && work_status . include? ( 0 )
normal_status ( - 1 , " 仅支持导出已提交的学生! " )
end
if group_id . present?
group_user_ids = @course . students . where ( course_group_id : params [ :course_group ] ) . pluck ( :user_id )
@all_student_works = @all_student_works . where ( user_id : group_user_ids )
end
unless params [ :search ] . blank?
@all_student_works = @all_student_works . joins ( user : :user_extension ) . where ( " concat(lastname, firstname) like ?
or student_id like ?" , " % #{ params [ :search ] } % " , " % #{ params [ :search ] } % " )
end
student_work_sizes = @all_student_works & . size
if student_work_sizes . blank? || student_work_sizes == 0
normal_status ( - 1 , " 导出失败,暂时没有已提交的学生 " )
elsif student_work_sizes > 100
normal_status ( - 2 , " 100 " )
end
end
end
end
end