|
|
|
@ -110,6 +110,23 @@ namespace :public_course do
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
task :create_homework_work => :environment do
|
|
|
|
|
course = Course.find(course_id)
|
|
|
|
|
course.practice_homeworks.each do |homework|
|
|
|
|
|
if homework.student_works.count == 0
|
|
|
|
|
str = ""
|
|
|
|
|
CourseMember.students(course).each do |student|
|
|
|
|
|
str += "," if str != ""
|
|
|
|
|
str += "(#{homework.id},#{student.user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
|
|
|
|
|
end
|
|
|
|
|
if str != ""
|
|
|
|
|
sql = "insert into student_works (homework_common_id, user_id, created_at, updated_at) values" + str
|
|
|
|
|
ActiveRecord::Base.connection.execute sql
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def min_swith(time)
|
|
|
|
|
puts time
|
|
|
|
|
return time < 9 ? "0#{time}" : time
|
|
|
|
|