dev_course
SylorHuang 5 years ago
parent 33cc969d88
commit 148b73d4ff

@ -994,8 +994,7 @@ class CoursesController < ApplicationController
else
member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks)
filename_ = "#{current_user.real_name}_#{@course.name}_全部成绩"
filename = Base64.urlsafe_encode64(filename_)
render xlsx: "#{format_sheet_name filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
render xlsx: "#{format_sheet_name filename_.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
locals: {course_info:@course_info, activity_level:@user_activity_level,
course_scores:@course_user_scores,shixun_works:@shixun_work_arrays,
common_works:@common_work_arrays,group_works:@group_work_arrays,task_works:@task_work_arrays,

@ -1291,24 +1291,15 @@ class ExercisesController < ApplicationController
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}"
ex_xlsx = render_to_string handlers: [:axlsx], formats: [:xlsx], template: "exercises/exercise_lists.xlsx.axlsx", locals: {table_columns:@table_columns,exercise_users:@user_columns}
zip_file = Tempfile.new(exercise_export_name,"/home/tmp")
zip_file.write(ex_xlsx)
zip_file.close
# render json{:status => 0,"file_name":"#{exercise_export_name}"}
render :json => { status: 0, file_name: "#{exercise_export_name}",file_path: "#{zip_file.path}" }
# 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}"
# exercise_export_name = Base64.urlsafe_encode64(exercise_export_name_.strip.first(30))
#
# render xlsx: "#{exercise_export_name}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
# }
# end
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
rescue Exception => e
@ -1323,10 +1314,9 @@ class ExercisesController < ApplicationController
def export_exercise
@request_url = request.base_url
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
filename_ = "#{@exercise.user.real_name}_#{@exercise.exercise_name}"
filename = Base64.urlsafe_encode64(filename_.strip.first(30))
filename_ = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
render pdf: 'exercise_export/blank_exercise', filename: filename_.strip.first(30), stylesheets: stylesheets
end
#空白试卷预览页面,仅供测试使用,无其他任何用途

@ -134,9 +134,8 @@ class GraduationTasksController < ApplicationController
respond_to do |format|
format.xlsx{
graduation_work_to_xlsx(@work_excel,@task,current_user)
task_export_name_ = "#{current_user.real_name}_#{@course.name}_#{@task.name}"
task_export_name = Base64.urlsafe_encode64(task_export_name_.strip.first(30))
render xlsx: "#{task_export_name}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
task_export_name_ = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{task_export_name_.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
}
end
end

@ -271,8 +271,7 @@ class GraduationTopicsController < ApplicationController
students = course.students.joins(user: :user_extension).order("user_extensions.student_id")
graduation_topic_to_xlsx(students,course)
topic_export_name_ = "#{current_user.real_name}_#{course.name}_毕设选题_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
topic_export_name = Base64.urlsafe_encode64(topic_export_name_.strip.first(30))
render xlsx: "#{topic_export_name}",template: "graduation_topics/export.xlsx.axlsx",locals: {table_columns:@topic_head_cells,topic_users:@topic_body_cells}
render xlsx: "#{topic_export_name_.strip.first(30)}",template: "graduation_topics/export.xlsx.axlsx",locals: {table_columns:@topic_head_cells,topic_users:@topic_body_cells}
rescue Exception => e
uid_logger(e.message)
missing_template

@ -206,9 +206,8 @@ class HomeworkCommonsController < ApplicationController
respond_to do |format|
format.xlsx{
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@homework.name}"
file_name = Base64.urlsafe_encode64(exercise_export_name.strip.first(30))
render xlsx: "#{file_name}",template: "homework_commons/works_list.xlsx.axlsx",locals:
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@homework.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "homework_commons/works_list.xlsx.axlsx",locals:
{table_columns: @work_head_cells,task_users: @work_cells_column}
}
end

@ -936,11 +936,9 @@ class PollsController < ApplicationController
else
respond_to do |format|
format.xlsx{
polls_export_name_ = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}"
polls_export_name = Base64.urlsafe_encode64(polls_export_name_.strip.first(30))
polls_export_name_ = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
polls_user_commit = poll_commit_result(@poll,@poll_export_questions,@poll_users,@poll_commit_ids)
render xlsx: "#{polls_export_name}",template: "polls/commit_result.xlsx.axlsx",locals: {polls_user_commit:polls_user_commit}
render xlsx: "#{polls_export_name_.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {polls_user_commit:polls_user_commit}
}
end
end

@ -6,12 +6,9 @@ class ZipsController < ApplicationController
before_action :require_admin_or_teacher
def shixun_report
service = BatchExportShixunReportService.new(@homework, @all_student_works)
filename_ = filename_for_content_disposition(service.filename)
filename = Base64.urlsafe_encode64(filename_)
send_file service.zip, filename: filename, type: 'application/zip'
send_file service.zip, filename: filename_, type: 'application/zip'
rescue BatchExportShixunReportService::Error => ex
normal_status(-1, ex.message)
end
@ -21,8 +18,7 @@ class ZipsController < ApplicationController
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
file_name_ = filename_for_content_disposition(exercises.filename)
file_name = Base64.urlsafe_encode64(file_name_)
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
send_file exercises.ex_zip, filename: file_name_, type: 'application/zip'
rescue Exception => e
normal_status(-1, e.message)
end

@ -14,7 +14,7 @@ class BatchExportShixunReportService
end
def filename
@_filename ||= "#{homework.name}"
@_filename ||= "#{homework.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
end
def zip

@ -10,7 +10,7 @@ class ExportExercisesService
end
def filename
exercise_export_name = "#{exercise.user.real_name}_#{exercise.exercise_name}"
exercise_export_name = "#{exercise.user.real_name}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
"#{exercise_export_name.strip}.zip"
end

Loading…
Cancel
Save