From dade4b8c27d31880b0235f338977f1a4c1008b5d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 21 Jun 2019 15:29:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E4=BD=9C=E5=93=81=E6=B7=BB=E5=8A=A0=E6=88=90=E5=91=98?= =?UTF-8?q?=E6=97=B6=E8=BF=87=E6=BB=A4=E6=8E=89=E6=9C=AA=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=9A=84=E5=88=86=E7=8F=AD=E5=AD=A6=E7=94=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_works_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index 46e87e632..4d98ea02b 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -41,14 +41,16 @@ class StudentWorksController < ApplicationController # 搜索课堂学生 def search_member_list + # 统一设置的作业取所有学生,否则取已发布的分班学生 + students = @homework.unified_setting? ? @course.students : @course.students.where(course_group_id: @homework.published_settings.pluck(:course_group_id)) unless params[:search].blank? - @members = @course.students.joins(:user).where("user_id != #{current_user.id} and + @members = students.joins(:user).where("user_id != #{current_user.id} and concat(users.lastname, users.firstname) like ?", "%#{params[:search]}%") else # 没有搜索条件时搜索课堂所有未提交的学生 user_ids = @homework.student_works.where("work_status = 0").pluck(:user_id) - [current_user.id] - @members = @course.students.where(user_id: user_ids) + @members = students.where(user_id: user_ids) end page = params[:page] ? params[:page].to_i : 1