修正课程显示老师、学生人数与课程中老师、学生数量不一致问题
修正学校主页课程推荐中显示的课程人数与课程总人数不一致问题
This commit is contained in:
parent
c78047ae98
commit
ff02c4f9f2
|
@ -98,11 +98,11 @@ module CoursesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
alias teacherCountOrigin teacherCount
|
#alias teacherCountOrigin teacherCount
|
||||||
def teacherCount project
|
#def teacherCount project
|
||||||
count = teacherCountOrigin project
|
# count = teacherCountOrigin project
|
||||||
garble count
|
# garble count
|
||||||
end
|
#end
|
||||||
|
|
||||||
# 注意:此方法有问题,速度慢且结果不准
|
# 注意:此方法有问题,速度慢且结果不准
|
||||||
# alias studentCountOrigin studentCount
|
# alias studentCountOrigin studentCount
|
||||||
|
@ -114,7 +114,20 @@ module CoursesHelper
|
||||||
# 学生人数计算
|
# 学生人数计算
|
||||||
# add by nwb
|
# add by nwb
|
||||||
def studentCount course
|
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
|
||||||
|
result = "5+"
|
||||||
|
else
|
||||||
|
result = (count-count % 10).to_s + "+"
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
#课程成员数计算
|
||||||
|
def memberCount course
|
||||||
|
count = searchStudent(course).count + searchTeacherAndAssistant(course).count
|
||||||
if count <= 5
|
if count <= 5
|
||||||
result = count.to_s
|
result = count.to_s
|
||||||
elsif count < 10 && count > 5
|
elsif count < 10 && count > 5
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
<div class='desc_item text_nowrap'>
|
<div class='desc_item text_nowrap'>
|
||||||
[<%= get_course_term course %>]
|
[<%= 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}") %>
|
<%= 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 %>
|
<% files_count = course.attachments.count.to_s %>
|
||||||
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
|
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
|
||||||
</div>
|
</div>
|
||||||
|
@ -164,7 +164,7 @@
|
||||||
<div class='desc_item text_nowrap'>
|
<div class='desc_item text_nowrap'>
|
||||||
[<%= get_course_term course %>]
|
[<%= 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}") %>
|
<%= 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 %>
|
<% files_count = course.attachments.count.to_s %>
|
||||||
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
|
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
|
||||||
</div>
|
</div>
|
||||||
|
@ -209,7 +209,7 @@
|
||||||
<div class='desc_item text_nowrap'>
|
<div class='desc_item text_nowrap'>
|
||||||
[<%= get_course_term course %>]
|
[<%= 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}") %>
|
<%= 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 %>
|
<% files_count = course.attachments.count.to_i.to_s %>
|
||||||
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
|
(<%= link_to "#{files_count}份", course_files_path(course) %>资料)
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue