From 8b672cc7c3ee4868cbbcb0bd5e72517c748bc5dc Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 3 May 2016 17:57:24 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E3=80=81=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=88=97=E8=A1=A8=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 2 ++ app/controllers/users_controller.rb | 6 +++--- app/views/users/_user_course_list.html.erb | 1 + app/views/users/_user_project_list.html.erb | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index d35d7ac63..51eb759e1 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -83,6 +83,8 @@ class NewsController < ApplicationController sort_type = @b_sort == 1 ? "asc" : "desc" + #scope = News.find_by_sql("select a.*,b.updated_at from news a, course_activities b where a.course_id = 532 and a.course_id = b.course_id and b.course_act_id = a.id ) ") + scope = @course ? @course.news.course_visible : News.course_visible news_arr = scope.map{|news| news.id} diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c4b1b244e..f67289a4b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2855,7 +2855,7 @@ class UsersController < ApplicationController @c_sort = 2 end - sort_name = "created_at" + sort_name = "updated_at" sort_type = @c_sort == 1 ? "asc" : "desc" @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a #{sort_type}") @@ -2899,10 +2899,10 @@ class UsersController < ApplicationController @c_sort = 2 end - sort_name = "created_on" + sort_name = "updated_on" sort_type = @c_sort == 1 ? "asc" : "desc" - @projects = @user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a #{sort_type}") + @projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a #{sort_type}") #根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num if @order.to_i == 2 diff --git a/app/views/users/_user_course_list.html.erb b/app/views/users/_user_course_list.html.erb index ca9420f7d..2fbf8e6ce 100644 --- a/app/views/users/_user_course_list.html.erb +++ b/app/views/users/_user_course_list.html.erb @@ -30,6 +30,7 @@ 创建时间:<%= format_time(course.created_at) %> + 更新时间:<%= format_time(course.updated_at) %> 开课学期:  <%= current_time_and_term course %> diff --git a/app/views/users/_user_project_list.html.erb b/app/views/users/_user_project_list.html.erb index 11f2981b0..fbc02c848 100644 --- a/app/views/users/_user_project_list.html.erb +++ b/app/views/users/_user_project_list.html.erb @@ -27,6 +27,7 @@
  • 创建时间:<%= format_time(project.created_on) %> + 更新时间:<%= format_time(project.updated_on) %>

    <%= project.project_score.issue_num %>问题| <%= project.project_score.attach_num %>资源

  • From afd176b805441b44f41acf96038748a096a17191 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 3 May 2016 19:10:04 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=8C=89=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/new_base_user.html.erb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 0ef49408d..65ea3770d 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -214,7 +214,7 @@ <% end%> <% end %> - <% if @user.courses.visible.count > 0 + <%# if @user.courses.visible.count > 0 course_order_ids = "(" + CourseActivity.find_by_sql("SELECT c.course_id, updated_at FROM (SELECT ca.course_id, MAX(ca.updated_at) AS updated_at FROM course_activities ca WHERE ca.course_id IN (" + @user.courses.visible.select('courses.id').map{|c| c.id}.join(',') + ") @@ -226,8 +226,7 @@ end %> - <%# courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> - + <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %>
    - <% if @user.projects.visible.count > 0 + <%# if @user.projects.visible.count > 0 project_order_ids = "(" + ForgeActivity.find_by_sql("SELECT p.project_id, p.created_at FROM (SELECT fa.project_id, MAX(fa.created_at) AS created_at FROM forge_activities fa WHERE fa.project_id IN (" + @user.projects.visible.select('projects.id').map{|p| p.id}.join(',') + ") @@ -258,7 +257,7 @@ end %> - <%# projects = @user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%> + <% projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%>
      From 411ae6f89ec3165eae78bea15be3d6463fddc6d5 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 4 May 2016 11:03:08 +0800 Subject: [PATCH 3/7] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E8=B4=B4=E5=90=A7?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=982?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 3 ++- app/controllers/users_controller.rb | 7 +++++-- app/views/forums/_show_topics.html.erb | 4 +++- app/views/forums/show.html.erb | 3 --- app/views/forums/show.js.erb | 1 - app/views/layouts/new_base_user.html.erb | 10 ++++++---- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 51eb759e1..76b229dbf 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -103,7 +103,8 @@ class NewsController < ApplicationController end scope_order.each do |topic| - topic[:updated_at] = CourseActivity.where("course_act_type='#{topic.class}' and course_act_id =#{topic.id}").first.updated_at + topic[:updated_at] = topic.course_acts.first.updated_at + #topic[:updated_at] = CourseActivity.where("course_act_type='#{topic.class}' and course_act_id =#{topic.id}").first.updated_at end #根据 赞+回复数排序 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f67289a4b..6cc94d5a7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2858,7 +2858,9 @@ class UsersController < ApplicationController sort_name = "updated_at" sort_type = @c_sort == 1 ? "asc" : "desc" - @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a #{sort_type}") + @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*").order("#{sort_name} #{sort_type}") + + # @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a #{sort_type}") #根据 作业+资源数排序 if @order.to_i == 2 @@ -2902,7 +2904,8 @@ class UsersController < ApplicationController sort_name = "updated_on" sort_type = @c_sort == 1 ? "asc" : "desc" - @projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a #{sort_type}") + @projects = @user.projects.visible.select("projects.*").order("#{sort_name} #{sort_type}") + # @projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a #{sort_type}") #根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num if @order.to_i == 2 diff --git a/app/views/forums/_show_topics.html.erb b/app/views/forums/_show_topics.html.erb index 93df27e42..08c030f90 100644 --- a/app/views/forums/_show_topics.html.erb +++ b/app/views/forums/_show_topics.html.erb @@ -29,7 +29,9 @@
    <% end %> - + <% else %>

    <%= l(:label_no_data) %>

    <% end %> diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index b0ed5a60c..2b3772734 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -41,9 +41,6 @@
    <%= render :partial => 'show_topics',:locals => {:memos=>@memos}%>
    - diff --git a/app/views/forums/show.js.erb b/app/views/forums/show.js.erb index 9e36215ac..48b1474cb 100644 --- a/app/views/forums/show.js.erb +++ b/app/views/forums/show.js.erb @@ -1,2 +1 @@ $("#topics_list").html("<%= escape_javascript(render :partial => 'show_topics',:locals => {:memos=>@memos})%>") -$("#pages").html('<%= pagination_links_full @topic_pages, @topic_count,:per_page_links => false,:remote =>true%>'); \ No newline at end of file diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 65ea3770d..e43aa499f 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -346,28 +346,30 @@
    From 9dc92fe817f934e66d40dcb64faded2ab82c2043 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Wed, 4 May 2016 16:28:40 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 5 +- app/views/blogs/_article.html.erb | 90 ++++++++++---------- app/views/layouts/_user_courses.html.erb | 4 +- app/views/layouts/_user_projects.html.erb | 4 +- app/views/users/_course_boardlist.html.erb | 94 +++++++++++---------- app/views/users/_course_newslist.html.erb | 62 +++++++------- app/views/users/_project_boardlist.html.erb | 94 +++++++++++---------- app/views/users/_user_course_list.html.erb | 72 ++++++++-------- app/views/users/_user_project_list.html.erb | 50 ++++++----- 9 files changed, 249 insertions(+), 226 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6cc94d5a7..54970add6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2858,8 +2858,7 @@ class UsersController < ApplicationController sort_name = "updated_at" sort_type = @c_sort == 1 ? "asc" : "desc" - @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*").order("#{sort_name} #{sort_type}") - + @courses = @user.courses.visible.where("is_delete =?", 0).order("#{sort_name} #{sort_type}") # @courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a #{sort_type}") #根据 作业+资源数排序 @@ -2904,7 +2903,7 @@ class UsersController < ApplicationController sort_name = "updated_on" sort_type = @c_sort == 1 ? "asc" : "desc" - @projects = @user.projects.visible.select("projects.*").order("#{sort_name} #{sort_type}") + @projects = @user.projects.visible.order("#{sort_name} #{sort_type}") # @projects = @user.projects.visible.select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a #{sort_type}") #根据 问题+资源数排序 @project.project_score.issue_num @project.project_score.attach_num diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index ea494d0f9..4c00ee8a2 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -16,51 +16,55 @@
    - <% topics.each do |activity| %> - +
    + <% else %> +

    <%= l(:label_no_data) %>

    <% end %> -
    - -
    -
    diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index e740fe43d..07eb70f0f 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -75,10 +75,10 @@ <% end%>