|
|
@ -14,16 +14,18 @@ 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
|
|
|
|
# 第一个试卷的参与人数和通过人数都是传的数据,后续的随机
|
|
|
|
members = course.students.order("id asc").limit(participant_count)
|
|
|
|
if index == 0
|
|
|
|
update_exercise_user(exercise, members, pass_count)
|
|
|
|
members = course.students.order("id asc").limit(participant_count)
|
|
|
|
else
|
|
|
|
update_exercise_user(exercise, members, pass_count)
|
|
|
|
new_participant_count = rand((participant_count - 423)..participant_count)
|
|
|
|
else
|
|
|
|
new_pass_count = rand((new_participant_count - 113)..new_participant_count)
|
|
|
|
new_participant_count = rand((participant_count - 423)..participant_count)
|
|
|
|
|
|
|
|
new_pass_count = rand((new_participant_count - 113)..new_participant_count)
|
|
|
|
|
|
|
|
|
|
|
|
members = course.students.order("id asc").limit(new_participant_count)
|
|
|
|
members = course.students.order("id asc").limit(new_participant_count)
|
|
|
|
update_exercise_user(exercise, members, new_pass_count)
|
|
|
|
update_exercise_user(exercise, members, new_pass_count)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|