课程应用的功能实现
This commit is contained in:
parent
63b91e2cfb
commit
f2da5704ef
|
@ -343,6 +343,35 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add_exist_file_to_courses
|
||||||
|
file = Attachment.find(params[:file_id])
|
||||||
|
courses = params[:courses][:course]
|
||||||
|
courses.each do |course|
|
||||||
|
c = Course.find(course);
|
||||||
|
attach_copied_obj = file.copy
|
||||||
|
attach_copied_obj.tag_list.add(file.tag_list) # tag关联
|
||||||
|
attach_copied_obj.container = c
|
||||||
|
attach_copied_obj.created_on = Time.now
|
||||||
|
attach_copied_obj.author_id = User.current.id
|
||||||
|
attach_copied_obj.copy_from = file.copy_from.nil? ? file.id:file.copy_from
|
||||||
|
if attach_copied_obj.attachtype == nil
|
||||||
|
attach_copied_obj.attachtype = 4
|
||||||
|
end
|
||||||
|
@obj = c
|
||||||
|
@save_flag = attach_copied_obj.save
|
||||||
|
@save_message = attach_copied_obj.errors.full_messages
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
rescue NoMethodError
|
||||||
|
@save_flag = false
|
||||||
|
@save_message = [] << l(:error_attachment_empty)
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def find_project
|
def find_project
|
||||||
@attachment = Attachment.find(params[:id])
|
@attachment = Attachment.find(params[:id])
|
||||||
|
|
|
@ -22,7 +22,7 @@ class FilesController < ApplicationController
|
||||||
menu_item :files
|
menu_item :files
|
||||||
|
|
||||||
before_filter :find_project_by_project_id#, :except => [:getattachtype]
|
before_filter :find_project_by_project_id#, :except => [:getattachtype]
|
||||||
before_filter :authorize, :except => [:getattachtype]
|
before_filter :authorize, :except => [:getattachtype,:quote_resource_show]
|
||||||
|
|
||||||
helper :sort
|
helper :sort
|
||||||
include SortHelper
|
include SortHelper
|
||||||
|
@ -74,8 +74,7 @@ class FilesController < ApplicationController
|
||||||
when "created_on"
|
when "created_on"
|
||||||
attribute = "created_on"
|
attribute = "created_on"
|
||||||
end
|
end
|
||||||
@sort = order_by[0]
|
|
||||||
@order = order_by[1]
|
|
||||||
if order_by.count == 1
|
if order_by.count == 1
|
||||||
sort += "#{Attachment.table_name}.#{attribute} asc "
|
sort += "#{Attachment.table_name}.#{attribute} asc "
|
||||||
elsif order_by.count == 2
|
elsif order_by.count == 2
|
||||||
|
@ -116,7 +115,8 @@ class FilesController < ApplicationController
|
||||||
when "created_on"
|
when "created_on"
|
||||||
attribute = "created_on"
|
attribute = "created_on"
|
||||||
end
|
end
|
||||||
|
@sort = order_by[0]
|
||||||
|
@order = order_by[1]
|
||||||
if order_by.count == 1
|
if order_by.count == 1
|
||||||
sort += "#{Attachment.table_name}.#{attribute} asc "
|
sort += "#{Attachment.table_name}.#{attribute} asc "
|
||||||
elsif order_by.count == 2
|
elsif order_by.count == 2
|
||||||
|
@ -137,8 +137,8 @@ class FilesController < ApplicationController
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_file_show
|
def quote_resource_show
|
||||||
|
@file = Attachment.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -177,6 +177,8 @@ module AttachmentsHelper
|
||||||
s.html_safe
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Modified by Longjun
|
# Modified by Longjun
|
||||||
# 有参数的方法要加()
|
# 有参数的方法要加()
|
||||||
def private_filter(resultSet)
|
def private_filter(resultSet)
|
||||||
|
|
|
@ -44,6 +44,16 @@ module FilesHelper
|
||||||
File.new(zipfile_name,'w+')
|
File.new(zipfile_name,'w+')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def courses_check_box_tags(name,courses,current_course)
|
||||||
|
s = ''
|
||||||
|
courses.each do |course|
|
||||||
|
if course.id != current_course.id && is_course_teacher(User.current,course)
|
||||||
|
s << "<label>#{ check_box_tag name, course.id, false, :id => nil } #{h course.name}</label><br/>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
s.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
# 判断指定的资源时候符合类型
|
# 判断指定的资源时候符合类型
|
||||||
def isTypeOk(attachment, type, contentType)
|
def isTypeOk(attachment, type, contentType)
|
||||||
result = false
|
result = false
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<% if !@save_flag%>
|
||||||
|
$("#error_show").html("<%= @save_message.join(', ') %>");
|
||||||
|
<% else %>
|
||||||
|
closeModal();
|
||||||
|
<% end %>
|
|
@ -1,8 +1,10 @@
|
||||||
<!-- sort: @sort,order:@order,current:"created_on" -->
|
<!-- sort: @sort,order:@order,current:"created_on" -->
|
||||||
<% if sort == current %>
|
<% if sort == current %>
|
||||||
<% if order = "" || order =="asc" %>
|
<% if order =="asc" %>
|
||||||
↑
|
↑
|
||||||
|
<% elsif order == "desc" %>
|
||||||
|
↓
|
||||||
<% else %>
|
<% else %>
|
||||||
↓
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
|
@ -1,17 +1,18 @@
|
||||||
<% attachmenttypes = @course.attachmenttypes %>
|
<% attachmenttypes = @course.attachmenttypes %>
|
||||||
<% sufixtypes = @course.contenttypes %>
|
<% sufixtypes = @course.contenttypes %>
|
||||||
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
|
||||||
<%= stylesheet_link_tag 'resource', :media => 'all' %>
|
<%= stylesheet_link_tag 'resource', :media => 'all' %>
|
||||||
<script>
|
<script>
|
||||||
function show_upload()
|
function show_upload()
|
||||||
{
|
{
|
||||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show',:locals => {:course => @course}) %>');
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'upload_show',:locals => {:course => @course}) %>');
|
||||||
showModal('ajax-modal', '513px');
|
showModal('ajax-modal', '513px');
|
||||||
// $('#ajax-modal').css('height','569px');
|
|
||||||
$('#ajax-modal').siblings().remove();
|
$('#ajax-modal').siblings().remove();
|
||||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||||
$('#ajax-modal').parent().css("top","5").css("left","511");
|
$('#ajax-modal').parent().css("top","5").css("left","511");
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeModal()
|
function closeModal()
|
||||||
{
|
{
|
||||||
hideModal($("#popbox_upload"));
|
hideModal($("#popbox_upload"));
|
||||||
|
@ -27,14 +28,25 @@
|
||||||
<input type="submit" value="课内搜索" class="re_schbtn b_dblue" />
|
<input type="submit" value="课内搜索" class="re_schbtn b_dblue" />
|
||||||
<input type="submit" value="全站搜索" class="re_schbtn b_lblue" />
|
<input type="submit" value="全站搜索" class="re_schbtn b_lblue" />
|
||||||
</form>
|
</form>
|
||||||
<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload()">上传资源</a>
|
<% if is_course_teacher(User.current,@course) %>
|
||||||
|
<a href="javascript:void(0)" class="re_fabu f_r b_lblue" onclick="show_upload()">上传资源</a>
|
||||||
|
<% end %>
|
||||||
</div><!---re_top end-->
|
</div><!---re_top end-->
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
|
|
||||||
<div class="re_con">
|
<div class="re_con">
|
||||||
<div class="re_con_top">
|
<div class="re_con_top">
|
||||||
<p class="f_l c_blue f_b f_14">共有 <%= User.current.member_of_course?(@course) ? @all_attachments.count : 0 %> 个资源</p>
|
<p class="f_l c_blue f_b f_14">共有 <%= User.current.member_of_course?(@course) ? @all_attachments.count : 0 %> 个资源</p>
|
||||||
<p class="f_r">按 <%= link_to "时间",course_files_path(@course,:sort=>"created_on"),:class => "f_b c_grey" %><%= render partial: 'arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> / <%= link_to "下载次数",course_files_path(@course,:sort=>"downloads:desc"),:class => "f_b c_grey" %><%= render partial: 'arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> / <a href="#" class="f_b c_grey">引用次数</a> 排序</p>
|
<p class="f_r">
|
||||||
|
<% if @order == "asc" %>
|
||||||
|
按 <%= 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"} %> /
|
||||||
|
<%= link_to "下载次数",course_files_path(@course,:sort=>"downloads:desc"),:class => "f_b c_grey" %><%= render partial: 'arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
|
||||||
|
<a href="#" class="f_b c_grey">引用次数</a> 排序</p>
|
||||||
|
<%else%>
|
||||||
|
按 <%= link_to "时间",course_files_path(@course,:sort=>"created_on:asc"),:class => "f_b c_grey" %><%= render partial: 'arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
|
||||||
|
<%= link_to "下载次数",course_files_path(@course,:sort=>"downloads:asc"),:class => "f_b c_grey" %><%= render partial: 'arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
|
||||||
|
<a href="#" class="f_b c_grey">引用次数</a> 排序</p>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<% @curse_attachments.each do |file| %>
|
<% @curse_attachments.each do |file| %>
|
||||||
|
@ -44,10 +56,14 @@
|
||||||
<div class="re_con_box">
|
<div class="re_con_box">
|
||||||
<div class=" ">
|
<div class=" ">
|
||||||
<%= link_to_attachment file, :download => true, :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" %>
|
<%= link_to_attachment file, :download => true, :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" %>
|
||||||
<a href="#" class="f_l re_select">选入我的课程</a>
|
<% if is_course_teacher(User.current,@course) %>
|
||||||
<span id="is_public_<%= file.id %>">
|
<%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %>
|
||||||
<%= 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 id="is_public_<%= file.id %>">
|
||||||
</span>
|
<%= 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" %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div class="cl"></div>
|
<div class="cl"></div>
|
||||||
<div class="">
|
<div class="">
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<div id="popbox_upload" style="margin-top: -30px;margin-left: -20px;margin-right: -10px;">
|
||||||
|
<div class="upload_con">
|
||||||
|
<div id="error_show"></div>
|
||||||
|
<h2>将此课件引入我的课程资源库</h2>
|
||||||
|
<div class="upload_box">
|
||||||
|
<%= form_tag course_attach_relations_path,
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
id: "relation_file_form" do %>
|
||||||
|
<%= hidden_field_tag(:file_id, file.id) %>
|
||||||
|
<%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course), :id => 'courses')%>
|
||||||
|
<a id="submit_quote" href="javascript:void(0)" class="upload_btn" onclick="submit_quote();">引 用</a><a href="javascript:void(0)" class="upload_btn upload_btn_grey" onclick="closeModal();">取 消</a>
|
||||||
|
<% end -%>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function submit_quote()
|
||||||
|
{
|
||||||
|
$('#submit_quote').parent().submit();
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,5 @@
|
||||||
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'show_quote_resource',:locals => {:course => @course,:file => @file}) %>');
|
||||||
|
showModal('ajax-modal', '513px');
|
||||||
|
$('#ajax-modal').siblings().remove();
|
||||||
|
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'><a href='javascript:void(0)' onclick='closeModal()'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||||
|
$('#ajax-modal').parent().css("top","5").css("left","511");
|
|
@ -558,6 +558,7 @@ RedmineApp::Application.routes.draw do
|
||||||
match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post]
|
match 'attachments/autocomplete', :to => 'attachments#autocomplete', :via => [:post]
|
||||||
post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation'
|
post 'attachments/relationfile', to: 'attachments#add_exist_file_to_project', as: 'attach_relation'
|
||||||
post 'attachments/courserelationfile', to: 'attachments#add_exist_file_to_course', as: 'course_attach_relation'
|
post 'attachments/courserelationfile', to: 'attachments#add_exist_file_to_course', as: 'course_attach_relation'
|
||||||
|
post 'attachments/courserelationfiles', to: 'attachments#add_exist_file_to_courses', as: 'course_attach_relations'
|
||||||
get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/
|
get 'attachments/renderTag/:attchmentId', :to => 'attachments#renderTag', :attchmentId => /\d+/
|
||||||
resources :attachments, :only => [:show, :destroy] do
|
resources :attachments, :only => [:show, :destroy] do
|
||||||
collection do
|
collection do
|
||||||
|
@ -654,6 +655,9 @@ RedmineApp::Application.routes.draw do
|
||||||
collection do
|
collection do
|
||||||
match "getattachtype", :via => [:get, :post]
|
match "getattachtype", :via => [:get, :post]
|
||||||
end
|
end
|
||||||
|
member do
|
||||||
|
match "quote_resource_show", :via => [:get]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
|
resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
|
||||||
collection do
|
collection do
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20141105012624) do
|
ActiveRecord::Schema.define(:version => 20141120091234) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -52,6 +52,7 @@ ActiveRecord::Schema.define(:version => 20141105012624) do
|
||||||
t.string "disk_directory"
|
t.string "disk_directory"
|
||||||
t.integer "attachtype", :default => 1
|
t.integer "attachtype", :default => 1
|
||||||
t.integer "is_public", :default => 1
|
t.integer "is_public", :default => 1
|
||||||
|
t.integer "copy_from"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
|
add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id"
|
||||||
|
|
Loading…
Reference in New Issue