创建课堂数据

dev_hs
cxt 5 years ago
parent 88ab9e269a
commit 0e025048c1

@ -14,6 +14,7 @@ namespace :excellent_course_exercise do
course = Course.find_by(id: course_id) course = Course.find_by(id: course_id)
course.exercises.each_with_index do |exercise, index| course.exercises.each_with_index do |exercise, index|
if exercise.exercise_users.where(commit_status: 1).count == 0
# 第一个试卷的参与人数和通过人数都是传的数据,后续的随机 # 第一个试卷的参与人数和通过人数都是传的数据,后续的随机
if index == 0 if index == 0
members = course.students.order("id asc").limit(participant_count) members = course.students.order("id asc").limit(participant_count)
@ -27,6 +28,7 @@ namespace :excellent_course_exercise do
end end
end end
end end
end
def update_exercise_user exercise, members, pass_count def update_exercise_user exercise, members, pass_count
exercise_question_ids = exercise.exercise_questions.where(question_type: 0).pluck(:id) exercise_question_ids = exercise.exercise_questions.where(question_type: 0).pluck(:id)

@ -110,6 +110,23 @@ namespace :public_course do
end 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) def min_swith(time)
puts time puts time
return time < 9 ? "0#{time}" : time return time < 9 ? "0#{time}" : time

Loading…
Cancel
Save