From d7649d04421ab02105d40d987072a75a2d46f254 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:16:18 +0800 Subject: [PATCH] fix bug --- app/controllers/exercises_controller.rb | 46 ++++++++----------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index a1db41d79..038d9a87c 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1293,38 +1293,22 @@ class ExercisesController < ApplicationController @exercise_users_list = @exercise_users_list.page(@page).per(@limit) respond_to do |format| format.json - if @user_course_identity > Course::ASSISTANT_PROFESSOR - tip_exception(403,"无权限操作") - elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) - logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") - logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") - - - normal_status(-1,"暂无用户提交") - else - 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 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}") - # - # normal_status(-1,"暂无用户提交") - # else - # 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 + 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}") + + normal_status(-1,"暂无用户提交") + else + 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