From 37050d1349e81572ce8bb81cc8e5f809ea6f4adf Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 11 Oct 2019 17:02:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 10f046323..735798d38 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -161,11 +161,17 @@ class HomeworkCommonsController < ApplicationController # 作品状态 0: 未提交, 1 按时提交, 2 延迟提交 if params[:work_status].present? work_status = params[:work_status].map{|status| status.to_i} - all_student_works = @student_works.joins(:myshixun) + all_student_works = @student_works @student_works = all_student_works.where(work_status: work_status) - @student_works = @student_works.or(all_student_works.where(work_status: 0)).or(all_student_works.where(myshixuns: {status: 0})) if work_status.include?(3) - @student_works = @student_works.or(all_student_works.where(myshixun: {status: 0})) if work_status.include?(4) + if work_status.include?(3) + ids = all_student_works.joins(:myshixun).where(myshixuns: {status: 0}).pluck(:id) + @student_works = @student_works.or(all_student_works.where(work_status: 0)).or(all_student_works.where(id: ids)) + end + if work_status.include?(4) + ids = all_student_works.joins(:myshixun).where(myshixuns: {status: 1}).pluck(:id) + @student_works = @student_works.or(all_student_works.where(id: ids)) + end end # 分班情况