zip导出的问题修改

dev_course
SylorHuang 5 years ago
parent db69b3737c
commit 7d81be96a5

@ -1300,7 +1300,9 @@ class ExercisesController < ApplicationController
if params[:format] == "xlsx"
if @user_course_identity > Course::ASSISTANT_PROFESSOR
tip_exception(403,"无权限操作")
elsif (@exercise_status == 1) || (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
elsif @exercise_status == 1
normal_status(-1,"试卷未发布")
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
normal_status(-1,"暂无用户提交")
else
respond_to do |format|

@ -6,12 +6,9 @@ class ZipsController < ApplicationController
before_action :require_admin_or_teacher
def shixun_report
# student_work_ids = Array.wrap(params[:student_work_ids])
# service = BatchExportShixunReportService.new(@homework, @student_work_ids)
service = BatchExportShixunReportService.new(@homework, @all_student_works)
filename = filename_for_content_disposition(service.filename)
send_file service.zip, filename: filename, type: 'application/zip'
rescue BatchExportShixunReportService::Error => ex
@ -23,8 +20,8 @@ class ZipsController < ApplicationController
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
file_name = filename_for_content_disposition(exercises.filename)
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
rescue Exception => e
normal_status(-1, e.message)
end
@ -44,7 +41,7 @@ class ZipsController < ApplicationController
ActiveRecord::Base.transaction do
begin
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
@exercise_status = @exercise.get_exercise_status(current_user.id)
@exercise_status = @exercise.present? ? @exercise.get_exercise_status(current_user.id) : 1
group_id = params[:exercise_group_id]
if @exercise.blank?
normal_status(-1,"试卷不存在")
@ -101,11 +98,16 @@ class ZipsController < ApplicationController
def load_homework
@homework = HomeworkCommon.find(params[:homework_common_id])
@homework_status = @homework.present? ? @homework.homework_detail_manual.comment_status : 0
if @homework.blank?
normal_status(-1,"该作业不存在")
elsif @homework_status == 0
normal_status(-1,"该作业未发布")
else
@course = @homework.course
##7。2 -hs新增
@member = @course.course_member(current_user.id)
@all_student_works = @homework.teacher_works(@member).where("work_status > 0")
work_status = params[:work_status]
group_id = params[:course_group]
@ -131,4 +133,5 @@ class ZipsController < ApplicationController
normal_status(-2,"100")
end
end
end
end

@ -3,7 +3,6 @@ class BatchExportShixunReportService
MAX_BATCH_LIMIT = 20
# attr_reader :homework, :student_work_ids
attr_reader :homework, :all_student_works
@ -15,7 +14,7 @@ class BatchExportShixunReportService
end
def filename
@_filename ||= "#{Time.now.strftime('%Y%m%d%H%M%S')}-#{homework.name}.zip"
@_filename ||= "#{homework.name}-#{Time.now.strftime('%Y%m%d%H%M%S')}.zip"
end
def zip
@ -45,15 +44,4 @@ 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
end

Loading…
Cancel
Save