diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 33a569f5d..777c0d8b7 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -37,9 +37,17 @@ class ZipdownController < ApplicationController #下载某一学生的作业的所有文件 def download_user_homework homework = HomeworkAttach.find params[:homework] - if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first)) - zipfile = zip_homework_by_user homework - send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile + if User.current.admin? || User.current.member_of_course?(homework.bid.courses.first) + if homework != nil + if homework.attachments.count > 0 + zipfile = zip_homework_by_user homework + send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile + else + render_403 :message => :no_file_dowmload + end + else + render_403 :message =>:notice_file_not_found + end else render_403 :message => :notice_not_authorized end @@ -81,15 +89,17 @@ class ZipdownController < ApplicationController end def zip_homework_by_user(homeattach) - homeworks_attach_path = [] - # 需要将所有homework.attachments遍历加入zip - # 并且返回zip路径 - user_attaches_paths = homeattach.attachments.each do |attach| - #length = attach.storage_path.length - homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) - end - zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true - #user_attaches_paths + #if homeattach.attachments.count > 0 + homeworks_attach_path = [] + # 需要将所有homework.attachments遍历加入zip + # 并且返回zip路径 + user_attaches_paths = homeattach.attachments.each do |attach| + #length = attach.storage_path.length + homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) + end + zipping("#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + #user_attaches_paths + #end end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 8b241030a..81c960781 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -8,10 +8,7 @@
<%= l(:label_task_plural)%>(<%= @homework_list.count%>) - <%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if( - User.current.admin? || - !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || - (Rails.env.development?) %> + <%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if(is_teacher) %> |
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index e75cf7b11..cd5dd630a 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -1867,6 +1867,7 @@ zh:
lable_close_mutual_evaluation: 关闭互评
label_has_been: 已经被
label_course_userd_by: 个课程引用
+ no_file_dowmload: 该作业没有任何的附件可以下载
role_of_course: 课程角色
label_student: 学生
|