diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 22d8deb0c..e724f7a9c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb new file mode 100644 index 000000000..6476f9e71 --- /dev/null +++ b/app/views/users/_user_homework_list.html.erb @@ -0,0 +1,55 @@ +<% homework_commons.each do |homework_common|%> + <% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> +
+
+
+ <%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%> +
+
+
+ <%= 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"%> +
+
+ <%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%> +
+ +
+
+ <%= user_for_homework_common homework_common,is_teacher %> +
+
+ <%= l(:label_end_time)%>:<%= homework_common.end_time%> +
+
+
+ <%= homework_common.description.html_safe %> +
+
+ <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %> +
+
+ <% if is_teacher%> +
+
    +
  • +
      +
    • + <%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%> +
    • +
    • + <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> +
    • +
    +
  • +
+
+ <% end%> +
+
+
+
+<% end%> + + \ No newline at end of file diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index a6032a60b..19ecf3588 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -1,3 +1,18 @@ + + <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%>
@@ -42,56 +57,4 @@
<% end%> -<% @homework_commons.each do |homework_common|%> - <% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %> -
-
-
- <%=link_to image_tag(url_to_avatar(homework_common.user),width:"90px", height: "90px"), user_activities_path(homework_common.user.id)%> -
-
-
- <%= 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"%> -
-
- <%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%> -
- -
-
- <%= user_for_homework_common homework_common,is_teacher %> -
-
- <%= l(:label_end_time)%>:<%= homework_common.end_time%> -
-
-
- <%= homework_common.description.html_safe %> -
-
- <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => homework_common.attachments} %> -
-
- <% if is_teacher%> -
-
    -
  • -
      -
    • - <%= link_to l(:button_edit),edit_homework_common_path(homework_common), :class => "postOptionLink"%> -
    • -
    • - <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> -
    • -
    -
  • -
-
- <% end%> -
-
-
-
-<% end%> +<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0} %> diff --git a/app/views/users/user_homeworks.js.erb b/app/views/users/user_homeworks.js.erb new file mode 100644 index 000000000..a2e778a21 --- /dev/null +++ b/app/views/users/user_homeworks.js.erb @@ -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%>