题库支持按引用数和发布时间排序
This commit is contained in:
parent
1d93c6c56b
commit
12c60547ad
|
@ -376,13 +376,15 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
#用户作业列表
|
#用户作业列表
|
||||||
def user_homeworks
|
def user_homeworks
|
||||||
|
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||||
@user = User.current
|
@user = User.current
|
||||||
|
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||||
if(params[:type].blank? || params[:type] == "1") #公共题库
|
if(params[:type].blank? || params[:type] == "1") #公共题库
|
||||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc")
|
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||||
elsif params[:type] == "2" #我的题库
|
elsif params[:type] == "2" #我的题库
|
||||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc")
|
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||||
end
|
end
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
@limit = 15
|
@limit = 15
|
||||||
|
@ -525,20 +527,22 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_homework_type
|
def user_homework_type
|
||||||
|
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||||
|
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||||
@user = User.current
|
@user = User.current
|
||||||
if(params[:type].blank? || params[:type] == "1") #公共题库
|
if(params[:type].blank? || params[:type] == "1") #公共题库
|
||||||
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
visible_course = Course.where("is_public = 1 && is_delete = 0")
|
||||||
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
|
||||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc")
|
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||||
elsif params[:type] == "2" #我的题库
|
elsif params[:type] == "2" #我的题库
|
||||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc")
|
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
|
||||||
end
|
end
|
||||||
if params[:property] && params[:property] == "1"
|
if params[:property] && params[:property] == "1"
|
||||||
@homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc")
|
@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
|
||||||
elsif params[:property] && params[:property] == "2"
|
elsif params[:property] && params[:property] == "2"
|
||||||
@homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc")
|
@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
|
||||||
elsif params[:property] && params[:property] == "3"
|
elsif params[:property] && params[:property] == "3"
|
||||||
@homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
|
@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
|
||||||
end
|
end
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
@property = params[:property]
|
@property = params[:property]
|
||||||
|
@ -564,6 +568,8 @@ class UsersController < ApplicationController
|
||||||
|
|
||||||
#用户主页过滤作业
|
#用户主页过滤作业
|
||||||
def user_search_homeworks
|
def user_search_homeworks
|
||||||
|
@order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
|
||||||
|
@r_sort = @b_sort == "desc" ? "asc" : "desc"
|
||||||
@user = User.current
|
@user = User.current
|
||||||
search = params[:name].to_s.strip.downcase
|
search = params[:name].to_s.strip.downcase
|
||||||
if(params[:type].blank? || params[:type] == "1") #全部
|
if(params[:type].blank? || params[:type] == "1") #全部
|
||||||
|
@ -573,16 +579,16 @@ class UsersController < ApplicationController
|
||||||
all_user_ids = all_homeworks.map{|hw| hw.user_id}
|
all_user_ids = all_homeworks.map{|hw| hw.user_id}
|
||||||
user_str_ids = search_user_by_name all_user_ids, search
|
user_str_ids = search_user_by_name all_user_ids, search
|
||||||
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
|
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
|
||||||
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("created_at desc")
|
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
|
||||||
elsif params[:type] == "2" #课程资源
|
elsif params[:type] == "2" #课程资源
|
||||||
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
|
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("#{@order} #{@b_sort}")
|
||||||
end
|
end
|
||||||
if params[:property] && params[:property] == "1"
|
if params[:property] && params[:property] == "1"
|
||||||
@homeworks = @homeworks.where("homework_type = 1").reorder("created_at desc")
|
@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
|
||||||
elsif params[:property] && params[:property] == "2"
|
elsif params[:property] && params[:property] == "2"
|
||||||
@homeworks = @homeworks.where("homework_type = 2").reorder("created_at desc")
|
@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
|
||||||
elsif params[:property] && params[:property] == "3"
|
elsif params[:property] && params[:property] == "3"
|
||||||
@homeworks = @homeworks.where("homework_type = 3").reorder("created_at desc")
|
@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
|
||||||
end
|
end
|
||||||
@type = params[:type]
|
@type = params[:type]
|
||||||
@limit = 15
|
@limit = 15
|
||||||
|
@ -592,6 +598,8 @@ class UsersController < ApplicationController
|
||||||
@offset ||= @hw_pages.offset
|
@offset ||= @hw_pages.offset
|
||||||
@homeworks = paginateHelper @homeworks,15
|
@homeworks = paginateHelper @homeworks,15
|
||||||
@is_import = params[:is_import]
|
@is_import = params[:is_import]
|
||||||
|
@property = params[:property]
|
||||||
|
@search = search
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<ul class="subject-list-banner">
|
||||||
|
<li class="subject-list-name fl hidden"><span style="padding-left:15px;">作业名称</span></li>
|
||||||
|
<li class="subject-list-from fl">来源</li>
|
||||||
|
<li class="subject-list-type fl">类别</li>
|
||||||
|
<li class="subject-list-publisher fl">贡献者</li>
|
||||||
|
<li class="subject-list-count fl">
|
||||||
|
<%= link_to "引用数",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort),:class => "fl",:remote => true%>
|
||||||
|
<% if @order == "quotes"%>
|
||||||
|
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12" ,:remote => true%>
|
||||||
|
<% end%>
|
||||||
|
</li>
|
||||||
|
<li class="fl subject-list-date">
|
||||||
|
<%= link_to "发布时间",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort),:class => "fl",:remote => true%>
|
||||||
|
<% if @order == "created_at"%>
|
||||||
|
<%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "created_at", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12" ,:remote => true%>
|
||||||
|
<% end%>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div id="homework_repository">
|
||||||
|
<%=render :partial => 'homework_repository', :locals => {:homeworks => homeworks} %>
|
||||||
|
</div>
|
|
@ -4,7 +4,7 @@ $("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :
|
||||||
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
|
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :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_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>");
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
|
$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => @is_import,:property => @property,:search=>''})%>');
|
||||||
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
$("#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_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
|
||||||
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_repository_search', :locals=>{:type=>@type,:is_import=>@is_import,:property=>@property}) %>");
|
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_repository_search', :locals=>{:type=>@type,:is_import=>@is_import,:property=>@property}) %>");
|
||||||
|
|
|
@ -60,23 +60,9 @@
|
||||||
<div id="homework_search_input" class="mt10 fl">
|
<div id="homework_search_input" class="mt10 fl">
|
||||||
<%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %>
|
<%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => @property} %>
|
||||||
</div>
|
</div>
|
||||||
<!--<form class="resourcesSearchloadBox mt10">
|
|
||||||
<input type="text" name="serach" placeholder="输入题库关键词进行搜索" class="searchResource" />
|
|
||||||
<a href="javascript:void(0);" class="homepageSearchIcon"></a>
|
|
||||||
</form>-->
|
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="w583 fl mr10 mt10">
|
<div class="w583 fl mr10 mt10" id="homework_repository_list">
|
||||||
<ul class="subject-list-banner">
|
<%=render :partial => 'homework_repository_list', :locals => {:homeworks => @homeworks,:type=>@type,:is_import => 0,:property => @property,:search=>''} %>
|
||||||
<li class="subject-list-name fl hidden"><span style="padding-left:15px;">作业名称</span></li>
|
|
||||||
<li class="subject-list-from fl">来源</li>
|
|
||||||
<li class="subject-list-type fl">类别</li>
|
|
||||||
<li class="subject-list-publisher fl">贡献者</li>
|
|
||||||
<li class="subject-list-count fl">引用数</li>
|
|
||||||
<li class="fl subject-list-date">发布时间</li>
|
|
||||||
</ul>
|
|
||||||
<div id="homework_repository">
|
|
||||||
<%=render :partial => 'homework_repository', :locals => {:homeworks => @homeworks} %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="homework_repository_detail">
|
<div id="homework_repository_detail">
|
||||||
<%=render :partial => 'homework_repository_detail', :locals => {:homework => nil} %>
|
<%=render :partial => 'homework_repository_detail', :locals => {:homework => nil} %>
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
|
/*$("#homework_repository").html('<%#= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');*/
|
||||||
|
$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => 0,:property => @property,:search=>''})%>');
|
||||||
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
$("#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_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
|
||||||
|
|
|
@ -3,7 +3,7 @@ $("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'us
|
||||||
$("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
$("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
||||||
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
|
$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
|
||||||
<% else %>
|
<% else %>
|
||||||
$("#homework_repository").html('<%= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');
|
$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => @is_import,:property => @property,:search=>@search})%>');
|
||||||
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
$("#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_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
|
||||||
<% end %>
|
<% end %>
|
|
@ -1480,3 +1480,8 @@ a.choose-active {background-color:#269ac9; color:#ffffff;}
|
||||||
.subject-list-type {width:50px; text-align:center;}
|
.subject-list-type {width:50px; text-align:center;}
|
||||||
.subject-list-count {width:60px; text-align:center;}
|
.subject-list-count {width:60px; text-align:center;}
|
||||||
.subject-list-from {width:105px; text-align:center;}
|
.subject-list-from {width:105px; text-align:center;}
|
||||||
|
|
||||||
|
a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;}
|
||||||
|
a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;}
|
||||||
|
a.st_img { display:block;width:32px; height:32px; border:1px solid #CCC; padding:1px;}
|
||||||
|
a:hover.st_img { border:1px solid #1c9ec7; }
|
||||||
|
|
Loading…
Reference in New Issue