diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 9da4b90b9..376f8d5c2 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -14,6 +14,7 @@ class HomeworkCommonController < ApplicationController
#unless params[:page]
# update_homework_time(@course.homework_commons)
#end
+ search = "%#{params[:search].to_s.strip.downcase}%"
@new_homework = HomeworkCommon.new
@new_homework.homework_detail_manual = HomeworkDetailManual.new
@new_homework.course = @course
@@ -21,10 +22,10 @@ class HomeworkCommonController < ApplicationController
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
if @is_teacher
#@homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
- @homework_commons = @course.homework_commons.order("created_at desc")
+ @homework_commons = @course.homework_commons.where("name like '%#{search}%'").order("created_at desc")
else
#@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
- @homework_commons = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc")
+ @homework_commons = @course.homework_commons.where("name like '%#{search}%' and publish_time <= '#{Date.today}'").order("created_at desc")
end
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
@is_new = params[:is_new]
diff --git a/app/views/homework_common/_homework_index_list.html.erb b/app/views/homework_common/_homework_index_list.html.erb
new file mode 100644
index 000000000..9b11017e8
--- /dev/null
+++ b/app/views/homework_common/_homework_index_list.html.erb
@@ -0,0 +1,8 @@
+<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => homework_commons,:page => 0,:is_in_course => 1,:course_id => course_id} %>
+
+
+
+ <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
+
+
+
\ No newline at end of file
diff --git a/app/views/homework_common/_homework_search_form.html.erb b/app/views/homework_common/_homework_search_form.html.erb
index f71cec9a5..250d72467 100644
--- a/app/views/homework_common/_homework_search_form.html.erb
+++ b/app/views/homework_common/_homework_search_form.html.erb
@@ -1,4 +1,4 @@
-<%= form_tag( url_for(:controller => 'courses',:action => 'homework_search',:id=>course.id),
+<%= form_tag( homework_common_index_url_in_org(course.id),
:remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
<%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb
index 29cff8933..35f4658f9 100644
--- a/app/views/homework_common/index.html.erb
+++ b/app/views/homework_common/index.html.erb
@@ -71,13 +71,8 @@
<% end%>
<% end%>
- <%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,:page => 0,:is_in_course => 1,:course_id => @course.id} %>
-
-
-
- <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
-
-
+
+ <%= render :partial => 'homework_common/homework_index_list', :locals => {:homework_commons => @homeworks,:course_id => @course.id} %>
diff --git a/app/views/homework_common/index.js.erb b/app/views/homework_common/index.js.erb
index 7a038eb5c..4a9ec6ad3 100644
--- a/app/views/homework_common/index.js.erb
+++ b/app/views/homework_common/index.js.erb
@@ -1 +1,4 @@
-$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homeworks, :page => @page, :is_in_course => 1,:course_id => @course.id} )%>");
\ No newline at end of file
+/*
+$("#user_show_more_homework").replaceWith("<%#= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homeworks, :page => @page, :is_in_course => 1,:course_id => @course.id} )%>");*/
+
+$("#homework_index_list").html("<%=escape_javascript(render :partial => 'homework_common/homework_index_list', :locals => {:homework_commons => @homeworks,:course_id => @course.id}) %>");