作业列表搜索作业:搜索结果中包括不包含关键字的作业、作业回复框加载不出
This commit is contained in:
parent
6586dfaf91
commit
ccf29c980a
|
@ -14,6 +14,7 @@ class HomeworkCommonController < ApplicationController
|
||||||
#unless params[:page]
|
#unless params[:page]
|
||||||
# update_homework_time(@course.homework_commons)
|
# update_homework_time(@course.homework_commons)
|
||||||
#end
|
#end
|
||||||
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
||||||
@new_homework = HomeworkCommon.new
|
@new_homework = HomeworkCommon.new
|
||||||
@new_homework.homework_detail_manual = HomeworkDetailManual.new
|
@new_homework.homework_detail_manual = HomeworkDetailManual.new
|
||||||
@new_homework.course = @course
|
@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))
|
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
|
||||||
if @is_teacher
|
if @is_teacher
|
||||||
#@homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
|
#@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
|
else
|
||||||
#@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
|
#@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
|
end
|
||||||
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
|
||||||
@is_new = params[:is_new]
|
@is_new = params[:is_new]
|
||||||
|
|
|
@ -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} %>
|
||||||
|
|
||||||
|
<div style="width:210px; text-align:center; margin:0 auto;">
|
||||||
|
<ul class="wlist" style=" border:none; display:inline-block; float:none; margin-top:10px;">
|
||||||
|
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
||||||
|
</ul>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
|
@ -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 %>
|
:remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
|
||||||
<input type="text" name="search" placeholder="输入作业名称进行搜索" class="searchResource" />
|
<input type="text" name="search" placeholder="输入作业名称进行搜索" class="searchResource" />
|
||||||
<%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
|
<%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
|
||||||
|
|
|
@ -71,13 +71,8 @@
|
||||||
<% end%>
|
<% end%>
|
||||||
</div><!----HomeWork end-->
|
</div><!----HomeWork end-->
|
||||||
<% end%>
|
<% end%>
|
||||||
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,:page => 0,:is_in_course => 1,:course_id => @course.id} %>
|
<div id="homework_index_list">
|
||||||
|
<%= render :partial => 'homework_common/homework_index_list', :locals => {:homework_commons => @homeworks,:course_id => @course.id} %>
|
||||||
<div style="width:210px; text-align:center; margin:0 auto;">
|
|
||||||
<ul class="wlist" style=" border:none; display:inline-block; float:none; margin-top:10px;">
|
|
||||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
|
|
||||||
</ul>
|
|
||||||
<div class="cl"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
|
@ -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} )%>");
|
/*
|
||||||
|
$("#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}) %>");
|
||||||
|
|
Loading…
Reference in New Issue