作业列表滚动到底部显示下面10条作业
This commit is contained in:
parent
bedc364275
commit
d8b87ccc37
|
@ -305,10 +305,11 @@ class UsersController < ApplicationController
|
|||
|
||||
#用户作业列表
|
||||
def user_homeworks
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
|
||||
homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc")
|
||||
@homework_commons = paginateHelper homework_commons,10
|
||||
@homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10)
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'new_base_user'}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<% homework_commons.each do |homework_common|%>
|
||||
<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %>
|
||||
<div class="HomeWork mb10">
|
||||
<div class="homepagePostBrief">
|
||||
<div class="homepagePostPortrait">
|
||||
<%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%>
|
||||
</div>
|
||||
<div class="homepagePostDes">
|
||||
<div class="homepagePostTo">
|
||||
<%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%>
|
||||
TO
|
||||
<%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
|
||||
</div>
|
||||
<div class="homepagePostTitle">
|
||||
<%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
|
||||
</div>
|
||||
|
||||
<div class="homepagePostSubmitContainer">
|
||||
<div class="homepagePostSubmit">
|
||||
<%= user_for_homework_common homework_common,is_teacher %>
|
||||
</div>
|
||||
<div class="homepagePostDeadline">
|
||||
<%= l(:label_end_time)%>:<%= homework_common.end_time%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="homepagePostIntro upload_img break_word">
|
||||
<%= homework_common.description.html_safe %>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% if is_teacher%>
|
||||
<div class="homepagePostSetting">
|
||||
<ul>
|
||||
<li class="homepagePostSettingIcon">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li>
|
||||
<%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div><!----HomeWork end-->
|
||||
<% end%>
|
||||
|
||||
<input type="hidden" value="<%= page%>" id="user_show_more_homework" />
|
|
@ -1,3 +1,18 @@
|
|||
<script type="text/javascript">
|
||||
var scrollHandler = function(){
|
||||
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
|
||||
$.get(
|
||||
'<%= user_homeworks_user_path(User.current.id)%>',
|
||||
{ page : $("#user_show_more_homework").val()},
|
||||
function (data) {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
$(window).scroll(scrollHandler);
|
||||
</script>
|
||||
|
||||
<% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
|
||||
<!-- 老师身份才可以发布作业 -->
|
||||
<div class="HomeWork mb10">
|
||||
|
@ -42,56 +57,4 @@
|
|||
</div><!----HomeWork end-->
|
||||
<% end%>
|
||||
|
||||
<% @homework_commons.each do |homework_common|%>
|
||||
<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %>
|
||||
<div class="HomeWork mb10">
|
||||
<div class="homepagePostBrief">
|
||||
<div class="homepagePostPortrait">
|
||||
<%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%>
|
||||
</div>
|
||||
<div class="homepagePostDes">
|
||||
<div class="homepagePostTo">
|
||||
<%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%>
|
||||
TO
|
||||
<%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
|
||||
</div>
|
||||
<div class="homepagePostTitle">
|
||||
<%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
|
||||
</div>
|
||||
|
||||
<div class="homepagePostSubmitContainer">
|
||||
<div class="homepagePostSubmit">
|
||||
<%= user_for_homework_common homework_common,is_teacher %>
|
||||
</div>
|
||||
<div class="homepagePostDeadline">
|
||||
<%= l(:label_end_time)%>:<%= homework_common.end_time%>
|
||||
</div>
|
||||
</div>
|
||||
<div class="homepagePostIntro upload_img break_word">
|
||||
<%= homework_common.description.html_safe %>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<% if is_teacher%>
|
||||
<div class="homepagePostSetting">
|
||||
<ul>
|
||||
<li class="homepagePostSettingIcon">
|
||||
<ul class="homepagePostSettiongText">
|
||||
<li>
|
||||
<%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end%>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div><!----HomeWork end-->
|
||||
<% end%>
|
||||
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0} %>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page} )%>");
|
||||
<% if @homework_commons.count < 10%>
|
||||
$(window).off("scroll", scrollHandler);
|
||||
<% end%>
|
Loading…
Reference in New Issue