diff --git a/Gemfile b/Gemfile index dd19b4435..63dd32df4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,11 @@ source 'https://rubygems.org' +unless RUBY_PLATFORM =~ /w32/ + # unix-like only + gem 'iconv' + gem 'rubyzip' + gem 'zip-zip' +end gem "rails", "3.2.13" gem "jquery-rails", "~> 2.0.2" gem "i18n", "~> 0.6.0" diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index 7c2129496..cb28f4e66 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -30,7 +30,7 @@ class TestController < ApplicationController input_filename = files_path zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip" - Dir.mkdir(File.dirname(zipfile_name)) if File.exist?(File.dirname(zipfile_name)) + 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| zipfile.add(ic.iconv(filename_to_real(File.basename(filename))), folder + '/' + filename) diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 8e0c93a79..c93436cee 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -14,6 +14,10 @@ <% end %> <% display_id = im_watching_student_id? @bid%> +<%= link_to "作业打包下载", test_zip_path(homework_id: @bid), remote: true, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;display: inline-block;" if( User.current.admin? || + !(User.current.roles_for_project(@bid.courses.first).map(&:id) & + ([7,9, 10])).empty? + ) && Rails.env.development? %> <% @homework_list.each do |homework|%> <% if homework.attachments.any?%>