diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 66edf761f..555c67d13 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 @@ -379,6 +379,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/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 434e8847f..9c4bde60d 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -57,7 +57,7 @@
-
+

<%= render :partial => 'layouts/user_brief_introduction', :locals => {:user => @user} %>

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 @@ +
+
+
资源库
+
+ +
+
+ + +
+
+ <%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %> +
+ <%= render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks}%> +
+
+
+ 确定 +
+
+ 取消 +
+
+ <% end%> +
+
\ No newline at end of file diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index e184d4132..4f47cd7f2 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -47,7 +47,7 @@
上传附件 - + <%= link_to "资源库", user_import_resource_user_path(User.current.id),:class => "FilesBtn fl mr15 mt3",:remote => true%>
<% content_for :header_tags do %> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 2d4c7eb49..e6cd1483d 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -1,6 +1,6 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
-
+

@@ -38,7 +38,7 @@
发送 - 取消 + 取消
\ No newline at end of file diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 2813f2006..e232579f9 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -11,6 +11,14 @@ } }; $(window).scroll(scrollHandler); + + function reset_homework(){ + $("#homework_name").val(""); + $("#homework_end_time").val(""); + $("#course_id").val(""); + $("#homework_attachments").html("<%= escape_javascript(render :partial => 'users/user_homework_attachment', :locals => { :container => HomeworkCommon.new })%>"); + homework_description_editor.html(""); + } <% if User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)%> @@ -22,7 +30,7 @@
-
+
<% homework = HomeworkCommon.new %> <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
diff --git a/app/views/users/user_import_homeworks.js.erb b/app/views/users/user_import_homeworks.js.erb index 7f9bfa0df..d00886b1c 100644 --- a/app/views/users/user_import_homeworks.js.erb +++ b/app/views/users/user_import_homeworks.js.erb @@ -4,4 +4,4 @@ $('#ajax-modal').css('height','300px').css("width","580px"); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); -$('#ajax-modal').parent().css("top","20%").css("left","25%"); +$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed"); diff --git a/app/views/users/user_import_resource.js.erb b/app/views/users/user_import_resource.js.erb new file mode 100644 index 000000000..ce70d68ad --- /dev/null +++ b/app/views/users/user_import_resource.js.erb @@ -0,0 +1,7 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_homeworks') %>'); +showModal('ajax-modal', '580px'); +$('#ajax-modal').css('height','300px').css("width","580px"); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + +""); +$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed"); \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 634fb6d27..7237787bd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -329,6 +329,7 @@ RedmineApp::Application.routes.draw do match 'user_homeworks', :to => 'users#user_homeworks', :via => :get get 'user_import_homeworks' get 'user_search_homeworks' + get 'user_import_resource' match 'watch_projects', :to => 'users#watch_projects', :via => :get # # added by bai diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 83b17281d..c0492c85b 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -691,7 +691,7 @@ a.referenceTypeBlock {color:#888888; display:inline-block; padding:0px 20px;} /*底部*/ #Footer{background-color:#ffffff; padding-bottom:15px; color:#666666;} /*margin-bottom:10px;*/ .footerAboutContainer {width:auto; border-bottom:1px solid #efefef;} -.footerAbout{ width:455px; margin:0 auto;height:35px; line-height:35px;} +.footerAbout{ width:455px; margin:0 auto;height:35px; line-height:35px; } .languageBox {width:55px; height:20px; margin-left:5px; outline:none; color:#666666; border:1px solid #d9d9d9;} .departments{ width:890px; margin:5px auto 0 auto;height:30px;line-height:30px;} .copyright{ width:375px; margin:0 auto;height:20px;line-height:20px;}