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