修改课程资源模块相关问题

This commit is contained in:
z9hang 2014-11-22 13:45:17 +08:00
parent e2892453de
commit 436cf1175f
8 changed files with 62 additions and 23 deletions

View File

@ -366,7 +366,7 @@ class AttachmentsController < ApplicationController
end
rescue NoMethodError
@save_flag = false
@save_message = [] << l(:error_attachment_empty)
@save_message = [] << l(:label_course_empty_select)
respond_to do |format|
format.js
end

View File

@ -26,13 +26,15 @@ class FilesController < ApplicationController
helper :sort
include SortHelper
include FilesHelper
helper :project_score
def show_attachments obj
@all_attachments = []
@attachments = []
obj.each do |container|
@all_attachments += container.attachments
@attachments += container.attachments
end
@all_attachments = visable_attachemnts(@attachments)
@limit = 10
@feedback_count = @all_attachments.count
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
@ -48,9 +50,11 @@ class FilesController < ApplicationController
#(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
if params[:insite]
@result = find_public_attache q
@result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
else
@result = find_course_attache q,@course
@result = visable_attachemnts @result
@searched_attach = paginateHelper @result,10
end
@ -69,7 +73,7 @@ class FilesController < ApplicationController
# StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map
# 此时内容不多速度还可但文件增长每条判断多则进行3-4次表连接。
# 现在还木有思路 药丸
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND (is_public = 1 OR author_id = #{User.current.id}) AND filename LIKE :like ", like: "%#{keywords}%").
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%").
reorder("created_on DESC")
end

View File

@ -72,6 +72,16 @@ module FilesHelper
result
end
def visable_attachemnts attachments
result = []
attachments.each do |attachment|
if attachment.is_public? || attachment.author_id == User.current.id
result << attachment
end
end
result
end
def get_qute_number attachment
if attachment.copy_from.nil?
return 0

View File

@ -1,6 +1,6 @@
<% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
<div class="re_con_top">
<p class="f_l c_blue f_b f_14">共有&nbsp;<%= User.current.member_of_course?(course) ? all_attachments.count : 0 %>&nbsp;个资源</p>
<p class="f_l c_blue f_b f_14">共有&nbsp;<%= all_attachments.count%>&nbsp;个资源</p>
<p class="f_r" style="color: #808080">
<!--<#% if @order == "asc" %>
按&nbsp;<#%= link_to "时间",course_files_path(course,:sort=>"created_on:desc"),:class => "f_b c_grey" %><#%= render partial: 'arrow_show',locals: { sort: sort,order:order,current:"created_on"} %>&nbsp;/&nbsp;
@ -16,24 +16,24 @@
</div>
<div class="cl"></div>
<% curse_attachments.each do |file| %>
<%if file.is_public == 0 && !User.current.member_of_course?(@course)%>
<%next%>
<%end%>
<div class="re_con_box">
<div class=" ">
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if is_course_teacher(User.current,@course) %>
<%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
<% if User.current.logged? %>
<% if is_course_teacher(User.current,@course) && file.author_id == User.current.id %>
<%= link_to "选入我的其他课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
<% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %>
<span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %>
</span>
<% else %>
<%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %>
<!-- <#%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> -->
<% end %>
<% else %>
<%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
<% end %>
<% else %>
<%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %>
<% end %>
</div>
<div class="cl"></div>
@ -41,7 +41,7 @@
<p class="f_l c_grey02 font">文件大小:<%= number_to_human_size(file.filesize) %></p>
<%= link_to( l(:button_delete), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;|&nbsp;&nbsp;引用<%=get_qute_number file %> </p>
<p class="f_r c_grey02" ><%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>&nbsp;&nbsp;|&nbsp;&nbsp;下载<%= file.downloads %>&nbsp;&nbsp;<!--|&nbsp;&nbsp;引用<%#=get_qute_number file %>--> </p>
</div>
<div class="cl"></div>
<div class="tag_h">

View File

@ -14,7 +14,7 @@
</span>
<% end %>
<% else %>
<span style="color:#8c8a8a" class="f_l">
&nbsp;&nbsp;&nbsp;<%= l(:label_tags_no) %>
<!-- <span style="color:#8c8a8a" class="f_l">
&nbsp;&nbsp;&nbsp;<#%= l(:label_tags_no) %> -->
</span>
<% end %>

View File

@ -1852,3 +1852,4 @@ en:
label_anonymous_comments: Anonymous comments
label_anonymous: Anonymous
label_submit_comments: Submit_comments
label_course_empty_select: You have not selected course

View File

@ -2204,3 +2204,4 @@ zh:
field_evaluation_num: 匿评分配数量
label_my_score: 我的评分
field_open_anonymous_evaluation: 是否开启匿评
label_course_empty_select: 尚未选择课程!

View File

@ -1,4 +1,4 @@
body{ font-size:12px; font-family:"微软雅黑","宋体"; line-height:1.9; background:#fff; font-style:normal;}
body{ font-size:12px !important; font-family:"微软雅黑","宋体" !important; line-height:1.9 !important; background:#fff !important; font-style:normal !important;}
div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,form,span,textarea{ margin:0; padding:0;}
div,img,tr,td,textarea{ border:0;}
table,tr,td{border:0; cellspacing:0; cellpadding:0;}
@ -52,10 +52,33 @@ a:hover.re_fabu{background:#55a1b9 !important;}
.re_con{ margin:5px; width:683px;}
.re_con_top{color:#494949; }
.re_con_top span{ color:#999999; font-weight:bold;}
a.re_select{ display:block; width:88px; height:22px; background:url(images/pic_select01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;}
a:hover.re_select{background:url(images/pic_select02.png) 0 0 no-repeat;}
.re_open{display:block; width:46px; height:22px; background:url(images/pic_open01.png) 0 0 no-repeat; color:#fff !important; font-weight:bold; margin-left:10px;}
a:hover.re_open{background:url(images/pic_open02.png) 0 0 no-repeat;}
a.re_select{
display: block;
height: 22px;
border: 1px solid #ff9900;
color: #ff9900;
margin-left: 10px;
padding-left: 10px;
padding-right: 10px;
}
a:hover.re_select{
background: #ff9900;
color: #fff;
text-decoration: none;}
.re_open{
display: block !important;
width: 46px !important;
height: 22px !important;
border: 1px solid #64bdd9 !important;
color: #64bdd9 !important;
margin-left: 10px !important;
}
a:hover.re_open
{
background: #64bdd9;
color: #fff !important;
text-decoration: none !important;
}
a.re_de{ color:#6883b6; margin-left:15px;}
.re_con_box{ border-bottom:1px dashed #dadada; padding:10px 0;}
/****翻页***/