You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
#coding=utf-8
|
|
# 执行示例 bundle exec rake excellent_course_exercise:student_answer args=149,2903
|
|
desc "同步精品课的学生试卷数据"
|
|
namespace :excellent_course_exercise do
|
|
task :student_answer => :environment do
|
|
|
|
course = Course.find_by(id: 2933)
|
|
|
|
participant_count = 1042
|
|
pass_count = 823
|
|
|
|
members_1 = course.students.order("id asc").limit(987)
|
|
members_2 = course.students.order("id asc").limit(1042)
|
|
members_1 = course.students.order("id asc").limit(322)
|
|
|
|
exercise_1884 = course.exercises.find_by(id: 1884)
|
|
members_1.each_with_index do |member, index|
|
|
if index < 821
|
|
exercise_1884.exercise_questions.where.not(question_type: 5).each do |question|
|
|
answer_option = {
|
|
:user_id => current_user.id,
|
|
:exercise_question_id => @exercise_question.id,
|
|
:exercise_choice_id => choice_id,
|
|
:answer_text => ""
|
|
}
|
|
ex_a = ExerciseAnswer.new(answer_option)
|
|
ex_a.save!
|
|
end
|
|
else
|
|
|
|
end
|
|
end
|
|
end
|
|
end |