作业列表的过滤查询

This commit is contained in:
sw 2015-08-28 10:00:48 +08:00
parent c5ad5a3a5a
commit 007a39b5d5
7 changed files with 46 additions and 31 deletions

View File

@ -39,13 +39,6 @@ class UsersController < ApplicationController
#
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info,
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,
:user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages,:edit_brief_introduction,:user_new_homework,:user_import_homeworks]
#edit has been deleted by huang, 2013-9-23
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
@ -53,7 +46,7 @@ class UsersController < ApplicationController
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
:user_import_homeworks]
:user_import_homeworks,:user_search_homeworks]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@ -322,6 +315,14 @@ class UsersController < ApplicationController
end
end
#用户主页过滤作业
def user_search_homeworks
@user_homeworks = HomeworkCommon.where("user_id = '#{@user.id}' and lower(name) like '%#{params[:name].to_s.downcase}%'").order("created_at desc")
respond_to do |format|
format.js
end
end
def user_new_homework
if params[:homework_common]
homework = HomeworkCommon.new

View File

@ -0,0 +1,13 @@
<% user_homeworks.each do |homework|%>
<ul class="homeworkPublish">
<li class="fl">
<input name="checkMenu" type="radio" class="courseSendCheckbox" value="<%= homework.id%>"/>
</li>
<li class="sendCourseName fl hidden w450">
<%= homework.name%>
</li>
</ul>
<div class="homeworkPublishTime">
创建时间:<%= format_date homework.created_at%>
</div>
<% end%>

View File

@ -1,33 +1,24 @@
<div class="cl"></div>
<div class="coursesChoosePopup">
<div class="coursesChoosePopup" id="coursesChoosePopup">
<div>
<div class="sendText">导入作业</div>
</div>
<div >
<form class="coursesSearchBox">
<input type="text" name="serach" placeholder="输入作业名称进行搜索" class="searchCoursesPopup" />
<a href="javascript:void(0);" class="searchIconPopup"></a>
<input type="text" name="homework_name" placeholder="输入作业名称进行搜索" class="searchCoursesPopup" id="search_homework_name"/>
<a href="javascript:void(0);" class="searchIconPopup" onclick="search_homework_by_name('<%= user_search_homeworks_user_path(User.current.id)%>');"></a>
</form>
</div>
<div class="homeworkListForm mb10">
<% @user_homeworks.each do |homework|%>
<ul class="homeworkPublish">
<li class="fl">
<input name="checkMenu" type="radio" class="courseSendCheckbox"/>
</li>
<li class="sendCourseName fl hidden w450">
<%= homework.name%>
</li>
</ul>
<div class="homeworkPublishTime">
创建时间:<%= format_date homework.created_at%>
</div>
<% end%>
<div class="homeworkListForm mb10 " id="homework_list_form_show">
<%= render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks}%>
</div>
<div>
<div class="courseSendSubmit"><a href="javascript:void(0);" class="sendSourceText">确定</a></div>
<div class="courseSendCancel"><a href="javascript:void(0);" class="sendSourceText">取消</a></div>
<div class="courseSendSubmit">
<a href="javascript:void(0);" class="sendSourceText">确定</a>
</div>
<div class="courseSendCancel">
<a href="javascript:void(0);" class="sendSourceText" onclick="hideModal('#coursesChoosePopup')">取消</a>
</div>
</div>
<div class="cl"></div>
</div>

View File

@ -0,0 +1 @@
$("#homework_list_form_show").html("<%= escape_javascript(render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks})%>");

View File

@ -327,6 +327,7 @@ RedmineApp::Application.routes.draw do
match 'user_visitorlist', :to => 'users#user_visitorlist', :via => :get
match 'user_homeworks', :to => 'users#user_homeworks', :via => :get
get 'user_import_homeworks'
get 'user_search_homeworks'
match 'watch_projects', :to => 'users#watch_projects', :via => :get
#
# added by bai

View File

@ -85,3 +85,13 @@ function regex_homework_name()
return true;
}
}
//老师导入作业时查询作业
function search_homework_by_name(url){
$.get(
url,
{ name: $("#search_homework_name").val() },
function (data) {
}
);
}

View File

@ -655,13 +655,11 @@ ul.list_watch{
.coursesChoosePopup {width:530px; height:auto; padding-left:20px; padding-bottom:35px; background-color:#ffffff;}
.coursesSearchBox {border:1px solid #e6e6e6; width:515px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;}
.searchCoursesPopup {border:none; outline:none; background-color:#ffffff; width:470px; height:25px; padding-left:10px; display:inline-block; float:left;}
.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(../images/homepage_icon.png) -180px -273px no-repeat; display:inline-block; float:left;}
.searchIconPopup:hover {background:url(../images/homepage_icon.png) -180px -314px no-repeat;}
/*导入作业弹窗*/
.homeworkPublish {width:500px; height:15px; line-height:15px;}
.homeworkPublishTime {font-size:12px; color:#b1b1b1; margin-left:22px; margin-bottom:8px;}
.homeworkListForm{min-height: 160px;width: 550px;overflow: scroll;overflow-x: hidden;}
.homeworkListForm{height: 160px;width: 550px;overflow: scroll;overflow-x: hidden;}
.w450{width: 450px;}
/*引用资源库弹窗*/