|
|
|
@ -5,14 +5,15 @@ class CoursesController < ApplicationController
|
|
|
|
|
menu_item l(:label_sort_by_active), :only => :index
|
|
|
|
|
menu_item l(:label_sort_by_influence), :only => :index
|
|
|
|
|
|
|
|
|
|
before_filter :find_course, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
|
|
|
|
|
before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
|
|
|
|
#before_filter :authorize_global, :only => [:view_homework_attaches, :new,:create]
|
|
|
|
|
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
|
|
|
|
before_filter :toggleCourse, only: [:finishcourse, :restartcourse]
|
|
|
|
|
|
|
|
|
|
before_filter :require_login, :only => [:join, :unjoin]
|
|
|
|
|
before_filter :allow_join, :only => [:join]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def join
|
|
|
|
|
if User.current.logged?
|
|
|
|
|
course = Project.find(params[:object_id])
|
|
|
|
@ -299,6 +300,24 @@ class CoursesController < ApplicationController
|
|
|
|
|
return activities
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def toggleCourse
|
|
|
|
|
@course_prefs = Course.find_by_extra(@course.extra)
|
|
|
|
|
unless (@course_prefs.teacher == User.current || User.current.admin?)
|
|
|
|
|
render_403
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def finishcourse
|
|
|
|
|
yesterday = Date.today.prev_day.to_time
|
|
|
|
|
|
|
|
|
|
@course_prefs.endup_time = yesterday
|
|
|
|
|
@save_flag = @course_prefs.save
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def allow_join
|
|
|
|
|