|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
class CoursesController < ApplicationController
|
|
|
|
|
layout 'base_courses'
|
|
|
|
|
include CoursesHelper
|
|
|
|
|
include ActivitiesHelper
|
|
|
|
|
helper :activities
|
|
|
|
|
helper :members
|
|
|
|
|
helper :words
|
|
|
|
@ -680,26 +681,49 @@ class CoursesController < ApplicationController
|
|
|
|
|
"show_course_files" => true,
|
|
|
|
|
"show_course_news" => true,
|
|
|
|
|
"show_course_messages" => true,
|
|
|
|
|
"show_bids" => true,
|
|
|
|
|
"show_course_journals_for_messages" => true,
|
|
|
|
|
"show_bids" => true,
|
|
|
|
|
"show_homeworks" => true
|
|
|
|
|
}
|
|
|
|
|
@date_to ||= Date.today + 1
|
|
|
|
|
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
|
|
|
|
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
|
|
|
|
@author ||= @course.teacher
|
|
|
|
|
# 决定显示所用用户或单个用户活动
|
|
|
|
|
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
|
|
|
|
:with_subprojects => false,
|
|
|
|
|
:author => @author)
|
|
|
|
|
@activity.scope_select {|t| has["show_#{t}"]}
|
|
|
|
|
# modify by nwb
|
|
|
|
|
# 添加私密性判断
|
|
|
|
|
if User.current.member_of_course?(@course)|| User.current.admin?
|
|
|
|
|
events = @activity.events(@days, @course.created_at)
|
|
|
|
|
if @author.nil?
|
|
|
|
|
# 显示老师和助教的活动
|
|
|
|
|
# @authors = searchTeacherAndAssistant(@course)
|
|
|
|
|
@authors = course_all_member(@course)
|
|
|
|
|
events = []
|
|
|
|
|
@authors.each do |author|
|
|
|
|
|
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
|
|
|
|
:with_subprojects => false,
|
|
|
|
|
:author => author.user)
|
|
|
|
|
|
|
|
|
|
@activity.scope_select {|t| has["show_#{t}"]}
|
|
|
|
|
# modify by nwb
|
|
|
|
|
# 添加私密性判断
|
|
|
|
|
if User.current.member_of_course?(@course)|| User.current.admin?
|
|
|
|
|
events += @activity.events(@days, @course.created_at)
|
|
|
|
|
else
|
|
|
|
|
events += @activity.events(@days, @course.created_at, :is_public => 1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
events = @activity.events(@days, @course.created_at, :is_public => 1)
|
|
|
|
|
# @author = @course.teacher
|
|
|
|
|
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
|
|
|
|
:with_subprojects => false,
|
|
|
|
|
:author => @author)
|
|
|
|
|
|
|
|
|
|
@activity.scope_select {|t| has["show_#{t}"]}
|
|
|
|
|
# modify by nwb
|
|
|
|
|
# 添加私密性判断
|
|
|
|
|
if User.current.member_of_course?(@course)|| User.current.admin?
|
|
|
|
|
events = @activity.events(@days, @course.created_at)
|
|
|
|
|
else
|
|
|
|
|
events = @activity.events(@days, @course.created_at, :is_public => 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 无新动态时,显示老动态
|
|
|
|
|
if events.count == 0
|
|
|
|
|
if User.current.member_of_course?(@course)|| User.current.admin?
|
|
|
|
@ -708,13 +732,17 @@ class CoursesController < ApplicationController
|
|
|
|
|
events = @activity.events(:is_public => 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
events = paginateHelper events,10
|
|
|
|
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
|
|
|
|
# documents
|
|
|
|
|
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
|
|
|
|
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
|
|
|
|
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
sorted_events = sort_activity_events_course(events);
|
|
|
|
|
events = paginateHelper sorted_events,10
|
|
|
|
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
|
|
|
|
# documents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html{render :layout => 'base_courses'}
|
|
|
|
|
format.api
|
|
|
|
|