|
|
|
@ -1291,39 +1291,37 @@ class ExercisesController < ApplicationController
|
|
|
|
|
@page = params[:page] || 1
|
|
|
|
|
@limit = params[:limit] || 20
|
|
|
|
|
@exercise_users_list = @exercise_users_list.page(@page).per(@limit)
|
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
|
logger.info("###########______________format.xlsx______111111111_#######")
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
@exercise_users_list = []
|
|
|
|
|
@export_ex_users = @exercise_users_list
|
|
|
|
|
@exercise_users_size = 0
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.json
|
|
|
|
|
format.xlsx{
|
|
|
|
|
|
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
|
if @user_course_identity > Course::ASSISTANT_PROFESSOR
|
|
|
|
|
tip_exception(403,"无权限操作")
|
|
|
|
|
else
|
|
|
|
|
if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
|
|
|
|
|
logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
|
|
|
|
|
logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
|
|
|
|
|
|
|
|
|
|
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0)
|
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
|
|
else
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.xlsx{
|
|
|
|
|
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')}"
|
|
|
|
|
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@exercise_users_list = []
|
|
|
|
|
@exercise_users_size = 0
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.json
|
|
|
|
|
format.xlsx{
|
|
|
|
|
normal_status(-1,"暂无用户提交")
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
# else
|
|
|
|
|
# respond_to do |format|
|
|
|
|
|
# format.json
|
|
|
|
|
# format.xlsx{
|
|
|
|
|
# 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')}"
|
|
|
|
|
# render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
|
|
|
|
|
# }
|
|
|
|
|
# end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|