|
|
|
@ -14,24 +14,24 @@ namespace :homework_evaluation do
|
|
|
|
|
if homework_common.anonymous_comment == 0 && homework_detail_manual.comment_status == 1 #新建状态才可开启匿评
|
|
|
|
|
student_works = homework_common.student_works.has_committed
|
|
|
|
|
if student_works && student_works.size >= 2
|
|
|
|
|
if homework_common.homework_type == 3
|
|
|
|
|
student_work_projects = homework_common.student_work_projects.where("student_work_id is not null")
|
|
|
|
|
student_work_projects.each_with_index do |pro_work, pro_index|
|
|
|
|
|
n = homework_detail_manual.evaluation_num
|
|
|
|
|
n = n < student_works.size ? n : student_works.size - 1
|
|
|
|
|
work_index = -1
|
|
|
|
|
student_works.each_with_index do |stu_work, stu_index|
|
|
|
|
|
if stu_work.id.to_i == pro_work.student_work_id.to_i
|
|
|
|
|
work_index = stu_index
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
|
|
|
|
|
assigned_homeworks.each do |h|
|
|
|
|
|
student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
|
|
|
|
|
student_works_evaluation_distributions.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
# if homework_common.homework_type == 3
|
|
|
|
|
# student_work_projects = homework_common.student_work_projects.where("student_work_id is not null")
|
|
|
|
|
# student_work_projects.each_with_index do |pro_work, pro_index|
|
|
|
|
|
# n = homework_detail_manual.evaluation_num
|
|
|
|
|
# n = n < student_works.size ? n : student_works.size - 1
|
|
|
|
|
# work_index = -1
|
|
|
|
|
# student_works.each_with_index do |stu_work, stu_index|
|
|
|
|
|
# if stu_work.id.to_i == pro_work.student_work_id.to_i
|
|
|
|
|
# work_index = stu_index
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# assigned_homeworks = get_assigned_homeworks(student_works, n, work_index)
|
|
|
|
|
# assigned_homeworks.each do |h|
|
|
|
|
|
# student_works_evaluation_distributions = StudentWorksEvaluationDistribution.new(user_id: pro_work.user_id, student_work_id: h.id)
|
|
|
|
|
# student_works_evaluation_distributions.save
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
# else
|
|
|
|
|
student_works.each_with_index do |work, index|
|
|
|
|
|
user = work.user
|
|
|
|
|
n = homework_detail_manual.evaluation_num
|
|
|
|
@ -42,7 +42,7 @@ namespace :homework_evaluation do
|
|
|
|
|
student_works_evaluation_distributions.save
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
#end
|
|
|
|
|
homework_detail_manual.update_column('comment_status', 2)
|
|
|
|
|
# 匿评开启消息邮件通知,# 所有人
|
|
|
|
|
#send_message_anonymous_comment(homework_common, 2)
|
|
|
|
|