|
|
|
@ -470,23 +470,27 @@ class CoursesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def homework
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@bids = @course.homeworks.order('deadline DESC')
|
|
|
|
|
@bids = @bids.like(params[:name]) if params[:name].present?
|
|
|
|
|
@bid_count = @bids.count
|
|
|
|
|
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
|
|
|
|
|
|
|
|
|
@offset ||= @bid_pages.reverse_offset
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
if @course.is_public == 0
|
|
|
|
|
render_403
|
|
|
|
|
else
|
|
|
|
|
limit = @bid_count % @limit
|
|
|
|
|
if limit == 0
|
|
|
|
|
limit = 10
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@bids = @course.homeworks.order('deadline DESC')
|
|
|
|
|
@bids = @bids.like(params[:name]) if params[:name].present?
|
|
|
|
|
@bid_count = @bids.count
|
|
|
|
|
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
|
|
|
|
|
|
|
|
|
@offset ||= @bid_pages.reverse_offset
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
else
|
|
|
|
|
limit = @bid_count % @limit
|
|
|
|
|
if limit == 0
|
|
|
|
|
limit = 10
|
|
|
|
|
end
|
|
|
|
|
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
|
|
|
|
end
|
|
|
|
|
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
|
|
|
|
render :layout => 'base_courses'
|
|
|
|
|
end
|
|
|
|
|
render :layout => 'base_courses'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 新建作业
|
|
|
|
|