|
|
@ -17,7 +17,7 @@ class ZipsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def export_exercises
|
|
|
|
def export_exercises
|
|
|
|
exercises = ExportExercisesService.new(@exercise,@ex_users)
|
|
|
|
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
|
|
|
|
|
|
|
|
|
|
|
|
file_name = filename_for_content_disposition(exercises.filename)
|
|
|
|
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'
|
|
|
@ -41,6 +41,7 @@ class ZipsController < ApplicationController
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
begin
|
|
|
|
begin
|
|
|
|
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
|
|
|
|
@exercise = Exercise.includes(:exercise_users,:exercise_questions).find_by(id:params[:exercise_id])
|
|
|
|
|
|
|
|
@request_url = request.base_url
|
|
|
|
group_id = params[:exercise_group_id]
|
|
|
|
group_id = params[:exercise_group_id]
|
|
|
|
if @exercise.blank?
|
|
|
|
if @exercise.blank?
|
|
|
|
normal_status(-1,"试卷不存在")
|
|
|
|
normal_status(-1,"试卷不存在")
|
|
|
@ -48,19 +49,20 @@ class ZipsController < ApplicationController
|
|
|
|
@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
|
|
|
|
default_ex_users_size = default_ex_users.size
|
|
|
|
|
|
|
|
@ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
|
|
|
|
@ex_users = default_ex_users #仅导出已提交的,截止后则是全部为提交的。
|
|
|
|
#可以分班选择
|
|
|
|
#可以分班选择
|
|
|
|
if group_id.present?
|
|
|
|
if group_id.present?
|
|
|
|
exercise_students = @course.students.course_find_by_ids("course_group_id",group_id) # 试卷所分班的全部人数
|
|
|
|
exercise_students = @course.students.where(course_group_id: group_id) # 试卷所分班的全部人数
|
|
|
|
user_ids = exercise_students.pluck(:user_id).reject(&:blank?)
|
|
|
|
user_ids = exercise_students.pluck(:user_id).reject(&:blank?).uniq
|
|
|
|
@ex_users = @ex_users.exercise_commit_users(user_ids)
|
|
|
|
@ex_users = @ex_users.where(user_id: user_ids)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# @ex_users = @ex_users.first(200)
|
|
|
|
|
|
|
|
|
|
|
|
default_ex_users_size = @ex_users.size
|
|
|
|
|
|
|
|
|
|
|
|
if default_ex_users_size == 0
|
|
|
|
if default_ex_users_size == 0
|
|
|
|
normal_status(-1,"导出失败,暂时没有已提交的学生")
|
|
|
|
normal_status(-1,"导出失败,暂时没有已提交的学生")
|
|
|
|
elsif default_ex_users_size > 200
|
|
|
|
elsif default_ex_users_size > 100
|
|
|
|
normal_status(-1,"导出数量超过200,请分班导出或联系网站管理员导出")
|
|
|
|
normal_status(-1,"导出数量超过100,请分班导出或联系网站管理员导出")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|