题库过滤作业的搜索
This commit is contained in:
parent
b333c40ce0
commit
8aff404f0c
|
@ -539,6 +539,7 @@ class UsersController < ApplicationController
|
|||
@homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
|
||||
end
|
||||
@type = params[:type]
|
||||
@property = params[:property]
|
||||
@limit = 15
|
||||
@is_remote = true
|
||||
@hw_count = @homeworks.count
|
||||
|
@ -574,6 +575,13 @@ class UsersController < ApplicationController
|
|||
elsif params[:type] == "2" #课程资源
|
||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
|
||||
end
|
||||
if params[:property] && params[:property] == "1"
|
||||
@homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc")
|
||||
elsif params[:property] && params[:property] == "2"
|
||||
@homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc")
|
||||
elsif params[:property] && params[:property] == "3"
|
||||
@homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
|
||||
end
|
||||
@type = params[:type]
|
||||
@limit = 15
|
||||
@is_remote = true
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<input type="text" name="search" placeholder="输入作业、老师姓名的关键词进行搜索" class="subject-pop-search fr" />
|
||||
<script type="text/javascript">
|
||||
var lastSearchCondition = '';
|
||||
var count = 0;
|
||||
function search_hws(e){
|
||||
if($(e.target).val().trim() == lastSearchCondition && lastSearchCondition != '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'users', :action => 'user_search_homeworks') %>'+'?name='+ e.target.value+'&type=<%=type %>&is_import=<%=is_import %>&property=<%=property %>',
|
||||
type:'get'
|
||||
});
|
||||
}
|
||||
|
||||
function throttle(method,context,e){
|
||||
clearTimeout(method.tId);
|
||||
method.tId=setTimeout(function(){
|
||||
method.call(context,e);
|
||||
},500);
|
||||
}
|
||||
|
||||
//查询项目
|
||||
$("input[name='search']").on('input', function (e) {
|
||||
throttle(search_hws,window,e);
|
||||
});
|
||||
|
||||
</script>
|
|
@ -7,7 +7,7 @@ $("#homework_search_input").html("<%=escape_javascript(render :partial=>'homewor
|
|||
$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
|
||||
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||
$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
|
||||
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>");
|
||||
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_repository_search', :locals=>{:type=>@type,:is_import=>@is_import,:property=>@property}) %>");
|
||||
$("#homework_type_all").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 0) %>');
|
||||
$("#homework_type_nor").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 1) %>');
|
||||
$("#homework_type_pro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 2) %>');
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
</ul>
|
||||
<div class="cl"></div>
|
||||
<div id="homework_search_input" class="mt10 fl">
|
||||
<%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 0} %>
|
||||
<%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %>
|
||||
</div>
|
||||
<!--<form class="resourcesSearchloadBox mt10">
|
||||
<input type="text" name="serach" placeholder="输入题库关键词进行搜索" class="searchResource" />
|
||||
|
|
|
@ -99,8 +99,6 @@ ActiveRecord::Schema.define(:version => 20160303103231) do
|
|||
t.integer "quotes"
|
||||
t.integer "version"
|
||||
t.integer "attachment_id"
|
||||
t.integer "is_publish", :default => 1
|
||||
t.date "publish_time"
|
||||
end
|
||||
|
||||
create_table "attachments", :force => true do |t|
|
||||
|
@ -1279,6 +1277,7 @@ ActiveRecord::Schema.define(:version => 20160303103231) do
|
|||
t.text "description"
|
||||
t.integer "creator_id"
|
||||
t.integer "home_id"
|
||||
t.string "domain"
|
||||
t.boolean "is_public"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
|
@ -1386,6 +1385,7 @@ ActiveRecord::Schema.define(:version => 20160303103231) do
|
|||
t.integer "changeset_num", :default => 0
|
||||
t.integer "board_message_num", :default => 0
|
||||
t.integer "board_num", :default => 0
|
||||
t.integer "act_num", :default => 0
|
||||
t.integer "attach_num", :default => 0
|
||||
t.datetime "commit_time"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue