测试集的显示、新版分页

This commit is contained in:
cxt 2016-08-03 13:46:59 +08:00
parent 718b13e6c1
commit acc3ba121f
9 changed files with 80 additions and 38 deletions

View File

@ -834,12 +834,12 @@ class UsersController < ApplicationController
courses = @user.courses.where("is_delete = 1")
course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")"
if @order == "course_name"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks = HomeworkCommon.find_by_sql(sql)
elsif @order == "user_name"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
end
elsif params[:type] == "2" #题库
visible_course = Course.where("is_public = 1 && is_delete = 0")

View File

@ -10,15 +10,9 @@
<li class="navHomepageMenu fl">
<%= link_to "资源库", user_resource_user_path(User.current, :type => 6), :class => "c_white f16 db p10" %>
</li>
<% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
<li class="navHomepageMenu fl">
<%= link_to "题库", user_homeworks_user_path(User.current), :class => "c_white f16 db p10"%>
</li>
<% else %>
<li class="navHomepageMenu fl">
<%= link_to "我的作业", student_homeworks_user_path(User.current), :class => "c_white f16 db p10"%>
</li>
<% end %>
<li class="navHomepageMenu fl mr30">
<%= link_to "帮助中心", "https://#{Setting.host_name}/forums/1/memos/1168", :class =>"c_white f16 db p10" %>
</li>

View File

@ -14,7 +14,24 @@
<p class="subjectContent mt10">
测试集:<%=@homework.homework_tests.count %>组
</p>
<% if @homework.user == User.current && @homework.homework_tests.count > 0 %>
<table class="hw_popup_testtable" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="test_td_min">&nbsp;</td>
<td class="test_td_title">测试集输入</td>
<td class="test_td_title">测试集输出</td>
</tr>
<% @homework.homework_tests.each_with_index do |test, i| %>
<tr>
<td class="test_td_min"><%=i+1 %></td>
<td><%=test.input %></td>
<td ><%=test.output %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% elsif @homework.homework_type ==3 && @homework.homework_detail_group %>
<p class="subjectContent mt10">
分组人数:<%=@homework.homework_detail_group.min_num %> - <%=@homework.homework_detail_group.max_num %>人

View File

@ -5,7 +5,7 @@ $("#homework_detail_information").html("<%=escape_javascript(render :partial =>
$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>");
<% else %>
$("#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, :is_new => true %>');
$("#homework_search_input").html('<%= escape_javascript(render :partial => 'users/homework_repository_search', :locals => {:type => @type,:is_import => @is_import,:property => @property,:order => @order, :b_sort => @b_sort, :search => ''})%>');
$("#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) %>');

View File

@ -25,7 +25,7 @@
}
</script>
<div class="hw_content">
<div class="hw_content mb10">
<ul id="hw_tab_nav">
<li id="hw_tab_nav_1" class="hw_tab_hover" onclick="HoverLi(1, '<%= user_homework_type_user_path(@user,:is_import => 0) %>');">
<a href="javascript:void(0)" id="public_homeworks_choose" class="hw_tab_type" style="text-align: center;">我的题库</a>
@ -48,18 +48,24 @@
</div>
<div class="cl"></div>
<div id="hw_tab_con_1">
<div class="sy_category" id="homework_search_input">
<%=render :partial=>'homework_repository_search', :locals=>{:type => '1',:is_import => 0,:property => nil,:order => @order, :b_sort => @b_sort, :search => ''} %>
</div>
<% if @homeworks.empty? %>
<div class="icons_tishi"><img src="../images/sy/icons_tan.png" width="110" height="110" alt="" ></div>
<p class="sy_tab_con_p">暂无可显示的内容~</p>
<% else %>
<div class="sy_category" id="homework_search_input">
<%=render :partial=>'homework_repository_search', :locals=>{:type => '1',:is_import => 0,:property => nil,:order => @order, :b_sort => @b_sort, :search => ''} %>
</div>
<div class="sy_classbox" style="min-height:800px;" id="homework_repository_list">
<%=render :partial => 'homework_repository_list', :locals => {:homeworks => @homeworks,:type=>'1',:is_import => 0,:property => @property,:search=>''} %>
</div>
<div class="cl"></div>
<div>
<ul class="wlist mt10" id="homework_pository_ref_pages" style="margin-top: 5px;margin-right: 295px">
<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
</ul>
</div>
<div class="sy_classbox" style="min-height:800px;" id="homework_repository_list">
<%=render :partial => 'homework_repository_list', :locals => {:homeworks => @homeworks,:type=>'1',:is_import => 0,:property => @property,:search=>''} %>
</div>
<div class="pages">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
</ul>
</div>
<div class="cl"></div>
<% end %>
</div>
</div>

View File

@ -1,4 +1,3 @@
/*$("#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_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>');

View File

@ -4,6 +4,6 @@ $("#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}) %>");
<% else %>
$("#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, :is_new => true %>');
$("#homework_search_input").html('<%= escape_javascript(render :partial => 'users/homework_repository_search', :locals => {:type => @type,:is_import => @is_import,:property => @property,:order => @order, :b_sort => @b_sort, :search => @search})%>');
<% end %>

View File

@ -231,6 +231,7 @@ module Redmine
per_page_links = options[:per_page_links]
remote = options[:remote] ? options[:remote] : false
flag = options[:flag] ? options[:flag] : false
is_new = options[:is_new] ? options[:is_new] : false
per_page_links = false if count.nil?
page_param = paginator.page_param
@ -242,7 +243,11 @@ module Redmine
else
text = "\xc2\xab " + l(:label_previous)
end
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '</li>' + ' '
if is_new
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'pages-big', :remote => remote) << '</li>' + ' '
else
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '</li>' + ' '
end
end
unless paginator.previous_page
if paginator.next_page
@ -251,7 +256,11 @@ module Redmine
else
text = "\xc2\xab " + l(:label_previous)
end
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '</li>' + ' '
if is_new
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'pages-big', :remote => remote) << '</li>' + ' '
else
html << '<li>' << yield(text, {page_param => paginator.previous_page}, :class => 'previous c_blue', :remote => remote) << '</li>' + ' '
end
end
end
@ -259,14 +268,22 @@ module Redmine
paginator.linked_pages.each do |page|
if previous && previous != page - 1
if flag
html << '<li>' << content_tag('a', '...', :class => 'c_blue') << '</li>' + ' '
if is_new
html << '<li>' << content_tag('a', '...', :class => 'c_blue') << '</li>' + ' '
else
html << '<li>' << content_tag('a', '...') << '</li>' + ' '
end
else
html << '<li>' << content_tag('span', '...', :class => 'spacer ') << '</li>' + ' '
end
end
if page == paginator.page
if flag
html << '<li class = "wlist_select">' << content_tag('a', page.to_s, :class => 'current-page c_white') << '</li>'
if is_new
html << '<li>' << content_tag('a', page.to_s, :class => 'active') << '</li>'
else
html << '<li class = "wlist_select">' << content_tag('a', page.to_s, :class => 'current-page c_white') << '</li>'
end
else
html << '<li>' << content_tag('span', page.to_s, :class => 'current-page') << '</li>'
end
@ -283,7 +300,11 @@ module Redmine
else
text = l(:label_next) + " \xc2\xbb"
end
html << '<li>' << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << '</li>' + ' '
if is_new
html << '<li>' << yield(text, {page_param => paginator.next_page}, :class => 'pages-big', :remote => remote) << '</li>' + ' '
else
html << '<li>' << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << '</li>' + ' '
end
end
unless paginator.next_page
@ -293,7 +314,11 @@ module Redmine
else
text = l(:label_next) + " \xc2\xbb"
end
html << "<li>" << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << "</li>" + ' '
if is_new
html << '<li>' << yield(text, {page_param => paginator.next_page}, :class => 'pages-big', :remote => remote) << '</li>' + ' '
else
html << '<li>' << yield(text, {page_param => paginator.next_page}, :class => 'next c_blue', :remote => remote) << '</li>' + ' '
end
end
end

View File

@ -607,11 +607,12 @@ a:hover.sy_class_ltitle{ color:#333;}
.hw_files_icon{display:block; width:17px; height:14px; background:url(../images/hw/icons_hw.png) 0 -135px no-repeat;}
.hw_list_classname{ width:300px; overflow:hidden; display:block;overflow:hidden;white-space: nowrap; text-overflow:ellipsis;}
.hw_list_teachername{ width:80px; overflow:hidden; display:block;overflow:hidden;white-space: nowrap; text-overflow:ellipsis;}
/* 测试集显示 */
.hw_popup_testtable{background:#fff; color:#888888; margin:10px 0; border-right:1px solid #e7e7e7; border-bottom:1px solid #e7e7e7;}
.hw_popup_testtable tr td{ width:47%; padding:10px; color:#888; border-left:1px solid #e7e7e7; border-top:1px solid #e7e7e7; }
.hw_popup_testtable tr td.test_td_min{ width:5%; color:#888;}
.hw_popup_testtable tr td.test_td_title{ text-align:center; color:#888888;}
/* 我的作业 */
.hw_classname{ width:180px; overflow:hidden; display:block;overflow:hidden;white-space: nowrap; text-overflow:ellipsis;}
#hw_tab_con_1 .sy_classbox .sy_classlist:last-child{ border-bottom:1px solid #ddd;}
.hw_tab_top{ height: 50px; line-height: 50px; padding-left: 15px; border-bottom:1px solid #ddd; border-left:3px solid #3b94d6; }
.hw_tab_top{ height: 50px; line-height: 50px; padding-left: 15px; border-bottom:1px solid #ddd; border-left:3px solid #3b94d6; }