添加判断课程是否为当前学期或下一学期方法

This commit is contained in:
z9hang 2014-11-26 17:38:46 +08:00
parent f267a3daf8
commit b0db7dfece
2 changed files with 15 additions and 1 deletions

View File

@ -486,6 +486,20 @@ module CoursesHelper
term
end
def course_in_current_or_next_term course
is_current_term = false
is_next_term = false
if course.time == Time.now.year && course.term == cur_course_term
is_current_term = true
end
if cur_course_term == "秋季学期" && course.time == (Time.now.year + 1) && course.term == "春季学期"
is_next_term = true
elsif cur_course_term == "春季学期" && course.time == Time.now.year && course.term == "秋季学期"
is_next_term = true
end
is_current_term || is_next_term
end
#获取课程动态
def get_course_activity courses, activities
@course_ids=activities.keys()

View File

@ -47,7 +47,7 @@ module FilesHelper
def courses_check_box_tags(name,courses,current_course,attachment)
s = ''
courses.each do |course|
if !(attachment.container_type && attachment.container_id == course.id) && is_course_teacher(User.current,course)
if !(attachment.container_type && attachment.container_id == course.id) && is_course_teacher(User.current,course) && course_in_current_or_next_term(course)
s << "<label>#{ check_box_tag name, course.id, false, :id => nil } #{h course.name}</label>&nbsp;[#{get_course_term course}]<br/>"
end
end