修正课程显示老师、学生人数与课程中老师、学生数量不一致问题

修正学校主页课程推荐中显示的课程人数与课程总人数不一致问题
This commit is contained in:
z9hang 2014-08-01 17:43:06 +08:00
parent c78047ae98
commit ff02c4f9f2
2 changed files with 22 additions and 9 deletions

View File

@ -98,11 +98,11 @@ module CoursesHelper
end
alias teacherCountOrigin teacherCount
def teacherCount project
count = teacherCountOrigin project
garble count
end
#alias teacherCountOrigin teacherCount
#def teacherCount project
# count = teacherCountOrigin project
# garble count
#end
# 注意:此方法有问题,速度慢且结果不准
# alias studentCountOrigin studentCount
@ -114,7 +114,7 @@ module CoursesHelper
# 学生人数计算
# add by nwb
def studentCount course
count = course.student.count
count = searchStudent(course).count#course.student.count
if count <= 5
result = count.to_s
elsif count < 10 && count > 5
@ -125,6 +125,19 @@ module CoursesHelper
result
end
#课程成员数计算
def memberCount course
count = searchStudent(course).count + searchTeacherAndAssistant(course).count
if count <= 5
result = count.to_s
elsif count < 10 && count > 5
result = "5+"
else
result = (count-count % 10).to_s + "+"
end
result
end
def eventToLanguageCourse event_type, course
case event_type
when "issue-note"

View File

@ -123,7 +123,7 @@
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{studentCount(course)}人" %>)
(<%= "#{memberCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
@ -164,7 +164,7 @@
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{studentCount(course)}人" %>)
(<%= "#{memberCount(course)}人" %>)
<% files_count = course.attachments.count.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>
@ -209,7 +209,7 @@
<div class='desc_item text_nowrap'>
[<%= get_course_term course %>]
<%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %>
(<%= "#{studentCount(course)}人" %> )
(<%= "#{memberCount(course)}人" %> )
<% files_count = course.attachments.count.to_i.to_s %>
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
</div>