班级资源库共享课程资源,但是搜索没有同步

This commit is contained in:
cxt 2017-06-08 15:42:14 +08:00
parent 28c5e9dfcc
commit 11b06012e2
3 changed files with 6 additions and 41 deletions

View File

@ -226,10 +226,11 @@ class FilesController < ApplicationController
if sort == ""
sort = "created_on DESC"
end
course_ids = "(" + course.syllabus.courses.map(&:id).join(",") + ")"
if keywords != "%%"
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id in #{course_ids} AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
else
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id in #{course_ids} "). reorder(sort)
end
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
end

View File

@ -3068,8 +3068,8 @@ module ApplicationHelper
#获取课程资源的TAG云
def get_course_tag_list course
all_attachments = course.attachments.select{|attachment| attachment.is_public? ||
(attachment.container_type == "Course" && User.current.member_of_course?(course))||
all_attachments = Attachment.where(:container_type => 'Course', :container_id => course.syllabus.courses.map(&:id)).select{|attachment| attachment.is_public? ||
(attachment.container_type == "Course" && syllabus_course_member(User.current, Course.find(attachment.container_id)))||
attachment.author_id == User.current.id
}
tag_list = attachment_tag_list all_attachments

View File

@ -73,43 +73,7 @@
%>
</li>
</div>
<div style="display: none" class="message_title_red system_message_style">
<% if User.current.allowed_to?(:as_teacher,ma.course_message.course) %>
<p>
<%= User.current.lastname + User.current.firstname %>老师您好!
<%= User.current.eql?(ma.course_message.user)?"您":(ma.course_message.user.show_name + "老师")%>刚刚发布了一个作业:
</p>
<ul class="ul_normal_color">
<li>班级名称:<%= ma.course_message.course.name %>
(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)</li>
<li>作业标题:<span style="color:Red"><%= ma.course_message.name %></span></li>
<li>发布时间:<span style="color:Red;"><%= DateTime.parse(ma.course_message.created_at.to_s).strftime('%Y-%m-%d %H:%M').to_s %></span></li>
<li>提交截止:<span style="color:Red;"><%= ma.course_message.end_time %>&nbsp;23:59</span></li>
<li>匿评开始:<span style="color:Red;"><%= ma.course_message.homework_detail_manual.evaluation_start %>&nbsp;23:59</span></li>
<li>匿评关闭:<span style="color:Red;"><%= ma.course_message.homework_detail_manual.evaluation_end %>&nbsp;23:59</span></li>
<li>迟交扣分:<span style="color:Red;"><%= ma.course_message.late_penalty %>分</span></li>
<li>缺评扣分:<span style="color:Red;"><%= ma.course_message.homework_detail_manual.absence_penalty %>分</span></li>
</ul>
<p>
您可以修改作业内容、评分规则、匿评过程等,谢谢!
</p>
<% else %>
<p><%= User.current.lastname + User.current.firstname %>同学您好!<%= ma.course_message.user.lastname + ma.course_message.user.firstname %>老师刚刚发布了一个作业:</p>
<ul class="ul_normal_color">
<li>班级名称:<%= ma.course_message.course.name %>
(<%= ma.course_message.course.time.to_s + '年'+ ma.course_message.course.term %>)</li>
<li>作业标题:<span style="color:Red;"><%= ma.course_message.name %></span></li>
<li>提交截止:<span style="color:Red;"><%= ma.course_message.end_time %>&nbsp;&nbsp;23:59</span></li>
<li>匿评开始:<span style="color:Red;"><%= ma.course_message.homework_detail_manual.evaluation_start %>&nbsp;&nbsp;23:59</span></li>
<li>匿评关闭:<span style="color:Red;"><%= ma.course_message.homework_detail_manual.evaluation_end %>&nbsp;&nbsp;23:59</span></li>
<li>迟交扣分:<span style="color:Red;"><%= ma.course_message.late_penalty %>分</span></li>
<li>缺评扣分:<span style="color:Red;"><%= ma.course_message.homework_detail_manual.absence_penalty %>分</span></li>
</ul>
<p>
请抓紧时间提交您的作品,谢谢!
</p>
<% end %>
</div>
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>