From e6d4d7d0cbcb1624a14932bc63b4c425fae86acf Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 2 Feb 2016 17:16:50 +0800 Subject: [PATCH 01/39] =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E6=A1=86=E7=9A=84?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A2=9E=E9=AB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/org_document_comments/_new.html.erb | 23 +++++++++++-------- app/views/org_document_comments/edit.html.erb | 2 +- app/views/org_document_comments/new.html.erb | 2 +- public/javascripts/des_kindEditor.js | 8 ++++++- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/views/org_document_comments/_new.html.erb b/app/views/org_document_comments/_new.html.erb index 3d8e8bc23..9d3fe2de8 100644 --- a/app/views/org_document_comments/_new.html.erb +++ b/app/views/org_document_comments/_new.html.erb @@ -1,8 +1,12 @@ <%= content_for(:header_tags) do %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> + <%= javascript_include_tag "des_KindEditor" %> <% end %> -<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %> -
+
+ <%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %>
@@ -41,10 +45,10 @@
+ <% end %>
-<% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index b17ae0e75..71ab98764 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -31,7 +31,7 @@
-
+
<%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %> diff --git a/app/views/org_document_comments/new.html.erb b/app/views/org_document_comments/new.html.erb index 30e397422..ba06e8589 100644 --- a/app/views/org_document_comments/new.html.erb +++ b/app/views/org_document_comments/new.html.erb @@ -39,7 +39,7 @@
-
+
<%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %> diff --git a/public/javascripts/des_kindEditor.js b/public/javascripts/des_kindEditor.js index 1b952672a..f09568faa 100644 --- a/public/javascripts/des_kindEditor.js +++ b/public/javascripts/des_kindEditor.js @@ -90,7 +90,9 @@ function init_form(params){ } function nh_reset_form(params){ params.form[0].reset(); - params.texttitle.empty(); + $("#document_title").val(""); + $('#org_document_editor').hide(); + $('#doc_title_hint').hide(); params.textarea.empty(); if(params.editor != undefined){ params.editor.html(params.textarea.html()); @@ -133,4 +135,8 @@ function init_des_data(){ } }); }); + + div_form = $("div[nhname='new_topic_form']"); + $(".ke-edit", div_form).css("height","150px"); + $(".ke-edit-iframe",div_form).css("height","150px"); } \ No newline at end of file From a2e60944be2fd3e8fcd9e9e1f6fc6316164c9406 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 23 Feb 2016 11:04:19 +0800 Subject: [PATCH 02/39] =?UTF-8?q?=E5=B7=B2=E5=8F=91=E5=B8=83=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=9A=84=E5=BB=B6=E6=9C=9F=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 27 +++++++- app/helpers/courses_helper.rb | 2 +- app/views/files/_course_list.html.erb | 80 +---------------------- app/views/files/_hidden_file.html.erb | 54 +++++++++++++++ app/views/files/_resource_detail.html.erb | 77 ++++++++++++++++++++++ app/views/files/_upload_course_files.erb | 2 +- app/views/files/file_hidden.js.erb | 6 ++ app/views/files/republish_file.js.erb | 2 + config/routes.rb | 3 + 9 files changed, 173 insertions(+), 80 deletions(-) create mode 100644 app/views/files/_hidden_file.html.erb create mode 100644 app/views/files/_resource_detail.html.erb create mode 100644 app/views/files/file_hidden.js.erb create mode 100644 app/views/files/republish_file.js.erb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index e83a13ad9..b18612243 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,7 +26,7 @@ class FilesController < ApplicationController before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project, :search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment, :search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache, - :search_files_in_subfield,:upload_files_menu] + :search_files_in_subfield,:upload_files_menu,:file_hidden,:republish_file] helper :sort include SortHelper @@ -96,6 +96,31 @@ class FilesController < ApplicationController end end + def file_hidden + @file = Attachment.find params[:id] + @course = Course.find params[:course_id] + respond_to do |format| + format.js + end + end + + def republish_file + @file = Attachment.find params[:id] + @course = Course.find params[:course_id] + if params[:publish_time] + unless params[:publish_time] == "" + @file.publish_time = params[:publish_time] + end + end + if @file.publish_time > Date.today + @file.is_publish = 0 + end + @file.save + respond_to do |format| + format.js + end + end + def search_project sort = "" @sort = "" diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 6d0066fbc..2cdb277be 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -746,7 +746,7 @@ module CoursesHelper return[] unless course result = [] course.attachments.each do |attachment| - if attachment.is_public? ||User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id))|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin? + if attachment.is_public? ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id))|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin? result << attachment end end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index d7aade6c2..7724bb861 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -1,82 +1,8 @@ - -<% delete_allowed = User.current.allowed_to?(:manage_files, course) %> <% curse_attachments.each do |file| %> <% if file.is_public? || User.current.member_of_course?(course) || User.current.admin? %> -
-
-
- <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %> -
-
-
- <%= link_to truncate(file.filename,length: 35, omission: '...'), - download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %> - <%= file_preview_eye(file, class: 'preview') %> - - <% if file.is_public? == false%> - 私有 - <%end %> - - <% if file.is_publish == 0 %> - <%=file.publish_time %>  0点发布 - <% end %> -
-
- 上传时间:<%= format_time(file.created_on)%> - <% if file.tag_list.length > 0%> - 上传类型:<%= file.tag_list[0] %> - <% end %> -

文件大小:<%= number_to_human_size(file.filesize) %>

-

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

-
-
-
- - <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> - <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> -
-
- -
    -
  • - <% if User.current.logged? %> - - <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> - <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %> -
      - -
    • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • -
    • <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
    • - <% if @course.is_public? %> -
    • - - <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> - -
    • - <%end%> -
    • - <%= link_to( '删除资源', attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %> -
    • -
    - - <% end %> - <%else%> -
      -
    • <%= link_to("发  送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • -
    - <% end %> - <% end %> -
  • -
- -
-
-
-
-
-
+
+ <%=render :partial=>'files/resource_detail',:locals => {:file => file} %> +
<% else %>
<%= file.filename %>是私有资源
<% end %> diff --git a/app/views/files/_hidden_file.html.erb b/app/views/files/_hidden_file.html.erb new file mode 100644 index 000000000..eb0f366a3 --- /dev/null +++ b/app/views/files/_hidden_file.html.erb @@ -0,0 +1,54 @@ +发布设置 + +<%= form_tag(republish_file_course_file_path(@course,@file), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> +
+ +
+ + <%#= calendar_for('attachment_publish_time')%> +
+ +
+
+ +
+ + +
+<% end %> +
+ \ No newline at end of file diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb new file mode 100644 index 000000000..fd0a165aa --- /dev/null +++ b/app/views/files/_resource_detail.html.erb @@ -0,0 +1,77 @@ +<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> +
+
+
+ <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %> +
+
+
+ <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkBlue f_14 f_b" %> + <%= file_preview_eye(file, class: 'preview') %> + + <% if file.is_public? == false%> + 私有 + <%end %> + + <% if file.is_publish == 0 %> + <%=file.publish_time %>  0点发布 + <% end %> +
+
+ 上传时间:<%= format_time(file.created_on)%> + <% if file.tag_list.length > 0%> + 上传类型:<%= file.tag_list[0] %> + <% end %> +

文件大小:<%= number_to_human_size(file.filesize) %>

+

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+
+
+
+ + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> +
+
+ +
    +
  • + <% if User.current.logged? %> + + <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> + <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %> +
      + +
    • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • +
    • <%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %>
    • +
    • <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
    • + <% if @course.is_public? %> +
    • + + <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> + +
    • + <%end%> +
    • + <%= link_to( '删除资源', attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %> +
    • +
    + + <% end %> + <%else%> +
      +
    • <%= link_to("发  送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • +
    + <% end %> + <% end %> +
  • +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index 2e53f05d2..1b8b140a5 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -28,7 +28,7 @@ <%#= calendar_for('attachment_publish_time')%>
- +
<% end %> diff --git a/app/views/files/file_hidden.js.erb b/app/views/files/file_hidden.js.erb new file mode 100644 index 000000000..b95ab5104 --- /dev/null +++ b/app/views/files/file_hidden.js.erb @@ -0,0 +1,6 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/hidden_file',:locals => {:course => @course,:course_attachment_type => 1}) %>'); +showModal('ajax-modal', '311px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file diff --git a/app/views/files/republish_file.js.erb b/app/views/files/republish_file.js.erb new file mode 100644 index 000000000..e85e5eb50 --- /dev/null +++ b/app/views/files/republish_file.js.erb @@ -0,0 +1,2 @@ +hideModal(); +$("#resource_detail_<%=@file.id %>").html("<%= escape_javascript(render :partial=>'files/resource_detail',:locals => {:file => @file}) %>") \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 7060e4eb6..095470139 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -695,6 +695,7 @@ RedmineApp::Application.routes.draw do end member do match "quote_resource_show", :via => [:get] + get "file_hidden" end end @@ -1015,6 +1016,8 @@ RedmineApp::Application.routes.draw do end member do match "quote_resource_show", :via => [:get] + get "file_hidden" + post "republish_file" end end resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do From b6bf78a5df895e00e08f5e1ebebe8f0f0b9b04b8 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 23 Feb 2016 11:35:07 +0800 Subject: [PATCH 03/39] =?UTF-8?q?=E5=BD=93=E5=A4=A9=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=9A=84=E8=B5=84=E6=BA=90=E6=98=BE=E7=A4=BA=E6=9C=AA=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E3=80=81=E6=97=A5=E6=9C=9F=E9=80=89=E6=8B=A9=E5=99=A8?= =?UTF-8?q?=E7=94=A8=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 ++ app/views/files/_hidden_file.html.erb | 1 + app/views/files/_upload_course_files.erb | 1 + 3 files changed, 4 insertions(+) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b18612243..ca37e445c 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -114,6 +114,8 @@ class FilesController < ApplicationController end if @file.publish_time > Date.today @file.is_publish = 0 + else + @file.is_publish = 1 end @file.save respond_to do |format| diff --git a/app/views/files/_hidden_file.html.erb b/app/views/files/_hidden_file.html.erb index eb0f366a3..8e359c605 100644 --- a/app/views/files/_hidden_file.html.erb +++ b/app/views/files/_hidden_file.html.erb @@ -1,3 +1,4 @@ + 发布设置 <%= form_tag(republish_file_course_file_path(@course,@file), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index 1b8b140a5..de43977cd 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -1,3 +1,4 @@ +

<%= l(:label_upload_files)%>

From c91ef44570f7941f759a82bfbdb3d87dab1f67ac Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 23 Feb 2016 12:52:04 +0800 Subject: [PATCH 04/39] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=AD=90=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=EF=BC=9A=E6=89=80=E6=9C=89=E5=AD=90=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=88=B0secdomains=E8=A1=A8=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E7=BB=84=E7=BB=87=E8=A1=A8=E4=B8=AD=E7=9A=84=E5=AD=90?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E8=BF=81=E7=A7=BB=E5=88=B0secdomains?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=EF=BC=8C=E5=B9=B6=E4=BF=AE=E6=94=B9=E7=9B=B8?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 3 ++- app/controllers/organizations_controller.rb | 9 +++++++-- app/views/organizations/_subfield_list.html.erb | 2 +- app/views/organizations/setting.html.erb | 11 ++++++----- app/views/users/user_organizations.html.erb | 5 ----- .../20160223021012_add_index_to_secdomain.rb | 5 +++++ .../20160223021227_move_domain_to_secdomain.rb | 14 ++++++++++++++ ...60223031843_remove_domain_from_organizations.rb | 8 ++++++++ db/schema.rb | 9 +++++++-- 9 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20160223021012_add_index_to_secdomain.rb create mode 100644 db/migrate/20160223021227_move_domain_to_secdomain.rb create mode 100644 db/migrate/20160223031843_remove_domain_from_organizations.rb diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index bae0232a5..2a4bcf9c8 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -30,7 +30,8 @@ class OrgSubfieldsController < ApplicationController if params[:id] @organization = Organization.find(params[:id]) else - @organization = Organization.where("domain=?",request.subdomain).first + domain = Secdomain.where("subname=?", request.subdomain).first + @organization = Organization.find(domain.pid) end @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6e2da311f..f225e7f50 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -139,7 +139,7 @@ class OrganizationsController < ApplicationController end def check_uniq_domain - @is_exist = (Organization.where("domain=?", params[:org_domain]).count > 0) + @is_exist = (Secdomain.where("subname=?",params[:org_domain]).count > 0) end def find_organization @@ -322,7 +322,12 @@ class OrganizationsController < ApplicationController def agree_apply_subdomain @organization = Organization.find(params[:organization_id]) OrgMessage.find(params[:act_id]).update_attribute(:viewed, 1) - @organization.update_attribute(:domain, params[:org_domain]) + if Secdomain.where("pid=? and sub_type=2",@organization.id).count > 0 + domain = Secdomain.where("pid=? and sub_type=2",params[:organization_id]).first + Secdomain.update(domain.id, :subname => params[:org_domain]) + else + Secdomain.create(:sub_type => 2, :pid => params[:organization_id], :subname => params[:org_domain]) + end if OrgMessage.where("message_type='AgreeApplySubdomain' and organization_id=#{@organization.id} and content=?",params[:org_domain]).count == 0 OrgMessage.create(:user_id => params[:user_id], :organization_id => @organization.id, :message_type => 'AgreeApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain]) end diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index b49436d4e..eed0dabf6 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -28,7 +28,7 @@
  • 新增
  • <%= field.field_type == "Post" ? "帖子" : "资源" %>
  • <% else %> - - + + <% end %> <% else %> diff --git a/app/views/news/_course_news_detail.html.erb b/app/views/news/_course_news_detail.html.erb index 61db84134..bd3215fb3 100644 --- a/app/views/news/_course_news_detail.html.erb +++ b/app/views/news/_course_news_detail.html.erb @@ -3,18 +3,6 @@ <%= javascript_include_tag "create_kindeditor" %> <% end %> - <% if newss%> <% newss.each do |news| %> - + <% unless forge_acts.empty? %> <% forge_acts.each do |activity| -%> - + <% user_activities.each do |user_activity| if user_activities %> -
    +
    @@ -91,7 +96,9 @@
    测试代码 - <% unless @is_test %> + <% if @is_test %> + <%=link_to '返 回',course_path(@course),:class=>'fr mt6' %> + <% else @is_test %> 提交代码 <% end %>
    diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 80c219350..7112bd3f3 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -113,6 +113,7 @@ h4{ font-size:14px; color:#3b3b3b;} .mt0 {margin-top:0px !important;} .mt3{ margin-top:3px;} .mt5{ margin-top:5px;} +.mt6{ margin-top:6px;} .mt8{ margin-top:8px;} .mt10{ margin-top:10px !important;} .mt20{margin-top: 20px;} From c93b4d109ad963db2555bed43bde140cd9a114eb Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 25 Feb 2016 16:18:24 +0800 Subject: [PATCH 28/39] =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=90=E8=8F=9C=E5=8D=95=EF=BC=9A=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E4=BD=9C=E5=93=81/=E5=8F=96=E6=B6=88=E5=85=AC?= =?UTF-8?q?=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 28 ++- app/controllers/student_work_controller.rb | 159 ++++++++++-------- .../_alert_open_student_works.html.erb | 23 +++ .../alert_open_student_works.js.erb | 6 + .../homework_common/open_student_works.js.erb | 7 + .../_org_course_homework.html.erb | 9 + .../student_work/_student_work_list.html.erb | 9 +- app/views/users/_course_homework.html.erb | 9 + .../users/_user_homework_detail.html.erb | 9 + config/routes.rb | 2 + ...25024759_add_is_open_to_homewrok_common.rb | 5 + db/schema.rb | 15 +- 12 files changed, 204 insertions(+), 77 deletions(-) create mode 100644 app/views/homework_common/_alert_open_student_works.html.erb create mode 100644 app/views/homework_common/alert_open_student_works.js.erb create mode 100644 app/views/homework_common/open_student_works.js.erb create mode 100644 db/migrate/20160225024759_add_is_open_to_homewrok_common.rb diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index a891d3354..00b11323b 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -6,8 +6,8 @@ class HomeworkCommonController < ApplicationController include StudentWorkHelper before_filter :find_course, :only => [:index,:new,:create] - before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] - before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment] + before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works] + before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works] before_filter :member_of_course, :only => [:index] def index @@ -261,6 +261,30 @@ class HomeworkCommonController < ApplicationController end end + def open_student_works + if @homework.is_open == 0 + @homework.update_attribute(:is_open, 1) + else + @homework.update_attribute(:is_open, 0) + end + @user_activity_id = params[:user_activity_id] + @is_in_course = params[:is_in_course] if params[:is_in_course] + @course_activity = params[:course_activity] if params[:course_Activity] + end + + def alert_open_student_works + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] if params[:is_in_course] + @course_activity = params[:course_activity] if params[:course_Activity] + respond_to do |format| + format.js + end + end + def programing_test test = {language:params[:language],src:Base64.encode64(params[:src]),input:[params[:input]],output:[params[:output]]} @index = params[:index] diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 7ccb3177c..a38d83851 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -6,9 +6,10 @@ class StudentWorkController < ApplicationController require "base64" before_filter :find_homework, :only => [:new, :index, :create, :student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :program_test,:set_score_rule,:forbidden_anonymous_comment,:delete_work,:new_student_work_project,:student_work_project,:cancel_relate_project,:search_course_students] before_filter :find_work, :only => [:edit, :update, :show, :destroy, :add_score, :praise_student_work,:retry_work,:revise_attachment] - before_filter :member_of_course, :only => [:index, :new, :create, :show, :add_score, :praise_student_work] + before_filter :member_of_course, :only => [:new, :create, :show, :add_score, :praise_student_work] before_filter :author_of_work, :only => [:edit, :update, :destroy] before_filter :teacher_of_course, :only => [:student_work_absence_penalty, :absence_penalty_list, :evaluation_list, :set_score_rule, :forbidden_anonymous_comment] + before_filter :is_logged, :only => [:index] ### def program_test @@ -91,101 +92,119 @@ class StudentWorkController < ApplicationController student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')' end #老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表 - if @is_teacher || @homework.homework_detail_manual.nil? || - (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) + if @homework.is_open == 1 @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name @show_all = true - elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 - if @homework.homework_type == 3 - pro = @homework.student_work_projects.where(:user_id => User.current.id).first - if pro.nil? - @stundet_works = [] + elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin? + if @is_teacher || @homework.homework_detail_manual.nil? || + (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name + @show_all = true + elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + if pro.nil? + @stundet_works = [] + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) end - else - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - end - elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 - if @homework.homework_type == 3 - pro = @homework.student_work_projects.where(:user_id => User.current.id).first - if pro.nil? - my_work = [] + elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.where(:id => pro.student_work_id) + end else - my_work = @homework.student_works.where(:id => pro.student_work_id) + my_work = @homework.student_works.where(:user_id => User.current.id) end - else - my_work = @homework.student_works.where(:user_id => User.current.id) - end - @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} - elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 - if @homework.homework_type == 3 - pro = @homework.student_work_projects.where(:user_id => User.current.id).first - if pro.nil? - my_work = [] + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end + if my_work.empty? + @stundet_works = [] + else + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name + @show_all = true end else - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - end - if my_work.empty? @stundet_works = [] - else - @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name - @show_all = true end else - @stundet_works = [] + render_403 + return end + @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count else - if @is_teacher || @homework.homework_detail_manual.nil? || (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) #老师 || 超级管理员 显示所有列表 + if @homework.is_open == 1 @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name @show_all = true - elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 - if @homework.homework_type == 3 - pro = @homework.student_work_projects.where(:user_id => User.current.id).first - if pro.nil? - @stundet_works = [] + elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin? + if @is_teacher || @homework.homework_detail_manual.nil? || (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) #老师 || 超级管理员 显示所有列表 + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + @show_all = true + elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的 + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + if pro.nil? + @stundet_works = [] + else + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) end - else - @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - end - elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 - if @homework.homework_type == 3 - pro = @homework.student_work_projects.where(:user_id => User.current.id).first - if pro.nil? - my_work = [] + elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表 + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.where(:id => pro.student_work_id) + end else - my_work = @homework.student_works.where(:id => pro.student_work_id) + my_work = @homework.student_works.where(:user_id => User.current.id) end - else - my_work = @homework.student_works.where(:user_id => User.current.id) - end - @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} - elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 - if @homework.homework_type == 3 - pro = @homework.student_work_projects.where(:user_id => User.current.id).first - if pro.nil? - my_work = [] + @stundet_works = my_work + User.current.student_works_evaluation_distributions.map(&:student_work).select { |work| work.homework_common_id == @homework.id} + elsif @homework.homework_detail_manual.comment_status == 3 #学生 && 关闭匿评 未提交作品之前列表为空,提交了作品看到所有的 + if @homework.homework_type == 3 + pro = @homework.student_work_projects.where(:user_id => User.current.id).first + if pro.nil? + my_work = [] + else + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + end else - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id) + my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) + end + if my_work.empty? + @stundet_works = [] + else + @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name + @show_all = true end else - my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id) - end - if my_work.empty? @stundet_works = [] - else - @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name - @show_all = true end else - @stundet_works = [] + render_403 + return end + @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name).count end @@ -802,6 +821,10 @@ class StudentWorkController < ApplicationController render_403 unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? end + def is_logged + redirect_to signin_path unless User.current.logged? + end + #根据条件过滤作业结果 def search_homework_member homeworks,name if name == "" diff --git a/app/views/homework_common/_alert_open_student_works.html.erb b/app/views/homework_common/_alert_open_student_works.html.erb new file mode 100644 index 000000000..ef8fe3d08 --- /dev/null +++ b/app/views/homework_common/_alert_open_student_works.html.erb @@ -0,0 +1,23 @@ +
    +
    + <% if @homework.is_open == 0 %> +

    公开作品

    +

    + 本次作业的所有作品将对Trustie平台所有注册用户开放,请问是否确定公开作品? +

    + <% else %> +

    取消公开作品

    +

    + 您将取消“公开作品”的功能,本次作业的作品将不对Trustie平台其他未加入本课程的用户开放,请问是否确定? +

    + <% end %> + +
    +
    \ No newline at end of file diff --git a/app/views/homework_common/alert_open_student_works.js.erb b/app/views/homework_common/alert_open_student_works.js.erb new file mode 100644 index 000000000..591d34028 --- /dev/null +++ b/app/views/homework_common/alert_open_student_works.js.erb @@ -0,0 +1,6 @@ +$("#ajax-modal").html("<%=escape_javascript(render :partial => 'alert_open_student_works') %>"); +showModal('ajax-modal', '500px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before("" + + ""); +$('#ajax-modal').parent().css("top","30%").css("left","30%").css("position","fixed").css("border","3px solid #269ac9"); \ No newline at end of file diff --git a/app/views/homework_common/open_student_works.js.erb b/app/views/homework_common/open_student_works.js.erb new file mode 100644 index 000000000..e171e65d1 --- /dev/null +++ b/app/views/homework_common/open_student_works.js.erb @@ -0,0 +1,7 @@ +<% if @user_activity_id.to_i == -1 %> +$("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); +sd_create_editor_from_data(<%= @homework.id%>,"","100%", "<%=@homework.class.to_s%>"); +<% else %> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); +sd_create_editor_from_data(<%= @user_activity_id%>,"","100%", "UserActivity"); +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index b5e3c6958..40db2335f 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -240,6 +240,15 @@ <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <% end %> + <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> +
  • + <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> +
  • + <% elsif activity.is_open == 1 %> +
  • + <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> +
  • + <% end %> diff --git a/app/views/student_work/_student_work_list.html.erb b/app/views/student_work/_student_work_list.html.erb index df89f31eb..1eea8f1c2 100644 --- a/app/views/student_work/_student_work_list.html.erb +++ b/app/views/student_work/_student_work_list.html.erb @@ -4,15 +4,16 @@ (<%= @student_work_count%>人已交) - <% if !@is_teacher && @stundet_works.empty?%> + <% my_work = @homework.student_works.where("user_id = #{User.current.id}").first %> + <% if !@is_teacher && my_work.nil? && User.current.member_of_course?(@course) %> 您尚未提交作品 - <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> 您已提交且不可再修改,因为截止日期已过 - <% elsif !@is_teacher &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> + <% elsif !@is_teacher && my_work &&Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.parse(Time.now.to_s).strftime("%Y-%m-%d") && !@stundet_works.empty?%> 您已提交,您还可以修改 <% end %> - <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3%> + <%if @is_teacher || @homework.homework_detail_manual.comment_status == 3 || @homework.is_open == 1%>
    diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index d508fe1af..e1d9ca0e0 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -239,6 +239,15 @@ <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <% end %> + <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> +
  • + <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> +
  • + <% elsif activity.is_open == 1 %> +
  • + <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> +
  • + <% end %> diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 01673d164..c2989ee14 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -243,6 +243,15 @@ <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%> <% end %> + <% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %> +
  • + <%= link_to("公开作品", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%> +
  • + <% elsif homework_common.is_open == 1 %> +
  • + <%= link_to("取消公开", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%> +
  • + <% end %> diff --git a/config/routes.rb b/config/routes.rb index 095470139..562fb8157 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -238,6 +238,8 @@ RedmineApp::Application.routes.draw do get 'stop_anonymous_comment' get 'alert_anonymous_comment' get 'alert_forbidden_anonymous_comment' + get 'alert_open_student_works' + get 'open_student_works' get 'start_evaluation_set' get 'score_rule_set' post 'set_evaluation_attr' diff --git a/db/migrate/20160225024759_add_is_open_to_homewrok_common.rb b/db/migrate/20160225024759_add_is_open_to_homewrok_common.rb new file mode 100644 index 000000000..760205e26 --- /dev/null +++ b/db/migrate/20160225024759_add_is_open_to_homewrok_common.rb @@ -0,0 +1,5 @@ +class AddIsOpenToHomewrokCommon < ActiveRecord::Migration + def change + add_column :homework_commons, :is_open, :integer, :default => 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index ef1a1b538..99804e63f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160224074034) do +ActiveRecord::Schema.define(:version => 20160225024759) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -99,8 +99,6 @@ ActiveRecord::Schema.define(:version => 20160224074034) do t.integer "quotes" t.integer "version" t.integer "attachment_id" - t.integer "is_publish", :default => 1 - t.date "publish_time" end create_table "attachments", :force => true do |t| @@ -751,6 +749,14 @@ ActiveRecord::Schema.define(:version => 20160224074034) do t.integer "locked" end + create_table "forwards", :force => true do |t| + t.integer "from_id" + t.string "from_type" + t.integer "to_id" + t.string "to_type" + t.datetime "created_at" + end + create_table "groups_users", :id => false, :force => true do |t| t.integer "group_id", :null => false t.integer "user_id", :null => false @@ -788,6 +794,7 @@ ActiveRecord::Schema.define(:version => 20160224074034) do t.integer "teacher_priority", :default => 1 t.integer "anonymous_comment", :default => 0 t.integer "quotes", :default => 0 + t.integer "is_open", :default => 0 end add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" @@ -1269,6 +1276,7 @@ ActiveRecord::Schema.define(:version => 20160224074034) do t.text "description" t.integer "creator_id" t.integer "home_id" + t.string "domain" t.boolean "is_public" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false @@ -1376,6 +1384,7 @@ ActiveRecord::Schema.define(:version => 20160224074034) do t.integer "changeset_num", :default => 0 t.integer "board_message_num", :default => 0 t.integer "board_num", :default => 0 + t.integer "act_num", :default => 0 t.integer "attach_num", :default => 0 t.datetime "commit_time" end From 991613d7604a2036698d1d63fc242272ea1b8485 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 25 Feb 2016 16:22:42 +0800 Subject: [PATCH 29/39] =?UTF-8?q?=E5=9C=A8=E8=BD=AC=E5=8F=91=E8=A1=A8forwa?= =?UTF-8?q?rds=E8=AE=B0=E5=BD=95=E5=8F=91=E9=80=81=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E3=80=81=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 24 ++++++++++++++++++++++++ app/models/attachment.rb | 2 +- app/models/message.rb | 2 ++ app/models/news.rb | 3 +++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 654703bd6..a1dc443e0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1856,6 +1856,10 @@ class UsersController < ApplicationController course_ids.each do |course_id| if Course.find(course_id).news.map(&:id).exclude?(news.id) course_news = News.create(:course_id => course_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) + #record forward to table forwards if new record is valid + if course_news.valid? + news.forwards << Forward.new(:to_type => course_news.class.name, :to_id => course_news.id) + end news.attachments.each do |attach| course_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1872,6 +1876,10 @@ class UsersController < ApplicationController project = Project.find(project_id) if project.news.map(&:id).exclude?(news.id) message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if message.valid? + news.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) + end news.attachments.each do |attach| message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1885,6 +1893,10 @@ class UsersController < ApplicationController news = News.find(params[:send_id]) field_id = params[:subfield] org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1) + # record forward to table forwards if new record is valid + if org_news.valid? + news.forwards << Forward.new(:to_type => org_news.class.name, :to_id => org_news.id) + end news.attachments.each do |attach| org_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1900,6 +1912,10 @@ class UsersController < ApplicationController course = Course.find(course_id) if course.news.map(&:id).exclude?(@message.id) message = Message.create(:board_id => course.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if message.valid? + @message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) + end @message.attachments.each do |attach| message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1916,6 +1932,10 @@ class UsersController < ApplicationController project = Project.find(project_id) if project.news.map(&:id).exclude?(@message.id) message = Message.create(:board_id => project.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if message.valid? + @message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) + end @message.attachments.each do |attach| message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, @@ -1932,6 +1952,10 @@ class UsersController < ApplicationController @message.save board = OrgSubfield.find(field_id).boards.first mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id) + # record forward to table forwards if new record is valid + if mes.valid? + @message.forwards << Forward.new(:to_type => mes.class.name, :to_id => mes.id) + end @message.attachments.each do |attach| mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c8aa33760..9fb6112b8 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -28,7 +28,7 @@ class Attachment < ActiveRecord::Base belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy - has_many :forwards, :as => :from + has_many :forwards, :as => :from, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end diff --git a/app/models/message.rb b/app/models/message.rb index 675d37790..cc9968309 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -45,6 +45,8 @@ class Message < ActiveRecord::Base has_many :ActivityNotifies,:as => :activity, :dependent => :destroy + #转发表 + has_many :forwards, :as => :from, :dependent => :destroy after_destroy :delete_org_activities acts_as_searchable :columns => ['subject', 'content'], diff --git a/app/models/news.rb b/app/models/news.rb index fee5d2801..f859beb0c 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -37,6 +37,9 @@ class News < ActiveRecord::Base has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy #end + #转发表 + has_many :forwards, :as => :from, :dependent => :destroy + has_many :ActivityNotifies,:as => :activity, :dependent => :destroy validates_presence_of :title, :description From 09c8e57f1c677614c83e7ebcd920491951e6a625 Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 26 Feb 2016 10:41:14 +0800 Subject: [PATCH 30/39] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=97=B6=E5=8F=AF=E5=A4=8D=E5=88=B6=E8=B5=84=E6=BA=90=E5=92=8C?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 88 +++++++++++++++++++++++++ app/models/attachment.rb | 13 +++- app/views/courses/_copy_course.html.erb | 18 +++-- 3 files changed, 111 insertions(+), 8 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 36060d41c..be96124c2 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -450,6 +450,93 @@ class CoursesController < ApplicationController #copy avatar copy_avatar(@course, copy_course) + if params[:course_content_type] + params[:course_content_type].each do |type| + case type + when "0" + homeworks = copy_course.homework_commons + homeworks.each do |homework| + new_homework = HomeworkCommon.new + new_homework.name = homework.name + new_homework.user_id = User.current.id + new_homework.description = homework.description + new_homework.publish_time = Date.today + 30 + new_homework.end_time = Date.today + 60 + new_homework.homework_type = homework.homework_type + new_homework.late_penalty = homework.late_penalty + new_homework.course_id = @course.id + new_homework.teacher_priority = homework.teacher_priority + new_homework.anonymous_comment = homework.anonymous_comment + new_homework.quotes = 0 + new_homework.is_open = homework.is_open + homework.attachments.each do |attachment| + att = attachment.copy + att.container_id = nil + att.container_type = nil + att.copy_from = attachment.id + att.save + new_homework.attachments << att + end + homework_detail_manual = homework.homework_detail_manual + homework_detail_programing = homework.homework_detail_programing + homework_detail_group = homework.homework_detail_group + if homework_detail_manual + new_homework.homework_detail_manual = HomeworkDetailManual.new + new_homework_detail_manual = new_homework.homework_detail_manual + new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion + new_homework_detail_manual.comment_status = 0 + new_homework_detail_manual.evaluation_start = Date.today + 67 + new_homework_detail_manual.evaluation_end = Date.today + 74 + new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num + new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty + end + if homework_detail_programing + new_homework.homework_detail_programing = HomeworkDetailPrograming.new + new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion + new_homework.homework_detail_programing.language = homework_detail_programing.language + homework.homework_tests.each_with_index do |homework_test| + new_homework.homework_tests << HomeworkTest.new( + input: homework_test.input, + output: homework_test.output + ) + end + end + + if homework_detail_group + new_homework.homework_detail_group = HomeworkDetailGroup.new + new_homework.homework_detail_group.min_num = homework_detail_group.min_num + new_homework.homework_detail_group.max_num = homework_detail_group.max_num + new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project + end + if new_homework.save + new_homework_detail_manual.save if new_homework_detail_manual + new_homework.homework_detail_programing.save if new_homework.homework_detail_programing + new_homework.homework_detail_group.save if new_homework.homework_detail_group + end + homework.update_attribute(:quotes, homework.quotes+1) + end + when "1" + attachments = copy_course.attachments + attachments.each do |attachment| + attach_copied_obj = attachment.copy + attach_copied_obj.tag_list.add(attachment.tag_list) # tag关联 + attach_copied_obj.container = @course + attach_copied_obj.created_on = Time.now + attach_copied_obj.author_id = User.current.id + attach_copied_obj.copy_from = attachment.copy_from.nil? ? attachment.id : attachment.copy_from + attach_copied_obj.is_publish = 0 + attach_copied_obj.publish_time = Date.today + 30 + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + attach_copied_obj.save + update_quotes attach_copied_obj + end + end + end + end + +=begin if params[:checkAll] attachments = copy_course.attachments attachments.each do |attachment| @@ -513,6 +600,7 @@ class CoursesController < ApplicationController end end end +=end end if @course respond_to do |format| diff --git a/app/models/attachment.rb b/app/models/attachment.rb index c8aa33760..faeab1f30 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -88,7 +88,8 @@ class Attachment < ActiveRecord::Base cattr_accessor :thumbnails_storage_path @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") - before_save :files_to_final_location,:act_as_course_activity + before_save :files_to_final_location + after_save :act_as_course_activity after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count @@ -606,8 +607,14 @@ class Attachment < ActiveRecord::Base #课程动态公共表记录 def act_as_course_activity - if self.container_type == "Course" && self.course_acts.empty? - self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id) + if self.container_type == "Course" + if self.is_publish == 0 + self.course_acts.destroy_all + else + if self.is_publish == 1 && self.course_acts.empty? + self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id) + end + end end end diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index c7547adcd..0cd8804d9 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -93,15 +93,23 @@
  • - +
    • + + 作业
    • + 复制到新课中的作业将在1个月后发布、2个月后提交截止,请您调整作业的发布时间、截止时间等时间节点。 +
      +
    • + +
    • + 复制到新课的资源将在1个月后发布,请您调整资源的发布时间,否则学生可能看不到资源。
    -
      +
      <% end %> From e8234092ec3a2239d9c70d9f39ffadee36eebae3 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 26 Feb 2016 11:16:12 +0800 Subject: [PATCH 31/39] =?UTF-8?q?=E5=A4=8D=E5=88=B6=E5=AD=A6=E6=9C=9F?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_copy_course.html.erb | 17 ++++++++--------- app/views/courses/copy_course.js.erb | 2 +- db/schema.rb | 4 ++-- public/stylesheets/public.css | 1 + 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index 0cd8804d9..68184d352 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -92,22 +92,21 @@ (选中后课外用户可见该课程,否则仅对课内成员可见)
      -
    • +
    • -
        -
      • -
      diff --git a/app/views/repositories/_navigation.html.erb b/app/views/repositories/_navigation.html.erb index c3e154f17..d99df5ed1 100644 --- a/app/views/repositories/_navigation.html.erb +++ b/app/views/repositories/_navigation.html.erb @@ -18,7 +18,7 @@ <% if !@repository.branches.nil? && @repository.branches.length > 0 -%> <%= l(:label_branch) %>: - <%= select_tag :branch, options_for_select([''] + @repository.branches, @rev), :id => 'branch' %> + <%= select_tag :branch, options_for_select(@repository.branches, @rev), :id => 'branch' %> <% end -%> <% if !@repository.tags.nil? && @repository.tags.length > 0 -%> diff --git a/lib/gitlab-cli/lib/gitlab/client/projects.rb b/lib/gitlab-cli/lib/gitlab/client/projects.rb index 8d91edd06..2cc96c4d1 100644 --- a/lib/gitlab-cli/lib/gitlab/client/projects.rb +++ b/lib/gitlab-cli/lib/gitlab/client/projects.rb @@ -85,8 +85,8 @@ class Gitlab::Client # public (optional) - if true same as setting visibility_level = 20 # visibility_level (optional) - def edit_project(id, visibility_level) - put("/projects/#{id}", :body => {:visibility_level => visibility_level}) + def edit_project(id, visibility_level, default_branch) + put("/projects/#{id}", :body => {:visibility_level => visibility_level, :default_branch => default_branch}) end # Deletes a project. From 8edaa9d2bddcecf7daf84923feb804b0d2cae9a0 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 1 Mar 2016 17:33:44 +0800 Subject: [PATCH 39/39] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 67 +++---- app/helpers/users_helper.rb | 53 ++++++ app/views/layouts/_logined_header.html.erb | 2 +- .../users/_resource_search_form.html.erb | 6 +- app/views/users/_resources_list.html.erb | 27 +-- app/views/users/user_resource.html.erb | 169 +++++++++--------- public/stylesheets/public.css | 21 +++ 7 files changed, 209 insertions(+), 136 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index e6b2a2036..ddb650193 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -697,6 +697,8 @@ class UsersController < ApplicationController @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc") elsif params[:type] == "5" #用户资源 @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") + elsif params[:type] == "6" #公共资源 + Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)" + "or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc") end @type = params[:type] @limit = 7 @@ -729,6 +731,8 @@ class UsersController < ApplicationController @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") elsif params[:type] == "5" #用户资源 @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + elsif params[:type] == "6" #公共资源 + @attachments = Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)" + "or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc") end @type = params[:type] @limit = 7 @@ -1445,6 +1449,8 @@ class UsersController < ApplicationController else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type ='Principal'").order("created_on desc") end + elsif params[:type] == "6" # 公共资源 + @attachments = Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)" + "or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc") end @type = params[:type] || 1 @limit = 25 @@ -2171,51 +2177,30 @@ class UsersController < ApplicationController # 资源库 分为全部 课程资源 项目资源 附件 def user_resource - #确定container_type - # @user = User.find(params[:id]) # 别人的资源库是没有权限去看的 if User.current.id.to_i != params[:id].to_i render_403 return end - if(params[:type].blank? || params[:type] == "1") #全部 - if User.current.id.to_i == params[:id].to_i - user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 - @attachments = Attachment.where("(author_id = #{params[:id]} and is_publish = 1 and container_type in('Project','OrgSubfield','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(',')}) and is_publish = 1)").order("created_on desc") - else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源 - @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and is_publish = 1 " + - "and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) " + - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1)").order("created_on desc") - end - elsif params[:type] == "2" #课程资源 - if User.current.id.to_i == params[:id].to_i - user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc") - else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 - @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and container_type = 'Course' and is_publish = 1)"+ - "or (container_type = 'Course' and is_public = 1 and is_publish = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").order("created_on desc") - end - elsif params[:type] == "3" #项目资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").order("created_on desc") - end + user_course_ids = User.current.courses.map { |c| c.id} + user_project_ids = User.current.projects.map {|p| p.id} + # user_org_ids = User.current.projects.map {|p| p.id} + if(params[:type].blank? || params[:type] == "1") # 我的资源 + # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 + @attachments = Attachment.where("(author_id = #{params[:id]} and is_publish = 1 and container_type in('Project','OrgSubfield','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(',')}) and is_publish = 1)" + + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1)" ).order("created_on desc") + elsif params[:type] == "2" # 课程资源 + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc") + elsif params[:type] == "3" # 项目资源 + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc") elsif params[:type] == "4" #附件 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") - end + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") elsif params[:type] == "5" #用户资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal'").order("created_on desc") - end + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc") + elsif params[:type] == "6" # 公共资源 + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = Attachment.where(" ").order("created_on desc") end @type = params[:type] @limit = 25 @@ -2227,7 +2212,7 @@ class UsersController < ApplicationController @attachments = paginateHelper @attachments,25 respond_to do |format| format.js - format.html {render :layout => 'new_base_user'} + format.html {render :layout => 'new_base'} end end @@ -2274,6 +2259,10 @@ class UsersController < ApplicationController else @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") end + elsif params[:type] == "6" #全部资源 + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = Attachment.where("((is_public =1 and is_publish = 1 and container_id is not null)" + + "or (author_id = #{params[:id]} and is_publish = 0)) and (filename like :p) ", :p => search).order("created_on desc") end @type = params[:type] @limit = 25 diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index efb67a2ac..1e924cefa 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -54,6 +54,59 @@ module UsersHelper end end + def get_resource_origin attach + type = attach.container_type + content = attach.container + case type + when 'Course' + result = current_time_and_term_resource content + when 'Project' + result = content.name + when 'Issue' + result = content.subject + when 'Message' + result = content.subject + when 'News' + result = content.title + when 'HomewCommon' + result = content.name + when 'StudentWorkScore' + result = content.name + when 'Principal' + result = content.name + when 'OrgSubfield' + result = content.name + end + end + + def current_time_and_term_resource course + str = "" + term = cur_course_term_resource + name = course.name + if (course.time == course.end_time && course.term == course.end_term) || (course.end_term.nil? && course.end_time.nil?) || course.time > Time.now.year + str = name + "(" + course.time.to_s + course.term.to_s + ")" + elsif course.time == Time.now.year && set_term_value(cur_course_term) <= set_term_value(course.term) + str = name + "(" + course.time.to_s + course.term.to_s + ")" + elsif course.end_time < Time.now.year || (course.end_time == Time.now.year && set_term_value(cur_course_term) >= set_term_value(course.term)) + str = name + "(" + course.end_time.to_s + course.end_term.to_s + ")" + else + str = name + "(" + Time.now.year.to_s + cur_course_term_resource.to_s + ")" + end + str + end + + def cur_course_term_resource + month = Time.now.month + if month >= 9 || month < 2 + term = "秋" + elsif (month >= 7 && Time.now.day >= 15) || month == 8 + term = "夏" + else + term = "春" + end + term + end + def title_for_message type case type when nil diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 2fa627c73..0ab5c2876 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -8,7 +8,7 @@ <%= link_to "首页",user_activities_path(User.current.id), :class => "c_white f16 db p10", :title => "回到个人首页"%>
    • + 资源库 diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb index c629f9f32..f52fbe4df 100644 --- a/app/views/users/_resource_search_form.html.erb +++ b/app/views/users/_resource_search_form.html.erb @@ -1,7 +1,7 @@ -<%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>user.id), - :remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %> +<%= form_tag( url_for(:controller => 'users', :action => 'resource_search', :id => user.id), + :remote => true , :method => 'get', :class => 'resourcesSearchloadBox mt10', :id => 'resource_search_form') do %> <%= hidden_field_tag(:type,type.nil? ? 1 : type) %> - <%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %> + <%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none' %> <% end %> \ No newline at end of file diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index a0a1377f1..cb845e0ed 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -1,27 +1,28 @@ - <% if attachments.nil? || attachments.empty? %> <% else %> <% attachments.each do |attach| %> -
        -
      • +
          +
        • +
        • -
        • - - <%= link_to truncate(attach.filename,:length=>30), download_named_attachment_path(attach.id, attach.filename), - :title => attach.filename,:class=>'resourcesBlack'%> +
        • -
        • <%= number_to_human_size(attach.filesize) %>
        • -
        • <%= get_resource_type(attach.container_type)%>
        • -
        • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
        • +
        • <%= format_date(attach.created_on) %>
        • +
        • <%= attach.id %>
        • +
        • <%= attach.author_id %>
        • -
        • <%= format_date(attach.created_on) %>
        • +
        • <%= get_resource_type(attach.container_type)%>
        • +
        • <%= attach.id %>
        • +
        • <%= number_to_human_size(attach.filesize) %>
        • +
        • <%= attach.id %>
        • +
        • <%= attach.id %>
        -
          - +
          <% end %> <% end %> diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index 5abadfb29..9175bc1c4 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -1,4 +1,3 @@ - <%= javascript_include_tag 'bootstrap'%> <%= stylesheet_link_tag 'project' %> <%= stylesheet_link_tag 'leftside' %> @@ -12,6 +11,12 @@ function remote_get_resources(user_id,type){ } + $(document).ready(function(){ + $(".resource-switch").click(function(){ + $(".resource-switch").children().removeClass("resource-tab-active"); + $(this).children().addClass("resource-tab-active"); + }); + }); function remote_search(){ $("#resource_search_form").submit(); } @@ -21,7 +26,7 @@ showModal('ajax-modal', '452px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); - $('#ajax-modal').parent().css("top","50%").css("left","50%"); + $('#ajax-modal').parent().css("top","50%").css("left","50%").css("position","absolute"); $('#ajax-modal').parent().addClass("resourceUploadPopup"); $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); } @@ -56,95 +61,99 @@ } } -
          -
          资源库
          -
            -
          • -
              -
            • - <%= link_to '全部' ,user_resource_user_path(:id=>@user.id,:type=>1),:remote=>true,:method => 'get',:class=>'resourcesTypeAll resourcesGrey' %> -
            • -
            • - <%= link_to '课程资源' ,user_resource_user_path(:id=>@user.id,:type=>2),:remote=>true,:method => 'get',:class=>'homepagePostTypeAssignment postTypeGrey' %> -
            • -
            • - <%= link_to '项目资源' ,user_resource_user_path(:id=>@user.id,:type=>3),:remote=>true,:method => 'get',:class=>'homepagePostTypeQuiz postTypeGrey' %> -
            • -
            • - <%= link_to '用户资源' ,user_resource_user_path(:id=>@user.id,:type=>5),:remote=>true,:method => 'get',:class=>'resourcesTypeUser resourcesGrey' %> -
            • -
            • - <%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %> -
            • -
            -
          • -
          -
          - -
          -
          - -
          - <%= render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} %> -
          -
          为您找到<%= @atta_count%>个资源
          -
          -
          -
            -
          • -
          • 资源名称
          • -
          • 大小
          • -
          • 类别
          • -
          • 上传者
          • -
          • 上传时间
          • -
          -
          -
          -
          - <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> - -
          -
          -
          - +
          +
          +
          +
            +
          • 公共资源
          • +
          • <%=link_to "我的资源", {:controller => 'users', :action => 'user_resource', :id => User.current.id, :type => 1, :remote => true}, :class => "resource-tab" %>
          • +
          •  
          • +
          • +
              +
            • +
                +
              • + <%= link_to '全部' ,user_resource_user_path(:id => @user.id, :type => 1), :remote => true, :method => 'get', :class => 'resourcesTypeAll resourcesGrey' %> +
              • +
              • + <%= link_to '课程资源' ,user_resource_user_path(:id => @user.id, :type => 2), :remote => true, :method => 'get', :class=> 'homepagePostTypeAssignment postTypeGrey' %> +
              • +
              • + <%= link_to '项目资源' ,user_resource_user_path(:id => @user.id, :type => 3), :remote => true, :method => 'get', :class => 'homepagePostTypeQuiz postTypeGrey' %> +
              • +
              • + <%= link_to '用户资源' ,user_resource_user_path(:id=>@user.id,:type=>5),:remote=>true,:method => 'get', :class=>'resourcesTypeUser resourcesGrey' %> +
              • +
              • + <%= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4),:remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %> +
              • +
              +
            • +
            +
          • +
            +
          +
          +
          + +
          + <%= render :partial => 'resource_search_form',:locals => {:user => @user, :type => @type} %> +
          +
          为您找到<%= @atta_count %>个资源
          - 全选 - 删除 -
          -
          选择 0 个资源
          -
          - 发送 +
          +
            +
          • +
          • 资源名称
          • +
          • 上传时间
          • +
          • 上传者
          • +
          • 类别
          • +
          • 大小
          • +
          • 资源来源
          • +
          +
          + +
          + <%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %> +
          +
          +
          +
          + +
          + 全选 + 删除 +
          +
          选择 0 个资源
          +
          + 发送 +
          +
          + +
          +
          +
            + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> +
          - -
          -
          -
            - <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true%> -
          -
          -