作业列表增加序号和翻页、按创建时间倒排
This commit is contained in:
parent
31d94dc052
commit
0f2f4717b6
|
@ -20,15 +20,16 @@ class HomeworkCommonController < ApplicationController
|
||||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||||
@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("updated_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.order("created_at desc")
|
||||||
else
|
else
|
||||||
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_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("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]
|
||||||
|
|
||||||
|
@homeworks = paginateHelper @homework_commons,10
|
||||||
#设置at已读
|
#设置at已读
|
||||||
@homeworks.each do |homework|
|
@homeworks.each do |homework|
|
||||||
homework.journals_for_messages.each do |j|
|
homework.journals_for_messages.each do |j|
|
||||||
|
|
|
@ -3248,3 +3248,14 @@ def strip_html(text,len=0,endss="...")
|
||||||
end
|
end
|
||||||
return ss
|
return ss
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_hw_index(hw,is_teacher)
|
||||||
|
if is_teacher
|
||||||
|
homeworks = hw.course.homework_commons.order("created_at asc")
|
||||||
|
else
|
||||||
|
homeworks = hw.course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at asc")
|
||||||
|
end
|
||||||
|
hw_ids = homeworks.map{|hw| hw.id} if !homeworks.empty?
|
||||||
|
index = hw_ids.index(hw.id)
|
||||||
|
return index
|
||||||
|
end
|
||||||
|
|
|
@ -73,6 +73,12 @@
|
||||||
<% end%>
|
<% end%>
|
||||||
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,:page => 0,:is_in_course => 1,:course_id => @course.id} %>
|
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,: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>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,12 @@
|
||||||
<%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
|
<%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
|
||||||
</div>
|
</div>
|
||||||
<span class="homepagePostTitle hidden fl m_w505">
|
<span class="homepagePostTitle hidden fl m_w505">
|
||||||
<%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
|
<% if is_in_course == 1%>
|
||||||
|
<% index = get_hw_index(homework_common, is_teacher) %>
|
||||||
|
<%= link_to "<span class='fontBlue2'>作业#{index+1}:</span>".html_safe+homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
|
||||||
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<% if homework_common.homework_detail_manual%>
|
<% if homework_common.homework_detail_manual%>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<% if homework_commons.count == 10%>
|
<% if homework_commons.count == 10%>
|
||||||
<% if is_in_course == 1%>
|
<% if is_in_course == 1%>
|
||||||
<!-- 在课程内 -->
|
<!-- 在课程内 -->
|
||||||
<%= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
|
<%#= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
|
||||||
<% else%>
|
<% else%>
|
||||||
<!-- 在个人主页 -->
|
<!-- 在个人主页 -->
|
||||||
<%= link_to "点击展开更多",student_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
|
<%= link_to "点击展开更多",student_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
|
||||||
|
|
Loading…
Reference in New Issue