#coding=utf-8 namespace :zip do desc "手工打包作品" task :pack => :environment do include ZipService include Redmine::I18n homework = Object.const_get(ENV['CLASS']).find ENV["ID"] file_count = 0 homework.student_works.map { |work| file_count += work.attachments.count} if file_count > 0 users_id = [7405,8376,9009,9018,9035,9037,9039,9043,9049,9055,9058,9075,9145,9146,9172,14806,16336,16341,16346, 16356,17744,17847,18006,18044,18050,19177,23557,23561,23568,23702,23821,23822,23891,23941,23990, 24045, 24054,24057,24078,24087,24175,24177,24243,24245,24279,24672,29295,29372,30150,30154,30158,30159,30163,30165,30166, 30169,30171,30173,30177,30179,30180,30182,30183,30186,30191,30192,30193,30195,30198,30199,30205,30206,30207,30208, 30212,30214,30216,30217,30219,30221,30222,30224,30230,30231,30233,30236,30237,30239,30240,30241,30242,30243,30245, 30247,30248,30249,30252,30255,30256,30257,30260,30261,30262,30263,30266,30268,30269,30271,31408,31931,32012] student_works =(homework.id == 7412 ? homework.student_works.where(:user_id => users_id) : homework.student_works) zipfile = zip_homework_common(homework, student_works) if student_works.present? else zipfile = {:message => "no file"} end puts "out: #{zipfile}" end task :shixun_pack => :environment do include ZipService include Redmine::I18n homework = Object.const_get(ENV['CLASS']).find ENV["ID"] student_works = homework.student_works.select{|work| work.work_status != 0} if student_works.size > 0 zipfile = zip_shixun_work(homework, student_works) else zipfile = {:message => "no file"} end puts "out: #{zipfile}" end task :exercise_pack => :environment do include ZipService include Redmine::I18n exercise = Object.const_get(ENV['CLASS']).find ENV["ID"] exercise_users_list = exercise.exercise_users.select{|exercise| exercise.commit_status = 1} if exercise_users_list.size > 0 zipfile = zip_user_exercise(exercise, exercise_users_list) else zipfile = {:message => "no file"} end puts "out: #{zipfile}" end end