From 5d9f54c93bddf4c11eb25f46865306513309d904 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Nov 2014 09:50:21 +0800 Subject: [PATCH 1/6] =?UTF-8?q?#1490=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E4=B8=AD=E6=98=BE=E7=A4=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/zh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 8d1fb19af..9778bcdbf 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -603,7 +603,7 @@ zh: #by young label_requirement: 需求 label_new_course: 课程列表 - label_course_practice: 课程作业 + label_course_practice: 课程实践 label_course_all: 课程列表 label_teacher_all: 所有教师 label_project_deposit: 项目托管 From 2b829db804c726e602f098306bbd1dc0390629d2 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 11 Nov 2014 11:05:56 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=95=99=E5=B8=88=E6=89=93=E5=BC=80?= =?UTF-8?q?=E8=AF=84=E5=88=86=E7=95=8C=E9=9D=A2=E6=97=B6=EF=BC=8C=E8=AF=84?= =?UTF-8?q?=E5=88=86=E5=A4=84=E6=98=BE=E7=A4=BA=E5=85=B6=E4=B8=8A=E6=AC=A1?= =?UTF-8?q?=E7=9A=84=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/_show_star.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/homework_attach/_show_star.html.erb b/app/views/homework_attach/_show_star.html.erb index 2044c5360..0f842a1cd 100644 --- a/app/views/homework_attach/_show_star.html.erb +++ b/app/views/homework_attach/_show_star.html.erb @@ -12,5 +12,5 @@ <% elsif @is_comprehensive_evaluation == 1%> <%= l(:label_work_rating) %>: - <%= rating_for homework, dimension: :quality,start_score: 0, class: 'rateable div_inline' %> + <%= rating_for homework, dimension: :quality,start_score: @m_score, class: 'rateable div_inline' %> <% end %> \ No newline at end of file From ecd5a7b2fb30a0d32b17ff91e048c8f14c8acc92 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Nov 2014 11:16:37 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=89=93=E5=8C=85=E4=B8=8B=E8=BD=BD=E6=97=A0=E6=B3=95=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 58 +++++++++------------------ 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 18ed80a34..b2195adc3 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -19,17 +19,13 @@ class ZipdownController < ApplicationController end def assort - obj_class = params[:obj_class] - obj_id = params[:obj_id] - obj = obj_class.constantize.find(obj_id) - zipfile = nil - case obj.class.to_s.to_sym - when :Bid - zipfile = zip_bid obj - else - logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" + if params[:obj_class] == "Bid" + bid = Bid.find params[:obj_id] + zipfile = zip_bid bid + else + logger.error "[ZipDown#assort] ===> #{params[:obj_class]} unKown !!" end - send_file zipfile, :filename => obj.name+".zip", :type => detect_content_type(zipfile) if zipfile + send_file zipfile, :filename => bid.name + ".zip", :type => detect_content_type(zipfile) if zipfile rescue Exception => e render file: 'public/no_file_found.html' @@ -40,61 +36,43 @@ class ZipdownController < ApplicationController homework = HomeworkAttach.find params[:homework] if User.current.admin? || User.current.member_of_course?(homework.bid.courses.first) if homework != nil - if homework.attachments.count > 0 + unless homework.attachments.empty? zipfile = zip_homework_by_user homework send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if(zipfile) else - render file: 'public/no_file_found.html' , :layout => 'course_base' + render file: 'public/no_file_found.html' end else - render file: 'public/file_not_found.html' , :layout => 'course_base' + render file: 'public/file_not_found.html' end else - render_403 :message => :notice_not_authorized ,:layout => "course_base" + render_403 end rescue => e - render file: 'public/file_not_found.html' , :layout => 'course_base' + render file: 'public/file_not_found.html' end private - def zip_user_bid(bid,user_id) - # Todo: User Access Controll - - homeattaches = bid.homeworks.where("user_id = ?",user_id) - # 得到每一个人所有文件打包的zip文件 - # 并将每一个人的zip打包为一个并返回路径 - user_zip_paths = homeattaches.map do |homeattach| - zip_homework_by_user homeattach - end - user_zip_paths - end - def zip_bid(bid) # Todo: User Access Controll - - homeattaches = bid.homeworks - #记录所有作业是不是有附件,有一个附件就改为true - #has_file = false - # 得到每一个人所有文件打包的zip文件 - # 并将每一个人的zip打包为一个并返回路径 - user_zip_paths = homeattaches.map do |homeattach| - if homeattach.attachments.count > 0 - zip_homework_by_user homeattach - #has_file = true unless has_file + bid_homework_path = [] + bid.homeworks.each do |homeattach| + unless homeattach.attachments.empty? + bid_homework_path << zip_homework_by_user(homeattach) end end - zipping "#{Time.now.to_i}_#{bid.name}.zip", user_zip_paths, OUTPUT_FOLDER + zipping "#{Time.now.to_i}_#{bid.name}.zip", bid_homework_path, OUTPUT_FOLDER end def zip_homework_by_user(homeattach) homeworks_attach_path = [] # 需要将所有homework.attachments遍历加入zip # 并且返回zip路径 - user_attaches_paths = homeattach.attachments.each do |attach| + homeattach.attachments.each do |attach| 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) + zipping("#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) end From 1c50646677ea1fcd2b7c238c0e94715a1349dada Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Nov 2014 11:39:57 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8C=85?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=96=87=E4=BB=B6=E5=90=8D=E4=B8=BA=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=AF=A5=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E5=A7=93=E5=90=8D=5F=E5=AD=A6=E7=94=9F=E5=AD=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index b2195adc3..10c42cd6c 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -72,7 +72,7 @@ class ZipdownController < ApplicationController homeattach.attachments.each do |attach| homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping("#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + zipping("#{homeattach.user.name}_#{homeattach.user.user_extensions.student_id}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) end @@ -81,14 +81,14 @@ class ZipdownController < ApplicationController ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') input_filename = files_paths - rename_zipfile = zip_name_refer ||= "archive_#{Time.now.to_i}.zip" + rename_zipfile = zip_name_refer ||= "homework.zip" zipfile_name = "#{output_path}/#{rename_zipfile}" Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name)) Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| input_filename.each do |filename| - rename_file = Time.now.to_i.to_s+ ic.iconv( (File.basename(filename)) ).to_s + rename_file = ic.iconv( (File.basename(filename)) ).to_s rename_file = ic.iconv( filename_to_real( File.basename(filename))).to_s if is_attachment zipfile.add(rename_file, filename) From 3c2c9149b1e9be6c6509bec00a36b244b2d47e70 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Nov 2014 11:51:17 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A=E7=9A=84=E5=BF=85?= =?UTF-8?q?=E5=A1=AB=E6=A0=87=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/edit.html.erb | 4 ++-- app/views/homework_attach/new.html.erb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index 55015e2f9..92a72acd4 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -65,8 +65,8 @@

-

-

From 31ad012bee2a482a798756b72e6692ff5b7bac4c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Nov 2014 14:41:07 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=89=93=E5=8C=85=E4=B8=8B=E8=BD=BD=E6=88=90=E5=8A=9F?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E9=9D=A2=E6=89=93=E5=8C=85=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/zipdown_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 10c42cd6c..efa171d52 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -72,7 +72,7 @@ class ZipdownController < ApplicationController homeattach.attachments.each do |attach| homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping("#{homeattach.user.name}_#{homeattach.user.user_extensions.student_id}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + zipping("#{Time.now.to_i.to_s}_#{homeattach.user.name}_#{homeattach.user.user_extensions.student_id}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) end @@ -81,7 +81,7 @@ class ZipdownController < ApplicationController ic = Iconv.new('GBK//IGNORE', 'UTF-8//IGNORE') input_filename = files_paths - rename_zipfile = zip_name_refer ||= "homework.zip" + rename_zipfile = zip_name_refer ||= "#{Time.now.to_i.to_s}.zip" zipfile_name = "#{output_path}/#{rename_zipfile}" Dir.mkdir(File.dirname(zipfile_name)) unless File.exist?(File.dirname(zipfile_name))