修改试卷和问卷答题列表的搜索条件

dev_forum
SylorHuang 5 years ago
parent 4c4904190b
commit 61747f8e84

@ -1278,14 +1278,8 @@ class ExercisesController < ApplicationController
#搜索 #搜索
if params[:search].present? if params[: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}%"))
if nick_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}%")
end
end end
@export_ex_users = @exercise_users_list @export_ex_users = @exercise_users_list

@ -1026,13 +1026,9 @@ class PollsController < ApplicationController
#搜索 #搜索
if search_content.present? if search_content.present?
#搜索用户的nickname,如果存在则返回,否则继续查询用户的真实姓名或学生号
nick_name_search = @poll_users_list.where(user_id: User.where('CONCAT(users.lastname, users.firstname) like ?',"%#{search_content}%")) @poll_users_list = @poll_users_list.joins(user: :user_extension).where("CONCAT(lastname, firstname) like ? OR student_id like ?", "%#{search_content}%", "%#{search_content}%")
if nick_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}%")
end
end end
@poll_users_size = @poll_users_list.count @poll_users_size = @poll_users_list.count

Loading…
Cancel
Save