|
|
@ -44,9 +44,9 @@ module CoursesHelper
|
|
|
|
def visible_excellent_course obj
|
|
|
|
def visible_excellent_course obj
|
|
|
|
# if course.is_pu
|
|
|
|
# if course.is_pu
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 返回x项目成员数量,即roles表中定义的所有成员
|
|
|
|
# 返回x项目成员数量,即roles表中定义的所有成员
|
|
|
|
def projectCount project
|
|
|
|
def projectCount project
|
|
|
|
#searchCountByRoles project, AllPeople
|
|
|
|
#searchCountByRoles project, AllPeople
|
|
|
|
project.members.count
|
|
|
|
project.members.count
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -147,10 +147,10 @@ module CoursesHelper
|
|
|
|
|
|
|
|
|
|
|
|
# 返回学生数量,即roles表中定义的Reporter
|
|
|
|
# 返回学生数量,即roles表中定义的Reporter
|
|
|
|
#def studentCount project
|
|
|
|
#def studentCount project
|
|
|
|
# searchStudent(project).count
|
|
|
|
# searchStudent(project).count
|
|
|
|
# or
|
|
|
|
# or
|
|
|
|
# searchStudent(project).count
|
|
|
|
# searchStudent(project).count
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
# 判断用户是否是课程的管理员
|
|
|
|
# 判断用户是否是课程的管理员
|
|
|
|
# add by nwb
|
|
|
|
# add by nwb
|
|
|
@ -225,11 +225,11 @@ module CoursesHelper
|
|
|
|
#end
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
|
|
# 注意:此方法有问题,速度慢且结果不准
|
|
|
|
# 注意:此方法有问题,速度慢且结果不准
|
|
|
|
# alias studentCountOrigin studentCount
|
|
|
|
# alias studentCountOrigin studentCount
|
|
|
|
#def studentCount course
|
|
|
|
#def studentCount course
|
|
|
|
# count = studentCountOrigin course
|
|
|
|
# count = studentCountOrigin course
|
|
|
|
#garble count
|
|
|
|
#garble count
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
#获取课程所有成员
|
|
|
|
#获取课程所有成员
|
|
|
|
def course_all_member course
|
|
|
|
def course_all_member course
|
|
|
@ -265,27 +265,18 @@ module CoursesHelper
|
|
|
|
def garble count
|
|
|
|
def garble count
|
|
|
|
count = count.round( 1-count.to_s.size ).to_i
|
|
|
|
count = count.round( 1-count.to_s.size ).to_i
|
|
|
|
return count.to_s if count.to_s.size.eql?(1)
|
|
|
|
return count.to_s if count.to_s.size.eql?(1)
|
|
|
|
count.to_s << '+'
|
|
|
|
count.to_s << '+'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# =====================================================================================
|
|
|
|
# =====================================================================================
|
|
|
|
# return people list
|
|
|
|
# return people list
|
|
|
|
def searchPeopleByName(course, role_name)
|
|
|
|
|
|
|
|
course.members.select{|m|
|
|
|
|
|
|
|
|
m.roles.any?{|r|r.name == role_name}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def searchTeacherAndAssistant project
|
|
|
|
def searchTeacherAndAssistant project
|
|
|
|
searchPeopleByName(project, 'Manager').concat(
|
|
|
|
#searchPeopleByRoles(project, TeacherRoles)
|
|
|
|
searchPeopleByName(project, 'Teacher')
|
|
|
|
members = []
|
|
|
|
).concat(
|
|
|
|
project.members.includes(:user).each do |m|
|
|
|
|
searchPeopleByName(project, 'TeachingAsistant')
|
|
|
|
members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
members
|
|
|
|
|
|
|
|
|
|
|
|
def searchStudent project
|
|
|
|
|
|
|
|
searchPeopleByName(project, 'Student')
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def TeacherAndAssistantCount course
|
|
|
|
def TeacherAndAssistantCount course
|
|
|
@ -302,6 +293,19 @@ module CoursesHelper
|
|
|
|
members
|
|
|
|
members
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def searchStudent project
|
|
|
|
|
|
|
|
#searchPeopleByRoles(project, StudentRoles)
|
|
|
|
|
|
|
|
members = []
|
|
|
|
|
|
|
|
project.members.each do |m|
|
|
|
|
|
|
|
|
if m && m.user && m.user.allowed_to?(:as_student,project)
|
|
|
|
|
|
|
|
members << m
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
members
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def searchStudent_by_name project, name
|
|
|
|
def searchStudent_by_name project, name
|
|
|
|
#searchPeopleByRoles(project, StudentRoles)
|
|
|
|
#searchPeopleByRoles(project, StudentRoles)
|
|
|
|
members = []
|
|
|
|
members = []
|
|
|
@ -320,29 +324,29 @@ module CoursesHelper
|
|
|
|
mems = []
|
|
|
|
mems = []
|
|
|
|
if name != ""
|
|
|
|
if name != ""
|
|
|
|
name = name.to_s.downcase
|
|
|
|
name = name.to_s.downcase
|
|
|
|
members.each do |m|
|
|
|
|
members.each do |m|
|
|
|
|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
|
|
|
|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
|
|
|
|
if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
|
|
|
|
if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
|
|
|
|
mems << m
|
|
|
|
mems << m
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
mems = members
|
|
|
|
mems = members
|
|
|
|
end
|
|
|
|
end
|
|
|
|
mems
|
|
|
|
mems
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def searchgroupmember_by_name members, name, group
|
|
|
|
def searchgroupmember_by_name members, name, group
|
|
|
|
#searchPeopleByRoles(project, StudentRoles)
|
|
|
|
#searchPeopleByRoles(project, StudentRoles)
|
|
|
|
mems = []
|
|
|
|
mems = []
|
|
|
|
if name != ""
|
|
|
|
if name != ""
|
|
|
|
members.each do |m|
|
|
|
|
members.each do |m|
|
|
|
|
if m.course_group_id == group.id
|
|
|
|
if m.course_group_id == group.id
|
|
|
|
username = m.user[:lastname].to_s + m.user[:firstname].to_s
|
|
|
|
username = m.user[:lastname].to_s + m.user[:firstname].to_s
|
|
|
|
if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name))
|
|
|
|
if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name))
|
|
|
|
mems << m
|
|
|
|
mems << m
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
else
|
|
|
|
mems = members
|
|
|
|
mems = members
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -454,7 +458,7 @@ module CoursesHelper
|
|
|
|
content = content_tag('ul', content)
|
|
|
|
content = content_tag('ul', content)
|
|
|
|
content_tag('div', content, :class => "tabs")
|
|
|
|
content_tag('div', content, :class => "tabs")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def findCourseTime project
|
|
|
|
def findCourseTime project
|
|
|
|
str = ""
|
|
|
|
str = ""
|
|
|
|
begin
|
|
|
|
begin
|
|
|
@ -679,9 +683,9 @@ module CoursesHelper
|
|
|
|
#file_count
|
|
|
|
#file_count
|
|
|
|
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
|
|
|
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
|
|
|
if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin?
|
|
|
|
if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin?
|
|
|
|
activities[attachment.container_id]+=1
|
|
|
|
activities[attachment.container_id]+=1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
activities[attachment.container_id]
|
|
|
|
activities[attachment.container_id]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -700,8 +704,8 @@ module CoursesHelper
|
|
|
|
#news
|
|
|
|
#news
|
|
|
|
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
|
|
|
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
|
|
|
if news.author.member_of_course?(@course)
|
|
|
|
if news.author.member_of_course?(@course)
|
|
|
|
activities[news.course_id]+=1
|
|
|
|
activities[news.course_id]+=1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#homework_count
|
|
|
|
#homework_count
|
|
|
|