parent
69e366d841
commit
a49cf3eb6b
|
@ -247,6 +247,22 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
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
|
||||
else
|
||||
limit = @bid_count % @limit
|
||||
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
||||
end
|
||||
render :layout => 'base_courses'
|
||||
end
|
||||
|
||||
def get_course_activity courses, activities
|
||||
@course_ids=activities.keys()
|
||||
|
|
|
@ -20,7 +20,6 @@ class Course < ActiveRecord::Base
|
|||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
has_many :homework_for_courses, :dependent => :destroy
|
||||
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||
has_many :student, :through => :students_for_courses, :source => :user
|
||||
|
||||
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
<%= l(:label_x_base_courses_member, :count => membership.course.members.count) %>
|
||||
(<%= "#{membership.course.members.count}" %>)
|
||||
<%= l(:label_homework) %>
|
||||
(<span class=""><%= link_to (membership.course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => membership.course.identifier} %></span>)
|
||||
(<span class=""><%= link_to (membership.course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => membership.course.extra} %></span>)
|
||||
|
||||
<%= l(:label_course_news) %>
|
||||
(<span style="color: #ed8924"><%= link_to (membership.course.news.count), {:controller => 'news', :action => 'index', :course_id => membership.course.identifier} %></span>)
|
||||
(<span style="color: #ed8924"><%= link_to (membership.course.news.count), {:controller => 'news', :action => 'index', :course_id => membership.course.extra} %></span>)
|
||||
</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -548,6 +548,8 @@ RedmineApp::Application.routes.draw do
|
|||
resources :courses do
|
||||
member do
|
||||
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||
get 'homework', :action => 'homework', :as => 'homework'
|
||||
get 'new_homework', :action => 'new_homework', :as => 'new_homework'
|
||||
post 'finishcourse'
|
||||
post 'restartcourse'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue