1、引入资源到作业移除部分css

2、课程内点击作业列表加载更多
This commit is contained in:
sw 2015-09-29 10:20:13 +08:00
parent 9a5dba7773
commit ad4fc50fbb
8 changed files with 15 additions and 8 deletions

View File

@ -18,8 +18,7 @@ class HomeworkCommonController < ApplicationController
@homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
# @homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset()
# @homeworks = paginateHelper homeworks,20
@is_new = params[:is_new]
respond_to do |format|
format.js
format.html
@ -38,7 +37,7 @@ class HomeworkCommonController < ApplicationController
def edit
@user = User.current
@is_in_course = params[:is_in_course]
@is_in_course = params[:is_in_course].to_i
respond_to do |format|
format.html{render :layout => 'new_base_user'}
end

View File

@ -346,6 +346,7 @@ class UsersController < ApplicationController
user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
@homework_commons = HomeworkCommon.where("course_id in #{user_course_ids}").order("created_at desc").limit(10).offset(@page * 10)
@is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)
@is_in_course = params[:is_in_course].to_i || 0
respond_to do |format|
format.js
format.html {render :layout => 'new_base_user'}

View File

@ -36,7 +36,7 @@
</div><!----HomeWork end-->
<% end%>
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,:page => 0,:is_in_course => 1} %>
<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homeworks,:page => 0,:is_in_course => 1,:course_id => @course.id} %>
</div>
<div class="cl"></div>

View File

@ -0,0 +1 @@
$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homeworks, :page => @page, :is_in_course => 1,:course_id => @course.id} )%>");

View File

@ -91,7 +91,7 @@
<%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
</div>
<div class="subNav">
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
<%= link_to l(:label_homework), homework_common_index_path(:course => @course.id,:is_new => 1), :class => "f14 c_blue02"%>
<%= link_to "(#{@course.homework_commons.count})", homework_common_index_path(:course => @course.id), :class => "subnav_num c_orange"%>
<%= link_to( "+#{l(:label_course_homework_new)}", "javascript:void(0)", :class => 'subnav_green c_white', :onclick => "new_homework_alert();") if is_teacher %>
</div>

View File

@ -80,5 +80,11 @@
</div><!----HomeWork end-->
<% end%>
<% if homework_commons.count == 10%>
<%= link_to "加载更多",user_homeworks_user_path(User.current.id,:page => page),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
<% 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"%>
<% else%>
<!-- 在个人主页 -->
<%= link_to "加载更多",user_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"%>
<% end%>
<% end%>

View File

@ -12,5 +12,5 @@
'<div class="cl"></div>')
<% end %>
hideModal();
hideResource();
<% end %>

View File

@ -1,2 +1,2 @@
$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page} )%>");
$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>");