去除无用代码
This commit is contained in:
parent
37bd338311
commit
0408cc5150
|
@ -33,28 +33,6 @@ class CoursesController < ApplicationController
|
||||||
join = cs.join_course params,User.current
|
join = cs.join_course params,User.current
|
||||||
@state = join[:state]
|
@state = join[:state]
|
||||||
course = join[:course]
|
course = join[:course]
|
||||||
#course = Course.find_by_id params[:object_id]
|
|
||||||
#if course
|
|
||||||
# if course_endTime_timeout? course
|
|
||||||
# @state = 2
|
|
||||||
# else
|
|
||||||
# if User.current.member_of_course?(course)
|
|
||||||
# @state = 3
|
|
||||||
# else
|
|
||||||
# if params[:course_password] == course.password
|
|
||||||
# members = []
|
|
||||||
# members << Member.new(:role_ids => [10], :user_id => User.current.id)
|
|
||||||
# course.members << members
|
|
||||||
# StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id])
|
|
||||||
# @state = 0
|
|
||||||
# else
|
|
||||||
# @state = 1
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#else
|
|
||||||
# @state = 4
|
|
||||||
#end
|
|
||||||
else
|
else
|
||||||
@state = 5 #未登录
|
@state = 5 #未登录
|
||||||
end
|
end
|
||||||
|
@ -71,26 +49,15 @@ class CoursesController < ApplicationController
|
||||||
|
|
||||||
def unjoin
|
def unjoin
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
#
|
|
||||||
# @member = Member.where('course_id = ? and user_id = ?', params[:object_id], User.current.id)
|
|
||||||
# @member.first.destroy
|
|
||||||
#
|
|
||||||
# joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id])
|
|
||||||
# joined.each do |join|
|
|
||||||
# join.delete
|
|
||||||
# end
|
|
||||||
cs = CoursesService.new
|
cs = CoursesService.new
|
||||||
cs.exit_course params,User.current
|
cs.exit_course params,User.current
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
|
|
||||||
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} }
|
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def join_private_courses
|
def join_private_courses
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
@ -119,36 +86,6 @@ class CoursesController < ApplicationController
|
||||||
format.api { render_validation_errors(@course) }
|
format.api { render_validation_errors(@course) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#@course.safe_attributes = params[:course]
|
|
||||||
#@course.time = params[:time]
|
|
||||||
#@course.term = params[:term]
|
|
||||||
#@course.class_period = params[:class_period]
|
|
||||||
#if @course.save
|
|
||||||
# if params[:course][:is_public] == '0'
|
|
||||||
# course_status = CourseStatus.find_by_course_id(@course.id)
|
|
||||||
# course_status.destroy if course_status
|
|
||||||
# elsif params[:course][:is_public] == '1'
|
|
||||||
# course_status = CourseStatus.find_by_course_id(@course.id)
|
|
||||||
# course_status.destroy if course_status
|
|
||||||
# course_status = CourseStatus.create(:course_id => @course.id, :grade => 0)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# respond_to do |format|
|
|
||||||
# format.html {
|
|
||||||
# flash[:notice] = l(:notice_successful_update)
|
|
||||||
# redirect_to settings_course_url(@course)
|
|
||||||
# }
|
|
||||||
# format.api { render_api_ok }
|
|
||||||
# end
|
|
||||||
#else
|
|
||||||
# respond_to do |format|
|
|
||||||
# format.html {
|
|
||||||
# settings
|
|
||||||
# render :action => 'settings'
|
|
||||||
# }
|
|
||||||
# format.api { render_validation_errors(@course) }
|
|
||||||
# end
|
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_join
|
def new_join
|
||||||
|
@ -160,7 +97,6 @@ class CoursesController < ApplicationController
|
||||||
def search
|
def search
|
||||||
courses_all = Course.all_course
|
courses_all = Course.all_course
|
||||||
name = params[:name]
|
name = params[:name]
|
||||||
#(redirect_to courses_url, :notice => l(:label_sumbit_empty);return) if name.blank?
|
|
||||||
if name.blank?
|
if name.blank?
|
||||||
@courses = []
|
@courses = []
|
||||||
@courses_all = []
|
@courses_all = []
|
||||||
|
@ -347,22 +283,15 @@ class CoursesController < ApplicationController
|
||||||
@score_sort_by = "desc"
|
@score_sort_by = "desc"
|
||||||
if params[:group_id] && params[:group_id] != "0"
|
if params[:group_id] && params[:group_id] != "0"
|
||||||
@group = CourseGroup.find(params[:group_id])
|
@group = CourseGroup.find(params[:group_id])
|
||||||
|
|
||||||
@results = student_homework_score(@group.id,0, 0,"desc")
|
@results = student_homework_score(@group.id,0, 0,"desc")
|
||||||
@results = paginateHelper @results, 10
|
@results = paginateHelper @results, 10
|
||||||
|
|
||||||
|
|
||||||
else
|
else
|
||||||
page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1)
|
page_from = params[:page].nil? ? 0 : (params[:page].to_i - 1)
|
||||||
@results = student_homework_score(0,page_from, 10,"desc")
|
@results = student_homework_score(0,page_from, 10,"desc")
|
||||||
@results = paginateHelper_for_members @results, 10
|
@results = paginateHelper_for_members @results, 10
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def member
|
def member
|
||||||
## 有角色参数的才是课程,没有的就是项目
|
## 有角色参数的才是课程,没有的就是项目
|
||||||
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
|
||||||
|
@ -383,12 +312,8 @@ class CoursesController < ApplicationController
|
||||||
@subPage_title = l :label_student_list
|
@subPage_title = l :label_student_list
|
||||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||||
@all_members = student_homework_score(0,page, 10,"desc")
|
@all_members = student_homework_score(0,page, 10,"desc")
|
||||||
|
|
||||||
@members = paginateHelper_for_members @all_members, 10
|
@members = paginateHelper_for_members @all_members, 10
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if params[:page]
|
if params[:page]
|
||||||
format.js
|
format.js
|
||||||
|
@ -396,12 +321,9 @@ class CoursesController < ApplicationController
|
||||||
format.html {render :layout => 'base_courses'}
|
format.html {render :layout => 'base_courses'}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# render :layout => 'base_courses'
|
|
||||||
else
|
else
|
||||||
render_403
|
render_403
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def export_course_member_excel
|
def export_course_member_excel
|
||||||
|
@ -415,20 +337,9 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def member_score_sort
|
def member_score_sort
|
||||||
|
|
||||||
# @teachers= searchTeacherAndAssistant(@course)
|
|
||||||
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
@canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
|
||||||
# @role = params[:role]
|
|
||||||
# @course_groups = @course.course_groups if @course.course_groups
|
|
||||||
# @show_serch = params[:role] == '2'
|
|
||||||
@subPage_title = l :label_student_list
|
@subPage_title = l :label_student_list
|
||||||
@render_file = 'member_list'
|
@render_file = 'member_list'
|
||||||
# @results = params[:result] if params[:result]
|
|
||||||
# unless @result.nil?
|
|
||||||
# @results = @result.reverse
|
|
||||||
#
|
|
||||||
# end
|
|
||||||
# @results = paginateHelper @results@score_sort_by = "desc"
|
|
||||||
@is_remote = true
|
@is_remote = true
|
||||||
@score_sort_by = params[:sort_by] if params[:sort_by]
|
@score_sort_by = params[:sort_by] if params[:sort_by]
|
||||||
@search_name = params[:search_name] if params[:search_name]
|
@search_name = params[:search_name] if params[:search_name]
|
||||||
|
@ -436,7 +347,6 @@ class CoursesController < ApplicationController
|
||||||
if !@search_name.nil?
|
if !@search_name.nil?
|
||||||
if group_id == '0'
|
if group_id == '0'
|
||||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||||
|
|
||||||
@results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name)
|
@results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name)
|
||||||
@result_count = @results.count
|
@result_count = @results.count
|
||||||
@results = paginateHelper @results, 10
|
@results = paginateHelper @results, 10
|
||||||
|
@ -450,7 +360,6 @@ class CoursesController < ApplicationController
|
||||||
if group_id == '0'
|
if group_id == '0'
|
||||||
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
|
||||||
@results = student_homework_score(0,page, 10,@score_sort_by)
|
@results = student_homework_score(0,page, 10,@score_sort_by)
|
||||||
|
|
||||||
@results = paginateHelper_for_members @results, 10
|
@results = paginateHelper_for_members @results, 10
|
||||||
else
|
else
|
||||||
@group = CourseGroup.find(group_id)
|
@group = CourseGroup.find(group_id)
|
||||||
|
@ -458,32 +367,25 @@ class CoursesController < ApplicationController
|
||||||
@results = paginateHelper @results, 10
|
@results = paginateHelper @results, 10
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
# 显示每个学生的作业评分详情
|
# 显示每个学生的作业评分详情
|
||||||
def show_member_score
|
def show_member_score
|
||||||
|
|
||||||
@member_score = Member.find(params[:member_id]) if params[:member_id]
|
@member_score = Member.find(params[:member_id]) if params[:member_id]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {render :layout => 'course_base'}
|
format.html {render :layout => 'course_base'}
|
||||||
format.js
|
format.js
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_course courses, activities
|
def handle_course courses, activities
|
||||||
course_activity_count_array=activities.values()
|
course_activity_count_array=activities.values()
|
||||||
|
|
||||||
course_array=[]
|
course_array=[]
|
||||||
i=0;
|
i=0;
|
||||||
courses.each do |course|
|
courses.each do |course|
|
||||||
course_array[i]=course
|
course_array[i]=course
|
||||||
i=i+1
|
i=i+1
|
||||||
end
|
end
|
||||||
|
|
||||||
courses=desc_sort_course_by_avtivity(course_activity_count_array, course_array)
|
courses=desc_sort_course_by_avtivity(course_activity_count_array, course_array)
|
||||||
|
|
||||||
return courses
|
return courses
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -522,57 +424,6 @@ class CoursesController < ApplicationController
|
||||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
#if User.current.user_extensions.identity
|
|
||||||
# @course = Course.new
|
|
||||||
# @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
|
||||||
# @course.safe_attributes = params[:course]
|
|
||||||
# @course.tea_id = User.current.id
|
|
||||||
# # added by bai
|
|
||||||
# @course.term = params[:term]
|
|
||||||
# @course.time = params[:time]
|
|
||||||
# #@course.school_id = params[:occupation]
|
|
||||||
# @course.school_id = User.current.user_extensions.school_id
|
|
||||||
# @course.setup_time = params[:setup_time]
|
|
||||||
# @course.endup_time = params[:endup_time]
|
|
||||||
# @course.class_period = params[:class_period]
|
|
||||||
#end
|
|
||||||
#
|
|
||||||
#@issue_custom_fields = IssueCustomField.sorted.all
|
|
||||||
#@trackers = Tracker.sorted.all
|
|
||||||
#
|
|
||||||
#if @course.save
|
|
||||||
# #unless User.current.admin?
|
|
||||||
# r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
|
||||||
# m = Member.new(:user => User.current, :roles => [r])
|
|
||||||
# m.project_id = -1
|
|
||||||
# course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id)
|
|
||||||
# #user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
|
||||||
# if params[:course][:is_public] == '1'
|
|
||||||
# course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
|
||||||
# end
|
|
||||||
# @course.members << m
|
|
||||||
# @course.course_infos << course
|
|
||||||
# #end
|
|
||||||
# respond_to do |format|
|
|
||||||
# format.html {
|
|
||||||
# flash[:notice] = l(:notice_successful_create)
|
|
||||||
# if params[:continue]
|
|
||||||
# redirect_to new_course_url(attrs, :course => '0')
|
|
||||||
# elsif params[:course_continue]
|
|
||||||
# redirect_to new_course_url(:course => '1')
|
|
||||||
# else
|
|
||||||
# redirect_to settings_course_url(@course, :course_type => 1)
|
|
||||||
# end
|
|
||||||
# }
|
|
||||||
# format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
|
||||||
# end
|
|
||||||
# else
|
|
||||||
# #@course.destroy
|
|
||||||
# respond_to do |format|
|
|
||||||
# format.html { render :action => 'new', :layout => 'base' } #Added by young
|
|
||||||
# format.api { render_validation_errors(@course) }
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def course
|
def course
|
||||||
|
@ -590,54 +441,28 @@ class CoursesController < ApplicationController
|
||||||
|
|
||||||
@course_count = @courses_all.count
|
@course_count = @courses_all.count
|
||||||
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||||
|
|
||||||
#gcm activity count
|
|
||||||
|
|
||||||
@course_activity_count=Hash.new
|
@course_activity_count=Hash.new
|
||||||
#count initialize
|
|
||||||
@courses_all.each do |course|
|
@courses_all.each do |course|
|
||||||
@course_activity_count[course.id]=0
|
@course_activity_count[course.id]=0
|
||||||
end
|
end
|
||||||
|
|
||||||
#@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
|
||||||
#gcm end
|
|
||||||
|
|
||||||
|
|
||||||
case params[:course_sort_type]
|
case params[:course_sort_type]
|
||||||
when '0'
|
when '0'
|
||||||
@courses = @courses_all.order("created_on desc")
|
@courses = @courses_all.order("created_on desc")
|
||||||
@s_type = 0
|
@s_type = 0
|
||||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
|
||||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
|
||||||
|
|
||||||
when '1'
|
when '1'
|
||||||
@courses = @courses_all.order("course_ac_para desc")
|
@courses = @courses_all.order("course_ac_para desc")
|
||||||
@s_type = 1
|
@s_type = 1
|
||||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
|
||||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
|
||||||
|
|
||||||
when '2'
|
when '2'
|
||||||
@courses = @courses_all.order("watchers_count desc")
|
@courses = @courses_all.order("watchers_count desc")
|
||||||
@s_type = 2
|
@s_type = 2
|
||||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
|
||||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
|
||||||
|
|
||||||
#gcm
|
|
||||||
when '3'
|
when '3'
|
||||||
|
|
||||||
#gcm
|
|
||||||
@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
||||||
#gcmend
|
|
||||||
|
|
||||||
@courses=handle_course @courses_all,@course_activity_count
|
@courses=handle_course @courses_all,@course_activity_count
|
||||||
@s_type = 3
|
@s_type = 3
|
||||||
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||||
|
@ -645,11 +470,7 @@ class CoursesController < ApplicationController
|
||||||
@s_type = 0
|
@s_type = 0
|
||||||
@courses = @courses_all.order("created_on desc")
|
@courses = @courses_all.order("created_on desc")
|
||||||
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
#gcm
|
|
||||||
@course_activity_count=get_course_activity @courses,@course_activity_count
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
#gcmend
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -657,9 +478,6 @@ class CoursesController < ApplicationController
|
||||||
render :layout => 'base'
|
render :layout => 'base'
|
||||||
}
|
}
|
||||||
format.api {
|
format.api {
|
||||||
# @offset, @limit = api_offset_and_limit
|
|
||||||
# @course_count = Course.visible.count
|
|
||||||
# @courses = Course.visible.offset(@offset).limit(@limit).order('lft').all
|
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||||
|
@ -668,20 +486,16 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@course_type = params[:course_type] ||= params[:course]
|
@course_type = params[:course_type] ||= params[:course]
|
||||||
@issue_custom_fields = IssueCustomField.sorted.all
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
@trackers = Tracker.sorted.all
|
@trackers = Tracker.sorted.all
|
||||||
|
|
||||||
@course = Course.new
|
@course = Course.new
|
||||||
@course.safe_attributes = params[:course]
|
@course.safe_attributes = params[:course]
|
||||||
month = Time.now.month
|
month = Time.now.month
|
||||||
|
|
||||||
render :layout => 'base'
|
render :layout => 'base'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def desc_sort_course_by_avtivity(activity_count, courses)
|
def desc_sort_course_by_avtivity(activity_count, courses)
|
||||||
return courses if activity_count.size<2
|
return courses if activity_count.size<2
|
||||||
(activity_count.size-2).downto(0) do |i|
|
(activity_count.size-2).downto(0) do |i|
|
||||||
|
@ -762,22 +576,6 @@ class CoursesController < ApplicationController
|
||||||
bids = bids.like(params[:name]) if params[:name].present?
|
bids = bids.like(params[:name]) if params[:name].present?
|
||||||
@bids = paginateHelper bids,10
|
@bids = paginateHelper bids,10
|
||||||
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
|
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
|
||||||
#
|
|
||||||
# @offset, @limit = api_offset_and_limit({:limit => 10})
|
|
||||||
#
|
|
||||||
# @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
|
|
||||||
render :layout => 'base_courses'
|
render :layout => 'base_courses'
|
||||||
else
|
else
|
||||||
render_403
|
render_403
|
||||||
|
@ -853,26 +651,19 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
||||||
# try to redirect to the requested menu item
|
|
||||||
if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
|
if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@users_by_role = @course.users_by_role
|
@users_by_role = @course.users_by_role
|
||||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
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)
|
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@key = User.current.rss_key
|
@key = User.current.rss_key
|
||||||
#新增内容
|
#新增内容
|
||||||
@days = Setting.activity_days_default.to_i
|
@days = Setting.activity_days_default.to_i
|
||||||
|
|
||||||
if params[:from]
|
if params[:from]
|
||||||
begin; @date_to = params[:from].to_date + 1; rescue; end
|
begin; @date_to = params[:from].to_date + 1; rescue; end
|
||||||
end
|
end
|
||||||
|
|
||||||
has = {
|
has = {
|
||||||
"show_course_files" => true,
|
"show_course_files" => true,
|
||||||
"show_course_news" => true,
|
"show_course_news" => true,
|
||||||
|
@ -881,9 +672,7 @@ class CoursesController < ApplicationController
|
||||||
"show_course_journals_for_messages" => true
|
"show_course_journals_for_messages" => true
|
||||||
}
|
}
|
||||||
@date_to ||= Date.today + 1
|
@date_to ||= Date.today + 1
|
||||||
#
|
|
||||||
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
@date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date
|
||||||
#@date_from = @date_to - @days-1.years
|
|
||||||
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
||||||
# 决定显示所用用户或单个用户活动
|
# 决定显示所用用户或单个用户活动
|
||||||
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
||||||
|
@ -892,13 +681,11 @@ class CoursesController < ApplicationController
|
||||||
@activity.scope_select {|t| has["show_#{t}"]}
|
@activity.scope_select {|t| has["show_#{t}"]}
|
||||||
# modify by nwb
|
# modify by nwb
|
||||||
# 添加私密性判断
|
# 添加私密性判断
|
||||||
|
|
||||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||||
events = @activity.events(@days, @course.created_at)
|
events = @activity.events(@days, @course.created_at)
|
||||||
else
|
else
|
||||||
events = @activity.events(@days, @course.created_at, :is_public => 1)
|
events = @activity.events(@days, @course.created_at, :is_public => 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
# 无新动态时,显示老动态
|
# 无新动态时,显示老动态
|
||||||
if events.count == 0
|
if events.count == 0
|
||||||
if User.current.member_of_course?(@course)|| User.current.admin?
|
if User.current.member_of_course?(@course)|| User.current.admin?
|
||||||
|
@ -907,21 +694,10 @@ class CoursesController < ApplicationController
|
||||||
events = @activity.events(:is_public => 1)
|
events = @activity.events(:is_public => 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# @offset, @limit = api_offset_and_limit({:limit => 10})
|
|
||||||
# @events_count = events.count
|
|
||||||
# @events_pages = Paginator.new @events_count, @limit, params['page']
|
|
||||||
# @offset ||= @events_pages.offset
|
|
||||||
# events = events.slice(@offset,@limit)
|
|
||||||
events = paginateHelper events,10
|
events = paginateHelper events,10
|
||||||
|
|
||||||
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||||
# documents
|
# documents
|
||||||
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||||
# 这写变量发现没有用而且拖慢速度
|
|
||||||
#@teachers= searchTeacherAndAssistant(@course)
|
|
||||||
#@canShowRealName = isCourseTeacher(User.current.id,@course)
|
|
||||||
|
|
||||||
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
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)
|
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||||
end
|
end
|
||||||
|
@ -951,10 +727,6 @@ class CoursesController < ApplicationController
|
||||||
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
||||||
page = 1 + offset / @limit
|
page = 1 + offset / @limit
|
||||||
end
|
end
|
||||||
|
|
||||||
#@feedback_count = @jours.count
|
|
||||||
#@feedback_pages = Paginator.new @feedback_count, @limit, page
|
|
||||||
#@offset ||= @feedback_pages.offset
|
|
||||||
@jour = paginateHelper @jours,10
|
@jour = paginateHelper @jours,10
|
||||||
@state = false
|
@state = false
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -994,7 +766,6 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def allow_join course
|
def allow_join course
|
||||||
if course_endTime_timeout? course
|
if course_endTime_timeout? course
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
Loading…
Reference in New Issue