From 76ec0d5d4828516ccd18187c8b4a8cde502d019b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 28 Aug 2015 16:47:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=B0=E4=BD=9C=E4=B8=9A=E9=9D=99=E6=80=81?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 12 ++++++++- app/views/users/_show_user_resource.html.erb | 26 +++++++++++++++++++ .../users/_user_homework_attachment.html.erb | 2 +- app/views/users/user_import_homeworks.js.erb | 2 +- app/views/users/user_import_resource.js.erb | 7 +++++ config/routes.rb | 1 + 6 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 app/views/users/_show_user_resource.html.erb create mode 100644 app/views/users/user_import_resource.js.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 544ed7bf5..e98220d26 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -46,7 +46,7 @@ class UsersController < ApplicationController :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource, :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, - :user_import_homeworks,:user_search_homeworks] + :user_import_homeworks,:user_search_homeworks,:user_import_resource] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -378,6 +378,16 @@ class UsersController < ApplicationController end end + #用户从资源库导入资源到作业 + def user_import_resource + user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") + respond_to do |format| + format.js + end + end + include CoursesHelper def user_courses diff --git a/app/views/users/_show_user_resource.html.erb b/app/views/users/_show_user_resource.html.erb new file mode 100644 index 000000000..a27a51d65 --- /dev/null +++ b/app/views/users/_show_user_resource.html.erb @@ -0,0 +1,26 @@ +