From 71a0e539053713a9a23628e7d3107265b4a355aa Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Sep 2019 09:22:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AD=A6=E7=94=9F=E6=97=B6?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BD=9C=E5=93=81=E5=81=9A=E5=94=AF=E4=B8=80?= =?UTF-8?q?=E6=80=A7=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_member.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/course_member.rb b/app/models/course_member.rb index d67994ef..788f87aa 100644 --- a/app/models/course_member.rb +++ b/app/models/course_member.rb @@ -15,6 +15,7 @@ class CourseMember < ActiveRecord::Base homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_type in (1, 3, 4)") if homeworks.count != 0 homeworks.each do |hw| + next if hw.student_works.where(user_id: user_id).any? str += "," if str != "" str += "('#{hw.name}的作品提交',#{hw.id},#{user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end @@ -34,6 +35,7 @@ class CourseMember < ActiveRecord::Base exercises = course.exercises if exercises.count != 0 exercises.each do |ex| + next if ex.exercise_users.where(user_id: user_id).any? str += "," if str != "" str += "(#{ex.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end @@ -53,6 +55,7 @@ class CourseMember < ActiveRecord::Base polls = course.polls if polls.count != 0 polls.each do |poll| + next if poll.poll_users.where(user_id: user_id).any? str += "," if str != "" str += "(#{poll.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end @@ -72,6 +75,7 @@ class CourseMember < ActiveRecord::Base tasks = course.graduation_tasks if tasks.count != 0 tasks.each do |task| + next if task.graduation_works.where(user_id: user_id).any? str += "," if str != "" str += "(#{task.id}, #{user_id}, #{course.id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" end