@ -1278,14 +1278,8 @@ class ExercisesController < ApplicationController
#搜索
#搜索
ifparams[:search].present?
ifparams[:search].present?
search_content=params[:search]
#搜索用户的nickname,如果存在则返回,否则继续查询用户的真实姓名或学生号
@exercise_users_list=@exercise_users_list.joins(user::user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?","%#{params[:search]}%","%#{params[:search]}%")
nick_name_search=@exercise_users_list.where(user_id:User.where('CONCAT(users.lastname, users.firstname) like ?',"%#{search_content}%"))
ifnick_name_search.present?
@exercise_users_list=nick_name_search
else
@exercise_users_list=@exercise_users_list.joins(user:[:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{search_content}%","%#{search_content}%")
@ -1026,20 +1030,18 @@ class PollsController < ApplicationController
#搜索
#搜索
ifsearch_content.present?
ifsearch_content.present?
#搜索用户的nickname,如果存在则返回,否则继续查询用户的真实姓名或学生号
@poll_users_list=@poll_users_list.joins(user::user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?","%#{search_content}%","%#{search_content}%")
nick_name_search=@poll_users_list.where(user_id:User.where('CONCAT(users.lastname, users.firstname) like ?',"%#{search_content}%"))
ifnick_name_search.present?
@poll_users_list=nick_name_search
else
@poll_users_list=@poll_users_list.joins(user:[:user_extension]).where('user_extensions.student_id like ? OR user_extensions.student_realname like ?',"%#{search_content}%","%#{search_content}%")