dev_local_2
cxt 5 years ago
parent 2986586865
commit 891dae66a7

@ -161,16 +161,16 @@ 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
all_student_works = @student_works.left_joins(:myshixun)
@student_works = all_student_works.where(work_status: work_status)
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))
# 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(myshixuns: {status: 0}))
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))
# ids = all_student_works.joins(:myshixun).where(myshixuns: {status: 1}).pluck(:id)
@student_works = @student_works.or(all_student_works.where(myshixuns: {status: 1}))
end
end

Loading…
Cancel
Save