diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index e974f26b4..9853b4dc1 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -103,6 +103,9 @@ class AttachmentsController < ApplicationController direct_download_history end else + # 记录用户行为 + record_user_actions(params[:id]) + # 直接下载历史版本 direct_download_history end end @@ -113,6 +116,14 @@ class AttachmentsController < ApplicationController redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" end + 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) unless id.nil? + end + end + def download # modify by nwb # 下载添加权限设置 @@ -135,6 +146,8 @@ class AttachmentsController < ApplicationController direct_download end else + # 记录用户行为 + record_user_actions(params[:id]) direct_download end end 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/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/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} 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' diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index a02eb750c..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 @@ -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 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/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index b548092cf..2cf43f896 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -108,23 +108,15 @@

共有 <%= @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} %>

- <%= 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/files/_course_file_filter_order.html.erb b/app/views/files/_course_file_filter_order.html.erb new file mode 100644 index 000000000..a740d9481 --- /dev/null +++ b/app/views/files/_course_file_filter_order.html.erb @@ -0,0 +1,15 @@ +<% if @order == "asc" %> + 按 <%= 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.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 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}) %>"); 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 %>
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 %> 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| %>