From dfe784a051c14398029a9aaae96ecfbd51471cae Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 09:38:22 +0800 Subject: [PATCH 1/3] fix bug --- app/controllers/exercises_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 79bed2d25..d8278faff 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1297,7 +1297,7 @@ class ExercisesController < ApplicationController if @user_course_identity > Course::ASSISTANT_PROFESSOR tip_exception(403,"无权限操作") else - if @export_ex_users.exercise_user_committed.size == 0 + if (@exercise_users_size == 0) ||( @export_ex_users&.exercise_user_committed.size == 0) normal_status(-1,"暂无用户提交") else get_export_users(@exercise,@course,@export_ex_users) From 8768f4cb237abde1eda6f9e9221d8049f8e8e2ab Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 09:43:04 +0800 Subject: [PATCH 2/3] fix bug --- app/controllers/exercises_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index d8278faff..72e075d31 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,13 +1291,15 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) + logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") + logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") respond_to do |format| format.json 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) + if (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) normal_status(-1,"暂无用户提交") else get_export_users(@exercise,@course,@export_ex_users) @@ -1316,9 +1318,6 @@ class ExercisesController < ApplicationController format.xlsx{ normal_status(-1,"暂无用户提交") } - format.zip{ - normal_status(-1,"暂无用户提交") - } end end From 14dc08892ce247719bbc6e3a200b93690b9f0740 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Wed, 3 Jul 2019 10:14:16 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=AA=8C=E8=AF=81=20format.xlsx=E4=B8=8B?= =?UTF-8?q?=E7=9A=84render=20json=E6=98=AF=E5=90=A6=E6=9C=89=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 45 +++++++++++++++++-------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 72e075d31..a1db41d79 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1291,23 +1291,40 @@ class ExercisesController < ApplicationController @page = params[:page] || 1 @limit = params[:limit] || 20 @exercise_users_list = @exercise_users_list.page(@page).per(@limit) - logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}") - logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}") 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) - 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