From d8a568e685525893f5d2ca1edaa00512d9321559 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Tue, 9 Dec 2014 14:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E3=80=8A=E5=88=86=E7=8F=AD?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=AD=A6=E7=94=9F=E3=80=8B=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=20Signed-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 7 ++++++- app/helpers/courses_helper.rb | 12 ++++++++++++ app/views/courses/_member_list.html.erb | 6 +++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 756595e70..788237444 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -205,7 +205,12 @@ class CoursesController < ApplicationController @is_remote = true q = "#{params[:name].strip}" #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? - @results = searchStudent_by_name(@course, q) + if params[:incourse] + @results = searchStudent_by_name(@course, q) + else + group = CourseGroup.find(params[:search_group_id]) + @results = searchgroupstudent_by_name(group, @course, q) + end @result_count = @results.count @results = paginateHelper @results diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 3b7e811f6..bf3810030 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -184,6 +184,18 @@ module CoursesHelper end members end + def searchgroupstudent_by_name(group, project, q) + members = [] + group.members.each do |m| + if m && m.user && m.user.allowed_to?(:as_student,project) + username = m.user[:lastname].to_s + m.user[:firstname].to_s + if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name)) + members << m + end + end + end + members + end def searchStudent_by_group group, project #searchPeopleByRoles(project, StudentRoles) members = [] diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb index a02ca83e2..b77d359d0 100644 --- a/app/views/courses/_member_list.html.erb +++ b/app/views/courses/_member_list.html.erb @@ -8,7 +8,11 @@ <% if @subPage_title == l(:label_student_list) %> <%= form_tag( searchmembers_course_path(@course), method: 'get',:class => "f_l",:style => "margin-left: 5px; ",:remote=>true) do %> <%= text_field_tag 'name', params[:name], name: "name", :class => 'f_1', :style => "height:15px"%> - <%= submit_tag l(:label_search), :class => "f_2"%> + <% if @group %> + <%= hidden_field "#{@group.id}", params[:search_group_id], name: 'search_group_id' %> + <%= submit_tag l(:label_search), :name => "ingroup",:class => "f_2"%> + <% end %> + <%= submit_tag l(:label_search), :name => 'incourse',:class => "f_2"%> <%#= link_to l(:label_search),'' , :class => 'f_2' %> <% end %> <% end %>