|
|
|
@ -47,18 +47,18 @@ 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)
|
|
|
|
|
s << "<label>#{ check_box_tag name, course.id, false, :id => nil } #{h course.name}</label><br/>"
|
|
|
|
|
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> [#{get_course_term course}]<br/>"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
s.html_safe
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#判断用户是否拥有课程,需用户在该课程中角色为教师
|
|
|
|
|
#判断用户是否拥有课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期
|
|
|
|
|
def has_course? user
|
|
|
|
|
result = false
|
|
|
|
|
user.courses.each do |course|
|
|
|
|
|
if is_course_teacher(user,course)
|
|
|
|
|
if is_course_teacher(User.current,course) && course_in_current_or_next_term(course)
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -86,7 +86,7 @@ module FilesHelper
|
|
|
|
|
def visable_attachemnts attachments
|
|
|
|
|
result = []
|
|
|
|
|
attachments.each do |attachment|
|
|
|
|
|
if attachment.is_public? || attachment.author_id == User.current.id
|
|
|
|
|
if attachment.is_public? || (attachment.container_type == "Course" && attachment.author.member_of_course?(Course.find(attachment.container_id)))|| attachment.author_id == User.current.id
|
|
|
|
|
result << attachment
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -94,9 +94,15 @@ module FilesHelper
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def get_qute_number attachment
|
|
|
|
|
if attachment.copy_from.nil?
|
|
|
|
|
if attachment.copy_from
|
|
|
|
|
result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.copy_from}")
|
|
|
|
|
else
|
|
|
|
|
result = Attachment.find_by_sql("select count(*) as number from attachments where copy_from = #{attachment.id}")
|
|
|
|
|
end
|
|
|
|
|
if result.nil? || result.count <= 0
|
|
|
|
|
return 0
|
|
|
|
|
else
|
|
|
|
|
return result[0].number
|
|
|
|
|
end
|
|
|
|
|
count = Attachment.find_by_sql("select count(*) from attachments where copy_from = #{attachment.copy_from}")
|
|
|
|
|
end
|
|
|
|
|
end
|