dev_forum
SylorHuang 5 years ago
parent 338c53b769
commit 254a643b4f

@ -1300,8 +1300,6 @@ class ExercisesController < ApplicationController
if @export_ex_users.exercise_user_committed.size == 0
normal_status(-1,"暂无用户提交")
else
@exercise = @exercise.includes(:exercise_questions)
@export_ex_users = @export_ex_users.includes(user: :user_extension)
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"

@ -129,9 +129,13 @@ class GraduationTasksController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
else
graduation_work_to_xlsx(@work_excel,@task,current_user)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @task.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
if @work_count > 1
graduation_work_to_xlsx(@work_excel,@task,current_user)
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
else
normal_status(-1,"暂无提交的学生!")
end
end
}
format.zip{

@ -206,8 +206,7 @@ class HomeworkCommonsController < ApplicationController
if @user_course_identity >= Course::STUDENT
tip_exception(403, "无权限操作")
else
if @work_excel.present?
@homework = @homework.includes(:shixuns,:homework_detail_manual)
if @work_count > 1
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')

@ -6,9 +6,11 @@ class ZipsController < ApplicationController
before_action :require_admin_or_teacher
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)
send_file service.zip, filename: filename, type: 'application/zip'
@ -57,9 +59,9 @@ class ZipsController < ApplicationController
@ex_users = @ex_users.where(user_id: user_ids)
end
default_ex_users_size = @ex_users.size
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,"导出失败,暂时没有已提交的学生")
elsif default_ex_users_size > 100
normal_status(-2,"100")
@ -75,5 +77,14 @@ class ZipsController < ApplicationController
def load_homework
@homework = HomeworkCommon.find(params[:homework_common_id])
@course = @homework.course
##7。2 -hs新增
@member = @course.course_member(current_user.id)
@all_student_works = @homework.teacher_works(@member)
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

@ -3,11 +3,15 @@ class BatchExportShixunReportService
MAX_BATCH_LIMIT = 20
attr_reader :homework, :student_work_ids
# attr_reader :homework, :student_work_ids
attr_reader :homework, :all_student_works
def initialize(homework, student_work_ids)
def initialize(homework, all_student_works)
@homework = homework
@student_work_ids = student_work_ids
# @student_work_ids = student_work_ids
@all_student_works = all_student_works
end
def filename
@ -15,8 +19,8 @@ class BatchExportShixunReportService
end
def zip
validate!
student_works = homework.student_works.where(id: student_work_ids).includes(:myshixun, user: :user_extension)
# validate!
student_works = all_student_works.includes(:myshixun, user: :user_extension)
if student_works.count.zero?
raise Error, '请选择要导出的学生实训报告'
@ -41,15 +45,15 @@ class BatchExportShixunReportService
end
end
private
def validate!
if student_work_ids.size.zero?
raise Error, '请选择学生实训作业'
end
if student_work_ids.size > MAX_BATCH_LIMIT
raise Error, '导出实训报告太多,请分批导出'
end
end
# private
#
# def validate!
# if student_work_ids.size.zero?
# raise Error, '请选择学生实训作业'
# end
#
# if student_work_ids.size > MAX_BATCH_LIMIT
# raise Error, '导出实训报告太多,请分批导出'
# end
# end
end

Loading…
Cancel
Save