|
|
|
@ -52,37 +52,19 @@ class CoursesController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def allow_join
|
|
|
|
|
if course_endTime_timeout? Project.find(params[:object_id])
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js{
|
|
|
|
|
@state = 2
|
|
|
|
|
render :partial => 'set_join',
|
|
|
|
|
:locals => {:user => User.current,
|
|
|
|
|
:course => Project.find(params[:object_id]),
|
|
|
|
|
:object_id => params[:object_id]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
@course_type = params[:course_type]
|
|
|
|
|
@school_id = params[:school_id]
|
|
|
|
|
per_page_option = 10
|
|
|
|
|
if @school_id == "0" or @school_id.nil?
|
|
|
|
|
@courses_all = Project.active.visible.
|
|
|
|
|
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id").
|
|
|
|
|
where("#{Project.table_name}.course_type = ? ", Project::ProjectType_course)
|
|
|
|
|
@courses_all = Course.active.visible.
|
|
|
|
|
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id")
|
|
|
|
|
else
|
|
|
|
|
@courses_all = Project.active.visible.
|
|
|
|
|
joins("LEFT JOIN #{ProjectStatus.table_name} ON #{Project.table_name}.id = #{ProjectStatus.table_name}.course_id").
|
|
|
|
|
@courses_all = Course.active.visible.
|
|
|
|
|
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
|
|
|
|
|
joins(:course_extra).
|
|
|
|
|
where("#{Project.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Project::ProjectType_course, @school_id)
|
|
|
|
|
where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@course_count = @courses_all.count
|
|
|
|
@ -153,18 +135,72 @@ class CoursesController < ApplicationController
|
|
|
|
|
format.html {
|
|
|
|
|
render :layout => 'base'
|
|
|
|
|
}
|
|
|
|
|
format.api {
|
|
|
|
|
# @offset, @limit = api_offset_and_limit
|
|
|
|
|
# @course_count = Project.visible.count
|
|
|
|
|
# @courses = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
|
}
|
|
|
|
|
format.atom {
|
|
|
|
|
courses = Project.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
|
|
|
|
|
render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}")
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def get_course_activity courses,activities
|
|
|
|
|
@course_ids=activities.keys()
|
|
|
|
|
|
|
|
|
|
days = Setting.activity_days_default.to_i
|
|
|
|
|
date_to ||= Date.today + 1
|
|
|
|
|
date_from = date_to - days-1.years
|
|
|
|
|
|
|
|
|
|
#file_count
|
|
|
|
|
Attachment.where(container_id: @course_ids, container_type: Project).where("created_on>?",date_from).each do |attachment|
|
|
|
|
|
activities[attachment.container_id]+=1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#message_count
|
|
|
|
|
Board.where(course_id: @course_ids).each do |board|
|
|
|
|
|
# activities[board.course_id]+=1
|
|
|
|
|
activities[board.course_id]+=board.messages.where("updated_on>?",date_from).count
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#time_entry_count
|
|
|
|
|
TimeEntry.where(course_id: @course_ids).where("updated_on>?",date_from).each do |timeentry|
|
|
|
|
|
activities[timeentry.course_id]+=1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#feedbackc_count
|
|
|
|
|
JournalsForMessage.where(jour_id: @course_ids, jour_type: Project).each do |jourformess|
|
|
|
|
|
activities[jourformess.jour_id]+=1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#activities!=0
|
|
|
|
|
i=0;
|
|
|
|
|
courses.each do |course|
|
|
|
|
|
id=course.id
|
|
|
|
|
if activities[id]==0
|
|
|
|
|
activities[id]=1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return activities
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def allow_join
|
|
|
|
|
if course_endTime_timeout? Project.find(params[:object_id])
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js{
|
|
|
|
|
@state = 2
|
|
|
|
|
render :partial => 'set_join',
|
|
|
|
|
:locals => {:user => User.current,
|
|
|
|
|
:course => Project.find(params[:object_id]),
|
|
|
|
|
:object_id => params[:object_id]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def index1
|
|
|
|
|
|
|
|
|
|