From ccf29c980a243dae60c0f16193c9c2ce4ee36bf9 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 24 May 2016 10:34:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E4=BD=9C=E4=B8=9A=EF=BC=9A=E6=90=9C=E7=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E4=B8=AD=E5=8C=85=E6=8B=AC=E4=B8=8D=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E7=9A=84=E4=BD=9C=E4=B8=9A=E3=80=81?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=9B=9E=E5=A4=8D=E6=A1=86=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=B8=8D=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 5 +++-- app/views/homework_common/_homework_index_list.html.erb | 8 ++++++++ app/views/homework_common/_homework_search_form.html.erb | 2 +- app/views/homework_common/index.html.erb | 9 ++------- app/views/homework_common/index.js.erb | 5 ++++- 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 app/views/homework_common/_homework_index_list.html.erb 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} %> + +
+ +
+
\ 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} %> - -
- -
+
+ <%= 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}) %>");