分组作业提交作品添加成员时过滤掉未发布的分班学生

dev_course
cxt 6 years ago
parent a67bb19f49
commit dade4b8c27

@ -41,14 +41,16 @@ class StudentWorksController < ApplicationController
# 搜索课堂学生 # 搜索课堂学生
def search_member_list 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? 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]}%") concat(users.lastname, users.firstname) like ?", "%#{params[:search]}%")
else else
# 没有搜索条件时搜索课堂所有未提交的学生 # 没有搜索条件时搜索课堂所有未提交的学生
user_ids = @homework.student_works.where("work_status = 0").pluck(:user_id) - [current_user.id] 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 end
page = params[:page] ? params[:page].to_i : 1 page = params[:page] ? params[:page].to_i : 1

Loading…
Cancel
Save