|
|
|
@ -108,14 +108,8 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
@all_member_count = student_works.size
|
|
|
|
|
if @homework.publish_time.nil? || @homework.publish_time > Time.now
|
|
|
|
|
@student_works = []
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.json
|
|
|
|
|
format.xlsx{
|
|
|
|
|
normal_status(-1,"作业未发布")
|
|
|
|
|
}
|
|
|
|
|
format.zip{
|
|
|
|
|
normal_status(-1,"作业未发布")
|
|
|
|
|
}
|
|
|
|
|
if params[:format] == "xlsx" || params[:format] == "zip"
|
|
|
|
|
normal_status(-1,"作业未发布")
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if @user_course_identity == Course::STUDENT
|
|
|
|
@ -200,39 +194,42 @@ class HomeworkCommonsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
# @members = @course.students.where(user_id: @student_works.pluck(:user_id)).includes(:course_group)
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.json
|
|
|
|
|
format.xlsx{
|
|
|
|
|
if @user_course_identity >= Course::STUDENT
|
|
|
|
|
tip_exception(403, "无权限操作")
|
|
|
|
|
else
|
|
|
|
|
if @work_count > 1
|
|
|
|
|
|
|
|
|
|
if params[:format] == "xlsx"
|
|
|
|
|
complete_works = @work_excel.where("work_status > 0").size
|
|
|
|
|
if @user_course_identity >= Course::STUDENT
|
|
|
|
|
tip_exception(403, "无权限操作")
|
|
|
|
|
elsif complete_works == 0
|
|
|
|
|
normal_status(-1,"暂无提交的学生!")
|
|
|
|
|
else
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.xlsx{
|
|
|
|
|
student_work_to_xlsx(@work_excel,@homework)
|
|
|
|
|
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}
|
|
|
|
|
else
|
|
|
|
|
normal_status(-1,"暂无提交的学生!")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
format.zip{
|
|
|
|
|
if @user_course_identity >= Course::STUDENT
|
|
|
|
|
tip_exception(403, "无权限操作")
|
|
|
|
|
else
|
|
|
|
|
zip_works = @work_excel.where("work_status > 0")
|
|
|
|
|
status = checkfileSize(zip_works)
|
|
|
|
|
if status == 0
|
|
|
|
|
zipfile = zip_homework_common @homework, zip_works
|
|
|
|
|
file = decode64(zipfile[0][:base64file])
|
|
|
|
|
send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
|
|
|
|
|
else
|
|
|
|
|
tip_exception(status == -2 ? "500M" : "无附件可下载")
|
|
|
|
|
end
|
|
|
|
|
elsif params[:format] == "zip"
|
|
|
|
|
if @user_course_identity >= Course::STUDENT
|
|
|
|
|
tip_exception(403, "无权限操作")
|
|
|
|
|
else
|
|
|
|
|
zip_works = @work_excel.where("work_status > 0")
|
|
|
|
|
status = checkfileSize(zip_works)
|
|
|
|
|
if status == 0
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.zip{
|
|
|
|
|
zipfile = zip_homework_common @homework, zip_works
|
|
|
|
|
file = decode64(zipfile[0][:base64file])
|
|
|
|
|
send_file "#{OUTPUT_FOLDER}/#{file}", filename: filename_for_content_disposition(file), type: 'application/zip'
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
tip_exception(status == -2 ? "500M" : "无附件可下载")
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|