名师列表搜索功能
This commit is contained in:
parent
3dde8bd25a
commit
ad2f12c9d0
|
@ -28,7 +28,7 @@ class OrganizationsController < ApplicationController
|
|||
helper :project_score
|
||||
helper :issues
|
||||
include UsersHelper
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout]
|
||||
before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers]
|
||||
layout 'base_org'
|
||||
def index
|
||||
|
||||
|
@ -102,10 +102,18 @@ 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_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 =
|
||||
# @org_count = @org_teachers.count
|
||||
# @limit = 25
|
||||
# @is_remote = true
|
||||
# @atta_count = @attachments.count
|
||||
# @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
|
||||
# @offset ||= @atta_pages.offset
|
||||
# #@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||
# @attachments = paginateHelper @attachments,25
|
||||
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)
|
||||
|
@ -150,17 +158,29 @@ 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
|
||||
|
||||
def teachers
|
||||
q = params[:search].nil? ? "" : "#{params[:search].strip}"
|
||||
if params[:type] == "courses" || params[:type].nil?
|
||||
@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 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif params[:type] == "students"
|
||||
@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 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
elsif params[:type] == "resources"
|
||||
@org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count
|
||||
from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc")
|
||||
end
|
||||
limit = 10
|
||||
# @is_remote = true
|
||||
@teachers_count = @org_teachers.count
|
||||
@atta_pages = Paginator.new @teachers_count, limit, params['page'] || 1
|
||||
@offset ||= @atta_pages.offset
|
||||
#@curse_attachments_all = @all_attachments[@offset, @limit]
|
||||
@org_teachers = paginateHelper @org_teachers, limit
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def searchmember_by_name members, name
|
||||
|
|
|
@ -101,7 +101,11 @@
|
|||
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
<% if field.field_type == "Comptec" %>
|
||||
<%= link_to "#{field.name}", teachers_organization_path(organization), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
<% else %>
|
||||
<%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if User.current.logged? and User.current.admin_of_org?(organization) %>
|
||||
<%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子" %>
|
||||
|
|
|
@ -14,17 +14,17 @@
|
|||
<span class="f12 fontGrey2"><%= org_teacher.technical_title %></span></div>
|
||||
<% end %>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= org_teacher_course_count(org_teacher) %></div>
|
||||
<div class="block-num"><%= @org_count %></div>
|
||||
<div class="block-title">课程数</div>
|
||||
</div>
|
||||
<div class="block-slice"></div>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= org_student_course_count(org_teacher) %>500</div>
|
||||
<div class="block-num"><%#= org_student_course_count(org_teacher) %>500</div>
|
||||
<div class="block-title">学生数</div>
|
||||
</div>
|
||||
<div class="block-slice"></div>
|
||||
<div class="teacher-social-block">
|
||||
<div class="block-num"><%= org_teacher_resource_count(org_teacher) %></div>
|
||||
<div class="block-num"><%#= org_teacher_resource_count(org_teacher) %></div>
|
||||
<div class="block-title">资源数</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<!--<a href="javascript:" class="f_l" onclick="$('#search_student').submit();">搜索</a>-->
|
||||
<!--<input type="text" placeholder="搜索" class="teacher-list-search fl" />-->
|
||||
<!--<a href="javascript:void(0);" class="teacher-search-icon fl"></a>-->
|
||||
<select class="teacher-search-type fr">
|
||||
<option>课程数</option>
|
||||
<option>学生数</option>
|
||||
<option>资源数</option>
|
||||
<select class="teacher-search-type fr" onclick="chooseTeacherType();">
|
||||
<option value="1">课程数</option>
|
||||
<option value="2">学生数</option>
|
||||
<option value="3">资源数</option>
|
||||
</select>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -1,72 +1,66 @@
|
|||
<% if !params[:org_subfield_id].nil? && @org_subfield.field_type == "Compstu" %>
|
||||
<%= render 'organizations/show_students', :field => @org_subfield %>
|
||||
<% elsif !params[:org_subfield_id].nil? && @org_subfield.field_type == "Comptec" %>
|
||||
<%= render 'organizations/show_teachers', :field => @org_subfield %>
|
||||
<% else %>
|
||||
<%= javascript_include_tag "jquery.infinitescroll.js" %>
|
||||
<%= javascript_include_tag "jquery.infinitescroll.js" %>
|
||||
|
||||
<%= content_for(:header_tags) do %>
|
||||
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
|
||||
<% end %>
|
||||
<%= content_for(:header_tags) do %>
|
||||
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
|
||||
<% end %>
|
||||
|
||||
<% if params[:show_homepage].nil? and User.current.logged? %>
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName"><%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %></div>
|
||||
<% if params[:org_subfield_id].nil? %>
|
||||
<ul class="resourcesSelect">
|
||||
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||
<ul class="homepagePostType">
|
||||
<li>
|
||||
<ul class="homepagePostTypeHomework fl">
|
||||
<li class="f14">课程动态</li>
|
||||
<li><%= link_to "作业动态", {:controller => "organizations", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%>
|
||||
<!--<a href="javascript:void(0);" class="homepagePostTypeAssignment postTypeGrey">作业动态</a>--></li>
|
||||
<li><%= link_to "通知动态", {:controller => "organizations", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%>
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeNotice postTypeGrey">通知动态</a></li>-->
|
||||
<li><%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%>
|
||||
<li><%= link_to "问卷动态", {:controller => "organizations", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%>
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeForum postTypeGrey">论坛动态</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeQuiz postTypeGrey">问卷动态</a></li>-->
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul class="homepagePostTypeProject fl">
|
||||
<li class="f14">项目动态</li>
|
||||
<li><%= link_to "问题动态", {:controller => "organizations", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%>
|
||||
<li><%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%>
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeQuestion postTypeGrey">问题动态</a></li>
|
||||
<li><a href="javascript:void(0);" class="homepagePostTypeForum postTypeGrey">论坛动态</a></li>-->
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul class="homepagePostTypeProject fl">
|
||||
<li class="f14">更多</li>
|
||||
<li class="mt-4"><%= link_to "组织动态", {:controller => "organizations", :action => "show", :type => "org"}, :class =>"homepagePostTypeMessage postTypeGrey"%>
|
||||
<li class="mt-4"><%= link_to "全部动态", {:controller => "organizations", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%>
|
||||
</ul>
|
||||
</li>
|
||||
<% if params[:show_homepage].nil? and User.current.logged? %>
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName"><%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %></div>
|
||||
<% if params[:org_subfield_id].nil? %>
|
||||
<ul class="resourcesSelect">
|
||||
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||
<ul class="homepagePostType">
|
||||
<li>
|
||||
<ul class="homepagePostTypeHomework fl">
|
||||
<li class="f14">课程动态</li>
|
||||
<li><%= link_to "作业动态", {:controller => "organizations", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%>
|
||||
<!--<a href="javascript:void(0);" class="homepagePostTypeAssignment postTypeGrey">作业动态</a>--></li>
|
||||
<li><%= link_to "通知动态", {:controller => "organizations", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%>
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeNotice postTypeGrey">通知动态</a></li>-->
|
||||
<li><%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%>
|
||||
<li><%= link_to "问卷动态", {:controller => "organizations", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%>
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeForum postTypeGrey">论坛动态</a></li>-->
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeQuiz postTypeGrey">问卷动态</a></li>-->
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul class="homepagePostTypeProject fl">
|
||||
<li class="f14">项目动态</li>
|
||||
<li><%= link_to "问题动态", {:controller => "organizations", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%>
|
||||
<li><%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%>
|
||||
<!--<li><a href="javascript:void(0);" class="homepagePostTypeQuestion postTypeGrey">问题动态</a></li>
|
||||
<li><a href="javascript:void(0);" class="homepagePostTypeForum postTypeGrey">论坛动态</a></li>-->
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<ul class="homepagePostTypeProject fl">
|
||||
<li class="f14">更多</li>
|
||||
<li class="mt-4"><%= link_to "组织动态", {:controller => "organizations", :action => "show", :type => "org"}, :class =>"homepagePostTypeMessage postTypeGrey"%>
|
||||
<li class="mt-4"><%= link_to "全部动态", {:controller => "organizations", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 and params[:org_subfield_id].nil? %>
|
||||
<script>
|
||||
$(function() {
|
||||
sd_create_editor_from_data(<%= OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?",@organization.home_id).first.id %>, null, "100%", 'OrgActivity');
|
||||
});
|
||||
</script>
|
||||
<% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %>
|
||||
<%= render :partial => 'show_home_page', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %>
|
||||
<% end %>
|
||||
<% if @org_activities %>
|
||||
<%= render :partial => 'organizations/org_activities',
|
||||
:locals => {:org_activities => @org_activities,
|
||||
:page=> @page,
|
||||
:org => @organization,
|
||||
:org_act_count=> @org_activities.count} %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 and params[:org_subfield_id].nil? %>
|
||||
<script>
|
||||
$(function() {
|
||||
sd_create_editor_from_data(<%= OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?",@organization.home_id).first.id %>, null, "100%", 'OrgActivity');
|
||||
});
|
||||
</script>
|
||||
<% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %>
|
||||
<%= render :partial => 'show_home_page', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %>
|
||||
<% end %>
|
||||
<% if @org_activities %>
|
||||
<%= render :partial => 'organizations/org_activities',
|
||||
:locals => {:org_activities => @org_activities,
|
||||
:page=> @page,
|
||||
:org => @organization,
|
||||
:org_act_count=> @org_activities.count} %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
@ -75,3 +69,4 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<div class="resources mt10">
|
||||
<div class="function-row">
|
||||
<%= form_tag( url_for(:controller => 'organizations', :action => 'teachers'),
|
||||
:remote => true , :method => 'get', :id => 'resource_search_form') do %>
|
||||
<input type="text" name="search" placeholder="输入教师名进行搜索" class="teacher-list-search fl" />
|
||||
<%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none', :class => "teacher-search-icon fl" %>
|
||||
<!--<a href="javascript:void(0);" onclick='this.parent.submit();return false;' class="searchIcon"></a>-->
|
||||
<% end %>
|
||||
<!--<a href="javascript:" class="f_l" onclick="$('#search_student').submit();">搜索</a>-->
|
||||
<!--<input type="text" placeholder="搜索" class="teacher-list-search fl" />-->
|
||||
<!--<a href="javascript:void(0);" class="teacher-search-icon fl"></a>-->
|
||||
<select id="teacher_type_select" class="teacher-search-type fr" onclick="chooseTeacherType('<%= @organization.id %>');">
|
||||
<option value="1">课程数</option>
|
||||
<option value="2">学生数</option>
|
||||
<option value="3">资源数</option>
|
||||
</select>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div id="org_teachers_list">
|
||||
<%=render 'organizations/org_teachers_list', :org_teachers => @org_teachers %>
|
||||
</div>
|
||||
<div>
|
||||
<ul class="wlist" id="pages" style="margin-top: 15px;">
|
||||
<%= pagination_links_full @atta_pages, @teachers_count, :per_page_links => false, :flag => true %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,2 @@
|
|||
$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list')%>');
|
||||
$("#pages").html('<%= pagination_links_full @atta_pages, @teachers_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
|
@ -76,7 +76,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'more_org_projects'
|
||||
get 'more_org_courses'
|
||||
get 'search_courses'
|
||||
get 'teacher_search'
|
||||
get 'teachers'
|
||||
post 'join_course_menu'
|
||||
post 'join_courses'
|
||||
get 'search_projects'
|
||||
|
|
|
@ -74,4 +74,38 @@ function search_tag_attachment(url,tag_name,q,course_id,sort)
|
|||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 教师选项
|
||||
var sendType = '1';
|
||||
var lastSendType ;//初始为发送到我的课程
|
||||
function chooseTeacherType(org_id){
|
||||
sendType = $("#teacher_type_select").val();
|
||||
if (sendType === lastSendType) {
|
||||
alert("666");
|
||||
return;
|
||||
} else if(lastSendType != null) { //不是第一次点击的时候
|
||||
if (sendType == '1') {
|
||||
alert("te");
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/organizations/' + org_id + '/teachers',
|
||||
data:{type:"teachers"}
|
||||
});
|
||||
} else if(sendType == '2') {
|
||||
alert(org_id);
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/organizations/' + org_id + '/teachers',
|
||||
data:{type:"students"}
|
||||
});
|
||||
}else if(sendType == '3'){
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/organizations/' + org_id + '/teachers',
|
||||
data:{type:"resources"}
|
||||
});
|
||||
}
|
||||
}
|
||||
lastSendType = sendType;
|
||||
}
|
Loading…
Reference in New Issue