From 4999b47b44eacc0c9d224beaa55a77243ff0c08d Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 17 Mar 2016 16:46:26 +0800
Subject: [PATCH 01/14] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8E=BB=E6=8E=89ID?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/users_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index bdd34d80d..44b919121 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -62,7 +62,7 @@ module UsersHelper
when 'Course'
result = current_time_and_term_resource content
when 'Project'
- result = content.name + "(" + content.id.to_s + ")"
+ result = content.name
when 'Issue'
result = content.subject
when 'Message'
From 79767f4baec04d63fa3276b3255d62e2da785cd3 Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 17 Mar 2016 17:22:07 +0800
Subject: [PATCH 02/14] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A1=8C=E4=B8=BA?=
=?UTF-8?q?=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/attachments_controller.rb | 6 ++++++
app/models/user_actions.rb | 4 ++++
db/migrate/20160317090350_create_user_actions.rb | 11 +++++++++++
db/schema.rb | 10 +++++++++-
spec/factories/user_actions.rb | 8 ++++++++
spec/models/user_actions_spec.rb | 5 +++++
6 files changed, 43 insertions(+), 1 deletion(-)
create mode 100644 app/models/user_actions.rb
create mode 100644 db/migrate/20160317090350_create_user_actions.rb
create mode 100644 spec/factories/user_actions.rb
create mode 100644 spec/models/user_actions_spec.rb
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index e974f26b4..155e75976 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -104,6 +104,8 @@ class AttachmentsController < ApplicationController
end
else
direct_download_history
+ # 记录用户行为
+ record_user_actions
end
end
else
@@ -113,6 +115,10 @@ class AttachmentsController < ApplicationController
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end
+ def record_user_actions
+ UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id)
+ end
+
def download
# modify by nwb
# 下载添加权限设置
diff --git a/app/models/user_actions.rb b/app/models/user_actions.rb
new file mode 100644
index 000000000..de2388911
--- /dev/null
+++ b/app/models/user_actions.rb
@@ -0,0 +1,4 @@
+class UserActions < ActiveRecord::Base
+ attr_accessible :action_id, :action_type, :user_id
+ has_many :users
+end
diff --git a/db/migrate/20160317090350_create_user_actions.rb b/db/migrate/20160317090350_create_user_actions.rb
new file mode 100644
index 000000000..d7893fcad
--- /dev/null
+++ b/db/migrate/20160317090350_create_user_actions.rb
@@ -0,0 +1,11 @@
+class CreateUserActions < ActiveRecord::Migration
+ def change
+ create_table :user_actions do |t|
+ t.integer :user_id
+ t.string :action_type
+ t.integer :action_id
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 33bf42b5b..2c55aad61 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 => 20160316055201) do
+ActiveRecord::Schema.define(:version => 20160317090350) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -1782,6 +1782,14 @@ ActiveRecord::Schema.define(:version => 20160316055201) do
t.integer "fields_bits", :default => 0
end
+ create_table "user_actions", :force => true do |t|
+ t.integer "user_id"
+ t.string "action_type"
+ t.integer "action_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "user_activities", :force => true do |t|
t.string "act_type"
t.integer "act_id"
diff --git a/spec/factories/user_actions.rb b/spec/factories/user_actions.rb
new file mode 100644
index 000000000..38dbed67e
--- /dev/null
+++ b/spec/factories/user_actions.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+ factory :user_action, :class => 'UserActions' do
+ user_id 1
+action_type "MyString"
+action_id 1
+ end
+
+end
diff --git a/spec/models/user_actions_spec.rb b/spec/models/user_actions_spec.rb
new file mode 100644
index 000000000..afe799fb9
--- /dev/null
+++ b/spec/models/user_actions_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe UserActions, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
From 6f5a4d429d702f8fe3253552f9d80c25b256c0b7 Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Thu, 17 Mar 2016 21:17:30 +0800
Subject: [PATCH 03/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8Aissue=E8=AF=A6?=
=?UTF-8?q?=E6=83=85=E9=A1=B5=E9=9D=A2=E6=A0=B7=E5=BC=8F=E4=B9=B1=E4=BA=86?=
=?UTF-8?q?=E3=80=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/issues/show.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb
index 4b82f8665..cf771a700 100644
--- a/app/views/issues/show.html.erb
+++ b/app/views/issues/show.html.erb
@@ -9,7 +9,7 @@
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
- if(<%= @is_edit %>) {
+ if(true == <%= @is_edit %>) {
issueEditShow();
}
});
From b262e1b4325943b53b006c4d6108ed0628ea51ce Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 09:58:47 +0800
Subject: [PATCH 04/14] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=B8=8B=E8=BD=BD?=
=?UTF-8?q?=E8=A1=8C=E4=B8=BA=E8=AE=B0=E5=BD=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/attachments_controller.rb | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 155e75976..9d5b3cc5a 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -103,9 +103,10 @@ class AttachmentsController < ApplicationController
direct_download_history
end
else
- direct_download_history
# 记录用户行为
- record_user_actions
+ record_user_actions(params[:id])
+ # 直接下载历史版本
+ direct_download_history
end
end
else
@@ -115,8 +116,12 @@ class AttachmentsController < ApplicationController
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end
- def record_user_actions
- UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id)
+ def record_user_actions id
+ if params[:action] == "download_history"
+ UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) unless id.nil?
+ elsif params[:action] == "download"
+ UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id)
+ end
end
def download
@@ -141,6 +146,8 @@ class AttachmentsController < ApplicationController
direct_download
end
else
+ # 记录用户行为
+ record_user_actions(params[:id])
direct_download
end
end
From 4766abab7fb7c7378e5b12e79bbaed4b92354316 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 09:59:39 +0800
Subject: [PATCH 05/14] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E8=A1=8C=E4=B8=BA?=
=?UTF-8?q?=E6=B7=BB=E5=8A=A0ID=E5=88=A4=E6=96=AD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/attachments_controller.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 9d5b3cc5a..9853b4dc1 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -120,7 +120,7 @@ class AttachmentsController < ApplicationController
if params[:action] == "download_history"
UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) unless id.nil?
elsif params[:action] == "download"
- UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id)
+ UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id) unless id.nil?
end
end
From 4876e6669aae37e9e1f75ee3df1addaeb28af6e5 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 11:04:43 +0800
Subject: [PATCH 06/14] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=99=84=E4=BB=B6?=
=?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/files_controller.rb | 3 +--
app/views/files/_course_file.html.erb | 12 ++----------
app/views/files/_course_file_filter_order.html.erb | 9 +++++++++
app/views/files/search_tag_attachment.js.erb | 1 +
4 files changed, 13 insertions(+), 12 deletions(-)
create mode 100644 app/views/files/_course_file_filter_order.html.erb
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index b6ac99f11..7ae1b85f8 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -207,8 +207,7 @@ class FilesController < ApplicationController
sort = "created_on DESC"
end
if keywords != "%%"
- resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").
- reorder(sort)
+ resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
else
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
end
diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb
index b548092cf..50b1d0639 100644
--- a/app/views/files/_course_file.html.erb
+++ b/app/views/files/_course_file.html.erb
@@ -108,16 +108,8 @@
共有 <%= @all_attachments.count%> 个资源
-
- <% if @order == "asc" %>
- 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
- <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
- <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
- <% else %>
- 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
- <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
- <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
- <% end %>
+
+ <%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
diff --git a/app/views/files/_course_file_filter_order.html.erb b/app/views/files/_course_file_filter_order.html.erb
new file mode 100644
index 000000000..b5890fec6
--- /dev/null
+++ b/app/views/files/_course_file_filter_order.html.erb
@@ -0,0 +1,9 @@
+<% if @order == "asc" %>
+ 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => true %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
+ <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
+ <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
+<% else %>
+ 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey" , :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
+ <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
+ <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
+<% end %>
\ No newline at end of file
diff --git a/app/views/files/search_tag_attachment.js.erb b/app/views/files/search_tag_attachment.js.erb
index 31df68b6a..3003d8b98 100644
--- a/app/views/files/search_tag_attachment.js.erb
+++ b/app/views/files/search_tag_attachment.js.erb
@@ -1,5 +1,6 @@
<% if @course %>
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
+ $("#course_filter_order").html("<%= escape_javascript(render :partial => 'course_file_filter_order', :locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach, tag_name: @tag_name, q: @q})%>");
$("#attachment_count").html("<%= @result.count%>")
<% else %>
$("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>");
From 888c024e9ea6902c1edb0e9a63707696e9acce66 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 12:23:59 +0800
Subject: [PATCH 07/14] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93ajax=E5=B1=80?=
=?UTF-8?q?=E9=83=A8=E5=88=B7=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../files/_course_file_filter_order.html.erb | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/app/views/files/_course_file_filter_order.html.erb b/app/views/files/_course_file_filter_order.html.erb
index b5890fec6..a740d9481 100644
--- a/app/views/files/_course_file_filter_order.html.erb
+++ b/app/views/files/_course_file_filter_order.html.erb
@@ -1,9 +1,15 @@
<% if @order == "asc" %>
- 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => true %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
- <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
- <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:desc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
+ 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
+ <%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
+ <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey",:remote => true %>
+ <%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
+ <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
+ <%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
<% else %>
- 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey" , :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
- <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
- <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:asc", :tag_name => @tag_name, :q => @q), :class => "f_b c_grey", :remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
+ 按 <%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey" , :remote => true %>
+ <%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /
+ <%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey", :remote => true %>
+ <%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /
+ <%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort =>"quotes:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q),:class => "f_b c_grey", :remote => true %>
+ <%= render partial:'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序
<% end %>
\ No newline at end of file
From 2fe1100da6247051f7f3c477235cf40449eb76ac Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 12:34:41 +0800
Subject: [PATCH 08/14] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E4=BD=BF=E8=80=85=E5=B8=96=E5=AD=90=E4=B8=AD=E6=97=B6=E9=97=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/users/_course_message.html.erb | 8 --------
1 file changed, 8 deletions(-)
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb
index 7477eaabd..aed741ce5 100644
--- a/app/views/users/_course_message.html.erb
+++ b/app/views/users/_course_message.html.erb
@@ -41,14 +41,6 @@
<% content = activity.parent.content%>
<% end %>
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
- <% if activity.status == 1 %>
- <%= activity.created_on.year %>
- 年
- <%= activity.created_on.month %>
- 月
- <%= activity.created_on.day %>
- 日
- <% end %>
From 8a8c9bf7c3dccaa32dc38fe340e0901c3b94661d Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 12:41:07 +0800
Subject: [PATCH 09/14] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/course_activity.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb
index a02eb750c..49326f06b 100644
--- a/app/models/course_activity.rb
+++ b/app/models/course_activity.rb
@@ -75,7 +75,7 @@ class CourseActivity < ActiveRecord::Base
# message的status状态为0为正常,为1表示创建课程时发送的message
# author_id 默认为课程使者创建
message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => 1 , :sticky => true, :status => true )
- # 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直
+ # 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一致
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first
end
end
From 51bd745b8d4c5e4aab7f3d90ad3ce86045ca4981 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 13:39:28 +0800
Subject: [PATCH 10/14] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?=
=?UTF-8?q?=E5=8C=BA=E9=99=90=E5=88=B6=E6=94=B9=E6=88=9020000?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/models/course_activity.rb | 2 +-
public/javascripts/course.js | 6 +++---
public/javascripts/organization.js | 6 +++---
public/javascripts/project.js | 6 +++---
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb
index 49326f06b..96ec6e355 100644
--- a/app/models/course_activity.rb
+++ b/app/models/course_activity.rb
@@ -66,8 +66,8 @@ class CourseActivity < ActiveRecord::Base
# 发布新课导语
# 导语要放置在课程创建信息之后
- # 导语
def add_course_lead
+ # 避免空数据迁移报错问题
if self.course_act_type == "Course" and Message.where("id=12440").any?
lead_message = Message.find(12440)
name = lead_message.subject
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 544c2bc33..b5255f786 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -247,11 +247,11 @@ function regexTopicDescription()
function submit_topic()
{
- if(regexTopicSubject() && regexTopicDescription())
- {
+// if(regexTopicSubject() && regexTopicDescription())
+// {
message_content_editor.sync();
$("#message-form").submit();
- }
+// }
}
function reset_topic(){
diff --git a/public/javascripts/organization.js b/public/javascripts/organization.js
index bb7d6c5bb..7c1f3578c 100644
--- a/public/javascripts/organization.js
+++ b/public/javascripts/organization.js
@@ -3,11 +3,11 @@
*/
function submit_topic()
{
- if(regexTopicSubject() && regexTopicDescription())
- {
+// if(regexTopicSubject() && regexTopicDescription())
+// {
message_content_editor.sync();
$("#message-form").submit();
- }
+// }
}
function regexTopicSubject() {
diff --git a/public/javascripts/project.js b/public/javascripts/project.js
index c08c81054..75f6bb84e 100644
--- a/public/javascripts/project.js
+++ b/public/javascripts/project.js
@@ -618,11 +618,11 @@ function regexTopicDescription()
}
function submit_topic_project()
{
- if(regexTopicSubject() && regexTopicDescription())
- {
+// if(regexTopicSubject() && regexTopicDescription())
+// {
message_content_editor.sync();
$("#message-form-project").submit();
- }
+// }
}
function reset_topic(){
From bff20ee0721d29f75a673e73d79a3718b28a301d Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 14:16:23 +0800
Subject: [PATCH 11/14] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E6=A6=9C=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/helpers/courses_helper.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index d98de27f6..37c7deb4c 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -865,7 +865,7 @@ module CoursesHelper
# 学生按作业总分排序,取前8个
def hero_homework_score(course, score_sort_by)
sql_select = "SELECT members.*,(
- SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))
+ SELECT SUM(IF(student_works.final_score is null,null,IF(student_works.final_score = 0, 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{course.id}
From e167a28d49ad15983730a805332f77efac4b8a5f Mon Sep 17 00:00:00 2001
From: cxt
Date: Fri, 18 Mar 2016 14:59:34 +0800
Subject: [PATCH 12/14] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=8E=A8=E8=8D=90?=
=?UTF-8?q?=E7=9A=84=E4=BD=9C=E4=B8=9A=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/courses/_recommendation.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/courses/_recommendation.html.erb b/app/views/courses/_recommendation.html.erb
index f697383ca..28cc54ab8 100644
--- a/app/views/courses/_recommendation.html.erb
+++ b/app/views/courses/_recommendation.html.erb
@@ -11,8 +11,8 @@
<% if e_course.attachments.count > 0 %>
<%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)
<% end %>
- <% if e_course.homework_commons.count > 0 %>
- <%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)
+ <% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
+ <%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)
<% end %>
From 9917e802cb651f3d20a505341489fd285411698c Mon Sep 17 00:00:00 2001
From: cxt
Date: Fri, 18 Mar 2016 15:15:25 +0800
Subject: [PATCH 13/14] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=8E=A8=E8=8D=90?=
=?UTF-8?q?=E7=9A=84=E8=B5=84=E6=BA=90=E7=BB=9F=E8=AE=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/courses_controller.rb | 1 +
app/views/courses/_recommendation.html.erb | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 24f5fd52c..dfa30915e 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -7,6 +7,7 @@ class CoursesController < ApplicationController
helper :members
helper :words
helper :attachments
+ helper :files
helper :activity_notifys
before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
diff --git a/app/views/courses/_recommendation.html.erb b/app/views/courses/_recommendation.html.erb
index 28cc54ab8..d92eb3cf4 100644
--- a/app/views/courses/_recommendation.html.erb
+++ b/app/views/courses/_recommendation.html.erb
@@ -8,8 +8,8 @@
<%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %>
- <% if e_course.attachments.count > 0 %>
- <%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)
+ <% if visable_attachemnts(e_course.attachments).count > 0 %>
+ <%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts(e_course.attachments).count, course_files_path(e_course), :class => "linkBlue2" %>)
<% end %>
<% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
<%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)
From fc6210eadafe9a013baab34c66d7145e32628e48 Mon Sep 17 00:00:00 2001
From: huang
Date: Fri, 18 Mar 2016 15:17:49 +0800
Subject: [PATCH 14/14] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=AF=BC=E5=85=A5?=
=?UTF-8?q?=EF=BC=8C=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=E4=B8=AD=E5=AF=BC?=
=?UTF-8?q?=E5=85=A5400=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/users_controller.rb | 5 +++++
app/views/files/_course_file.html.erb | 2 +-
app/views/users/_import_resource_info.html.erb | 2 +-
app/views/users/_user_import_resource_list.html.erb | 4 ++--
app/views/users/_user_import_resource_search.html.erb | 2 +-
app/views/users/import_resources.js.erb | 6 +++---
app/views/users/import_resources_search.js.erb | 4 +++-
7 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 33b6e8643..034595e5d 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -2533,6 +2533,8 @@ class UsersController < ApplicationController
render_403
return
end
+ @resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
+ @resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
@user = User.find(params[:id])
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
@@ -2561,6 +2563,8 @@ class UsersController < ApplicationController
end
def import_resources_search
+ @resource_id = params[:mul_id]
+ @resource_type = params[:mul_type]
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
@@ -2571,6 +2575,7 @@ class UsersController < ApplicationController
render_403
return
end
+ @resource_id = params[:mul_id]
if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
user_course_ids = User.current.courses.map { |c| c.id}
diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb
index 50b1d0639..2cf43f896 100644
--- a/app/views/files/_course_file.html.erb
+++ b/app/views/files/_course_file.html.erb
@@ -116,7 +116,7 @@
- <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
+ <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
<%# html_title(l(:label_attachment_plural)) -%>
\ No newline at end of file
diff --git a/app/views/users/_import_resource_info.html.erb b/app/views/users/_import_resource_info.html.erb
index 4ea56ad9f..0a9d92b5c 100644
--- a/app/views/users/_import_resource_info.html.erb
+++ b/app/views/users/_import_resource_info.html.erb
@@ -27,7 +27,7 @@
我的资源
<% end %>
- <%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => ''} %>
+ <%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => '', :mul_id => @resource_id, :mul_type => @resource_type} %>
diff --git a/app/views/users/_user_import_resource_list.html.erb b/app/views/users/_user_import_resource_list.html.erb
index af4f951e0..f48e6c8fb 100644
--- a/app/views/users/_user_import_resource_list.html.erb
+++ b/app/views/users/_user_import_resource_list.html.erb
@@ -1,6 +1,6 @@
<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container',
- :mul_id => project_id.nil? ? (course_id.nil? ? subfield_file_id : course_id) : project_id,
- :mul_type => project_id.nil? ? (course_id.nil? ? "SubfieldFile" : "Course") : "Project"}),
+ :mul_id => @resource_id,
+ :mul_type => @resource_type}),
:method => 'post', :id => 'resource_import_container_form') do %>
<% @attachments.each do |attach| %>
diff --git a/app/views/users/_user_import_resource_search.html.erb b/app/views/users/_user_import_resource_search.html.erb
index b048675dd..fc86ec26e 100644
--- a/app/views/users/_user_import_resource_search.html.erb
+++ b/app/views/users/_user_import_resource_search.html.erb
@@ -9,7 +9,7 @@
}
lastSearchCondition = $(e.target).val().trim();
$.ajax({
- url: '<%= url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id) %>'+'?name='+ e.target.value+'&type=<%=type %>',
+ url: '<%= url_for({:controller => 'users', :action => 'import_resources_search', :id => User.current.id}) %>'+'?name='+ e.target.value+'&type=<%=type %>'+'&mul_id=<%=@resource_id %>'+'&mul_type=<%=@resource_type %>',
type:'get'
});
}
diff --git a/app/views/users/import_resources.js.erb b/app/views/users/import_resources.js.erb
index 6244e8e64..b07f534e7 100644
--- a/app/views/users/import_resources.js.erb
+++ b/app/views/users/import_resources.js.erb
@@ -1,9 +1,9 @@
<% if params[:project_id] %>
-$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :project_id => params[:project_id]} ) %>');
+$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :project_id => params[:project_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
<% elsif params[:course_id] %>
-$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :course_id => params[:course_id]} ) %>');
+$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :course_id => params[:course_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
<% elsif params[:subfield_file_id] %>
-$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :subfield_file_id => params[:subfield_file_id]} ) %>');
+$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :subfield_file_id => params[:subfield_file_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
<% end %>
showModal('ajax-modal', '615px');
$('#ajax-modal').siblings().remove();
diff --git a/app/views/users/import_resources_search.js.erb b/app/views/users/import_resources_search.js.erb
index ea527ab6b..928235f4c 100644
--- a/app/views/users/import_resources_search.js.erb
+++ b/app/views/users/import_resources_search.js.erb
@@ -1,3 +1,5 @@
$("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list',
- :locals => {:user => @user, :type => @type, :project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} ) %>');
+ :locals => {:user => @user, :type => @type,
+ :mul_id => @resource_id,
+ :mul_type => @resource_type}) %>');
$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');