Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
daiao 5 years ago
commit 48ea2ebbf9

@ -1291,17 +1291,26 @@ class ExercisesController < ApplicationController
@page = params[:page] || 1 @page = params[:page] || 1
@limit = params[:limit] || 20 @limit = params[:limit] || 20
@exercise_users_list = @exercise_users_list.page(@page).per(@limit) @exercise_users_list = @exercise_users_list.page(@page).per(@limit)
respond_to do |format| else
format.json @exercise_users_list = []
if @user_course_identity > Course::ASSISTANT_PROFESSOR @export_ex_users = @exercise_users_list
tip_exception(403,"无权限操作") @exercise_users_size = 0
elsif (@exercise_users_size == 0) || ( @export_ex_users&.exercise_user_committed.size == 0) end
logger.info("#######___________@exercise_users_size_________##################{@exercise_users_size}")
logger.info("#######__________@export_ex_users&.exercise_user_committed.size_________##################{@export_ex_users&.exercise_user_committed.size}")
if params[:format] == "xlsx"
logger.info("#######___________params_xlsx____________##########")
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 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 == 0____________##########")
normal_status(-1,"暂无用户提交")
else
respond_to do |format|
format.xlsx{ format.xlsx{
get_export_users(@exercise,@course,@export_ex_users) get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name = exercise_export_name =
@ -1309,35 +1318,8 @@ class ExercisesController < ApplicationController
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns} 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
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
}
end
else
@exercise_users_list = []
@exercise_users_size = 0
respond_to do |format|
format.json
format.xlsx{
normal_status(-1,"暂无用户提交")
}
end end
end end
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("页面调用失败!") tip_exception("页面调用失败!")

@ -927,23 +927,35 @@ class PollsController < ApplicationController
@poll_export_questions = @poll_questions.order("question_number ASC") @poll_export_questions = @poll_questions.order("question_number ASC")
@poll_questions = @poll_questions.page(@page).per(@limit) @poll_questions = @poll_questions.page(@page).per(@limit)
respond_to do |format| if params[:format] == "xlsx"
format.json if @user_course_identity > Course::ASSISTANT_PROFESSOR
format.xlsx{ tip_exception(403,"无权限操作")
if @user_course_identity > Course::ASSISTANT_PROFESSOR elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0)
tip_exception(403,"无权限操作") normal_status(-1,"暂无用户提交")
elsif (@poll.polls_status == 1) || (@poll_export_questions.size == 0) || (@poll_commit_ids.size == 0) else
normal_status(-1,"暂时没有提交的用户") respond_to do |format|
else format.xlsx{
polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}" polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: { render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
poll_questions:@poll_export_questions, poll_questions:@poll_export_questions,
poll:@poll, poll:@poll,
poll_users: @poll_users, poll_users: @poll_users,
poll_commit_ids:@poll_commit_ids} poll_commit_ids:@poll_commit_ids}
}
end end
} end
end end
# respond_to do |format|
# format.json
# format.xlsx{
# polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
# render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {
# poll_questions:@poll_export_questions,
# poll:@poll,
# poll_users: @poll_users,
# poll_commit_ids:@poll_commit_ids}
# }
# end
rescue Exception => e rescue Exception => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("页面调用失败!") tip_exception("页面调用失败!")

Loading…
Cancel
Save