Merge branch 'szzh' into develop

This commit is contained in:
cxt 2016-03-04 11:09:55 +08:00
commit bac94058de
9 changed files with 43 additions and 15 deletions

View File

@ -531,6 +531,13 @@ class UsersController < ApplicationController
elsif params[:type] == "2" #我的题库
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").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
@ -559,7 +566,11 @@ class UsersController < ApplicationController
if(params[:type].blank? || params[:type] == "1") #全部
visible_course = Course.where("is_public = 1 && is_delete = 0")
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}' and (name like '%#{search}%')").order("created_at desc")
all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
all_user_ids = all_homeworks.map{|hw| hw.user_id}
user_str_ids = search_user_by_name all_user_ids, search
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")
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

View File

@ -606,4 +606,16 @@ module UsersHelper
type
end
#根据姓名搜索用户
def search_user_by_name user_ids, name
result_ids = []
user_ids.each do |user_id|
user = User.find user_id
username = user.lastname.to_s.downcase + user.firstname.to_s.downcase
if username.include?(name)
result_ids << user_id
end
end
result_ids
end
end

View File

@ -1,4 +1,4 @@
<input type="text" name="search" placeholder="输入关键词进行搜索" class="subject-pop-search fr" />
<input type="text" name="search" placeholder="输入作业、老师姓名的关键词进行搜索" class="subject-pop-search fr" />
<script type="text/javascript">
var lastSearchCondition = '';
var count = 0;

View File

@ -6,7 +6,7 @@
<span title="<%= homework.name%>"><%= homework.name%></span>
</label>
</li>
<li class="subject-pop-from fl hidden">攻城狮</li>
<li class="subject-pop-from fl hidden"><span title="<%=homework.course.name %>(<%=current_time_and_term(homework.course) %>)"><%=homework.course.name %>(<%=current_time_and_term_short(homework.course) %>)</span></li>
<li class="subject-pop-type fl">
<% case homework.homework_type %>
<% when 1 %>

View File

@ -1,8 +1,8 @@
<div class="w985"> <a href="javascript:void(0);" class="popup-close" onclick="hideModal()"></a>
<div class="f16 fb fontBlue mb10">选用题库中的题目</div>
<div class="subject-list fl mr10">
<a href="<%= user_homework_type_user_path(@user,:is_import => 1) %>" id="public_homeworks_choose" class="subjectChoose chooseActive fl" data-remote="true">公共题库</a>
<a href="<%= user_homework_type_user_path(@user,:type=>'2',:is_import => 1) %>" id="user_homeworks_choose" class="subjectChoose fl" data-remote="true">我的题库</a>
<a href="<%= user_homework_type_user_path(@user,:is_import => 1) %>" id="public_homeworks_choose" class="resource-tab resource-tab-active fl" data-remote="true">公共题库</a>
<a href="<%= user_homework_type_user_path(@user,:type=>'2',:is_import => 1) %>" id="user_homeworks_choose" class="resource-tab fl" data-remote="true">我的题库</a>
<div id="homework_search_input">
<%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 1} %>
</div>
@ -43,11 +43,11 @@
</div>
<script type="text/javascript">
$("#public_homeworks_choose").click(function(){
$(this).toggleClass("choose-active");
$("#user_homeworks_choose").toggleClass("choose-active");
$(this).toggleClass("resource-tab-active");
$("#user_homeworks_choose").toggleClass("resource-tab-active");
});
$("#user_homeworks_choose").click(function(){
$(this).toggleClass("choose-active");
$("#public_homeworks_choose").toggleClass("choose-active");
$(this).toggleClass("resource-tab-active");
$("#public_homeworks_choose").toggleClass("resource-tab-active");
});
</script>

View File

@ -8,4 +8,8 @@ $("#homework_repository").html('<%= escape_javascript(render :partial => 'users/
$("#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_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) %>');
$("#homework_type_gro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 3) %>');
<% end %>

View File

@ -45,10 +45,10 @@
<ul class="resourcesSelect">
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
<ul class="resourcesType">
<li> <a href="/users/8523/user_resource?type=1" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部</a> </li>
<li> <a href="/users/8523/user_resource?type=2" class="homepagePostTypeAssignment postTypeGrey" data-method="get" data-remote="true">普通作业</a> </li>
<li> <a href="/users/8523/user_resource?type=3" class="program-btn postTypeGrey" data-method="get" data-remote="true" style="white-space:nowrap;">编程作业</a> </li>
<li> <a href="/users/8523/user_resource?type=5" class="group-btn resourcesGrey" data-method="get" data-remote="true">分组作业</a> </li>
<li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 0) %>" id="homework_type_all" class="resourcesTypeAll resourcesGrey" data-method="get" data-remote="true">全部</a> </li>
<li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 1) %>" id="homework_type_nor" class="homepagePostTypeAssignment postTypeGrey" data-method="get" data-remote="true">普通作业</a> </li>
<li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 2) %>" id="homework_type_pro" class="program-btn postTypeGrey" data-method="get" data-remote="true" style="white-space:nowrap;">编程作业</a> </li>
<li> <a href="<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 3) %>" id="homework_type_gro" class="group-btn resourcesGrey" data-method="get" data-remote="true">分组作业</a> </li>
</ul>
</li>
</ul>

View File

@ -1,5 +1,3 @@
$("#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}) %>");
/*$("#user_show_more_homework").replaceWith("<%#= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>");*/

View File

@ -1099,3 +1099,6 @@ a.resource-tab-active {color:#fff; background-color:#269ac9; border-bottom:1px s
.resource-pop-from {width:120px; text-align:center;}
.course-search {border: 1px solid #dddddd; height: 25px; width: 200px;outline: none;}
a.group-btn{ background: url(../images/course/hwork_icon.png) -2px -58px no-repeat !important; height:20px; display:block; padding-left:23px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;}
a.program-btn{background: url(../images/homepage_icon.png) -86px -393px no-repeat; width:30px; height:20px; display:block; padding-left:23px; color:#888888;}