diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 07bd55321..71a39d7ac 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -102,8 +102,10 @@ class OrganizationsController < ApplicationController if params[:org_subfield_id] @org_subfield = OrgSubfield.find(params[:org_subfield_id]) if @org_subfield.field_type == "Comptec" || @org_subfield.field_type == "Compstu" - #@org_students = User.find_by_sql("SELECT * FROM users u, user_extensions ue where u.id = ue.user_id and ue.identity =1;") + # @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,( SELECT `courses`.* FROM `courses` INNER JOIN `members` ON `courses`.`id` = `members`.`course_id` WHERE `members`.`user_id` = u.id AND (courses.status<>9)) as course_count + # from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + # @org_resources = else @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) @@ -148,6 +150,36 @@ class OrganizationsController < ApplicationController end + def teacher_search + "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' " + teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + q = "#{params[:search].strip}" + @org_teachers = searchmember_by_name(teachers, q) + @is_remote = true + #@result_count = results.count + #@results = paginateHelper results, 10 + # @results = results + # @search_name = q + + end + + def searchmember_by_name members, name + #searchPeopleByRoles(project, StudentRoles) + mems = [] + if name != "" + name = name.to_s.downcase + members.each do |m| + username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase + if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name)) + mems << m + end + end + else + mems = members + end + mems + end + def get_project_message_activities_org org project_ids = org.projects.map{|project| project.id}.join(",") unless project_ids.blank? diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb new file mode 100644 index 000000000..6397a9cb1 --- /dev/null +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -0,0 +1,35 @@ +<% @org_teachers.each do |org_teacher| %> + <% school = School.where("id =?", org_teacher.school_id).first %> +
+
+
+ <%= link_to image_tag(url_to_avatar(org_teacher), :width => "90", :height => "90"), user_url_in_org(org_teacher), :alt => "用户头像" %> +
+
+
<%= org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname) %> + <% unless school.nil? %> + <%= school.name %> + <% end %> + <% unless org_teacher.nil? %> + <%= org_teacher.technical_title %>
+ <% end %> +
+
<%= org_teacher_course_count(org_teacher) %>
+
课程数
+
+
+
+
<%= org_student_course_count(org_teacher) %>500
+
学生数
+
+
+
+
<%= org_teacher_resource_count(org_teacher) %>
+
资源数
+
+
+ 添加 +
+
+
+<% end %> \ No newline at end of file diff --git a/app/views/organizations/_show_teachers.html.erb b/app/views/organizations/_show_teachers.html.erb index cbaed9f74..3531b9a58 100644 --- a/app/views/organizations/_show_teachers.html.erb +++ b/app/views/organizations/_show_teachers.html.erb @@ -1,7 +1,14 @@
- - + <%= form_tag( url_for(:controller => 'organizations', :action => 'teacher_search'), + :remote => true , :method => 'get', :id => 'resource_search_form') do %> + + <%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none', :class => "teacher-search-icon fl" %> + + <% end %> + + +
- <% @org_teachers.each do |org_teacher| %> - <% school = School.where("id =?", org_teacher.school_id).first %> -
-
-
-
-
<%= org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname) %> - <% unless school.nil? %> - <%= school.name %> - <% end %> - <% unless org_teacher.nil? %> - <%= org_teacher.technical_title %>
- <% end %> -
-
<%= org_teacher_course_count(org_teacher) %>
-
课程数
-
-
-
-
<%= org_student_course_count(org_teacher) %>500
-
学生数
-
-
-
-
<%= org_teacher_resource_count(org_teacher) %>
-
资源数
-
-
- 添加 -
-
-
- <% end %> +
+ <%=render 'organizations/org_teachers_list' %> +
\ No newline at end of file diff --git a/app/views/organizations/teacher_search.js.erb b/app/views/organizations/teacher_search.js.erb new file mode 100644 index 000000000..6b27f0998 --- /dev/null +++ b/app/views/organizations/teacher_search.js.erb @@ -0,0 +1 @@ +$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list')%>'); diff --git a/config/routes.rb b/config/routes.rb index ffda033a6..9910cbe6c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,6 +76,7 @@ RedmineApp::Application.routes.draw do get 'more_org_projects' get 'more_org_courses' get 'search_courses' + get 'teacher_search' post 'join_course_menu' post 'join_courses' get 'search_projects' diff --git a/public/images/search.png b/public/images/search.png new file mode 100644 index 000000000..97ce7bf5d Binary files /dev/null and b/public/images/search.png differ